Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ Call a remote API on ODK Central database events:
The `centralwebhook` binary is small ~15MB and only consumes
~5MB of memory when running.

> [!NOTE]
> There is a 8000 byte Postgres limit for the submission XML that can be sent
> until [this issue](https://github.com/hotosm/central-webhook/issues/9)
> is addressed.
>
> The submission XML will simply be truncated in this case.

## Prerequisites

- ODK Central running, connecting to an accessible Postgresql database.
Expand Down
6 changes: 6 additions & 0 deletions db/trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ func CreateTrigger(ctx context.Context, dbPool *pgxpool.Pool, tableName string)
-- Merge the instanceId into the existing 'details' key in JSON
js := jsonb_set(js, '{details}', (js->'details') || result_data, true);

-- Truncate if payload is too large: https://github.com/hotosm/central-webhook/issues/8
IF length(js::text) > 8000 THEN
js := jsonb_set(js, '{truncated}', 'true'::jsonb);
js := jsonb_set(js, '{data}', 'Payload too large. Truncated.'::jsonb, true);
END IF;

-- Notify the odk-events queue
PERFORM pg_notify('odk-events', js::text);

Expand Down