Skip to content

Consent

Consent records what a user wants to hear. Every conversation and inbox ID has one of three states.

StateMeaningUI location
unknownNobody has decidedRequests
allowedThe user consentedMain inbox
deniedThe user refusedHidden

Consent belongs to the inbox. Device sync copies it to the user’s other installations.

TriggerState
A peer starts a conversationunknown
The user creates a conversationallowed
The user sends a messageallowed
The app accepts or subscribesallowed
The app blocks or unsubscribesdenied
The user is re-added to a group they leftunknown

The user’s creation of the conversation with the contact is considered consent.

The user’s response to the conversation is considered consent.

Sending a message sets the conversation to allowed from any prior state, including denied. Prevent sending in a denied conversation unless the user explicitly reverses the block.

TaskBrowser, NodeKotlin, Swift
Read conversationconversation.consentState()conversation.consentState()
Read by conversation IDpreferences.getConsentState(GroupId, id)preferences.conversationState(id)
Read by inbox IDpreferences.getConsentState(InboxId, id)preferences.inboxIdState(id)
Set conversationconversation.updateConsentState(state)conversation.updateConsent(state)
Set manypreferences.setConsentStates(records)preferences.setConsentState(entries)
Stream changespreferences.streamConsent()preferences.streamConsent()

Batch state changes when possible. One batch produces one device-sync message.

const
const stream: AsyncStreamProxy<Consent[]>
stream
= await
client: Client<BuiltInContentTypes>
client
.
Client<BuiltInContentTypes>.preferences: Preferences

Gets the preferences manager for this client

preferences
.
Preferences.streamConsent(options?: StreamOptions<Consent[]>): Promise<AsyncStreamProxy<Consent[]>>

Creates a stream of consent state updates

@paramoptions - Optional stream options

@returnsStream instance for consent updates

streamConsent
({
onValue?: ((value: Consent[]) => void | Promise<void>) | undefined

Called when a value is emitted from the stream. For message streams, this selects callback mode. Do not also iterate that stream. Message delivery is acknowledged after this callback returns successfully.

onValue
:
handleConsent: (consent: Consent[]) => void
handleConsent
,
});

Use conversation.addedByInboxId on Browser and Node. Use group.addedByInboxId() on Kotlin and Swift. creatorInboxId() is available on groups on all four SDKs.