Skip integrations
Privileged users can skip integrations on a per-message basis, providing greater control and flexibility when publishing messages to a channel. Skipping integration helps avoid infinite loops, for example, when an integration republishes a message to the same channel, potentially triggering itself again.
A strong use case for skipping integrations is in chat applications (for Chat SDK moderation, see Chat moderation). For example, a moderation service publishes a command telling clients to edit or delete a message. That command should not trigger further moderation events by itself.
Skip all integrations
To skip all integration rules for a specific message, set the skipRule field to '*' in the privileged section of the message extras.
The following example shows how to skip all integration rules when publishing a message to a channel:
1
2
3
4
5
6
7
8
9
10
11
const pubsubHttpClient = createHttpClient('demokey:*****');
const channel = pubsubHttpClient.channels.get('bag-ask-rod');
await channel.publish({
name: 'event_name',
data: 'event_data',
extras: {
privileged: {
skipRule: '*'
}
}
});Skip specific integration rules
You can also skip specific integration rules by including their ruleId in an array passed to skipRule. Rule IDs can be found in the Integrations tab of your Ably dashboard, via the Control API, or in the message envelope.
The following example shows how to skip specific integration rules when publishing a message to a channel:
1
2
3
4
5
6
7
8
9
const pubsubHttpClient = createHttpClient('demokey:*****');
const channel = pubsubHttpClient.channels.get('bag-ask-rod');
await channel.publish({
name: 'event_name',
data: 'event_data',
extras: {
privileged: { skipRule: ['rule_id_1'] }
}
})Updates, deletes and appends
When you update, delete or append to a message, skipRule applies to that operation the same way it does to a publish. If you specify extras in the operation, they replace the existing message's extras, so the operation only skips integrations if it sets skipRule itself.
If you leave extras out, the operation keeps the existing message's extras as part of the shallow mixin. It only keeps the privileged section, including skipRule, if the client performing the operation has the privileged-headers capability. Otherwise, the operation is not suppressed, even if it doesn't change the message's data. For example, if a client without privileged-headers deletes a message which skipped integrations when it was published, the delete is still passed to those integrations, along with the message's original data.