This documentation may be out of date!

This documentation site is for the versions of Synapse maintained by the Matrix.org Foundation (github.com/matrix-org/synapse), available under the Apache 2.0 licence.

Since version 1.99, Synapse is now maintained by Element under a new licence (github.com/element-hq/synapse).

If you are interested in the documentation for a later version of Synapse, please click here to navigate to this same page on the latest Element Synapse documentation site, if it's available.

Add extra fields to client events unsigned section callbacks

First introduced in Synapse v1.96.0

This callback allows modules to add extra fields to the unsigned section of events when they get sent down to clients.

These get called every time an event is to be sent to clients, so care should be taken to ensure with respect to performance.

API

To register the callback, use register_add_extra_fields_to_unsigned_client_event_callbacks on the ModuleApi.

The callback should be of the form

async def add_field_to_unsigned(
    event: EventBase,
) -> JsonDict:

where the extra fields to add to the event's unsigned section is returned. (Modules must not attempt to modify the event directly).

This cannot be used to alter the "core" fields in the unsigned section emitted by Synapse itself.

If multiple such callbacks try to add the same field to an event's unsigned section, the last-registered callback wins.