pub trait ChatEvents: JmapBackend {
// Provided methods
fn on_chat_destroyed(
&self,
caller: &Self::CallerCtx,
account_id: &Id,
chat_id: &Id,
) -> impl Future<Output = ()> + Send { ... }
fn on_space_destroyed(
&self,
caller: &Self::CallerCtx,
account_id: &Id,
space_id: &Id,
) -> impl Future<Output = ()> + Send { ... }
fn on_space_ban_created(
&self,
caller: &Self::CallerCtx,
account_id: &Id,
ban: &SpaceBan,
) -> impl Future<Output = ()> + Send { ... }
fn on_outbound_event(
&self,
caller: &Self::CallerCtx,
account_id: &Id,
event: &OutboundEvent,
) -> impl Future<Output = ()> + Send { ... }
}Expand description
Notifications from the handlers after a change: lifecycle callbacks and outbound events.
Part of ChatBackend (docs/design/chat-backend-split.md).
Provided Methods§
Sourcefn on_chat_destroyed(
&self,
caller: &Self::CallerCtx,
account_id: &Id,
chat_id: &Id,
) -> impl Future<Output = ()> + Send
fn on_chat_destroyed( &self, caller: &Self::CallerCtx, account_id: &Id, chat_id: &Id, ) -> impl Future<Output = ()> + Send
Called after a Chat is destroyed, so a companion extension can
update the records that reference it. Examples:
draft-atwood-jmap-chat-tasks-00 §Lifecycle (“the affected Tasks’
chatId fields MUST be cleared”) and draft-atwood-jmap-vtc-00
§VTCCall (“the server MUST clear the corresponding field to
null on all VTCCalls that reference it”).
§When the handler calls this
Once for each Chat that a request destroys, after the destroy succeeds:
- a
Chat/setdestroy; - each channel in a successful
Space/setremoveChannelspatch; - each channel Chat whose
spaceIdis a Space thatSpace/setdestroys (draft-atwood-jmap-chat-00 §Destroying a Space: “Cascades to all channel Chats”). These calls come beforeSelf::on_space_destroyedfor that Space.
It is not called when the handler deletes a duplicate direct Chat it created in the same request, because no response ever named that id.
The destroy is already committed, so the hook cannot fail the
request. A backend handles its own errors here. A change it makes
to another record type MUST advance that type’s state, as in
ChatStore::destroy_object (“Cascades”).
§Default implementation
Does nothing. A backend that implements an extension which references Chats overrides it.
Sourcefn on_space_destroyed(
&self,
caller: &Self::CallerCtx,
account_id: &Id,
space_id: &Id,
) -> impl Future<Output = ()> + Send
fn on_space_destroyed( &self, caller: &Self::CallerCtx, account_id: &Id, space_id: &Id, ) -> impl Future<Output = ()> + Send
Called after a Space/set destroy succeeds, so a companion
extension can update the records that reference the Space.
Examples: draft-atwood-jmap-vtc-00 §VTCCall (clear spaceId on
VTCCalls) and draft-atwood-jmap-chat-filenode-00 §Space Deletion
(“the server SHOULD also destroy the associated file tree”).
The handler calls it once per destroyed Space, after
Self::on_chat_destroyed for each of its channel Chats. The
error and state rules of Self::on_chat_destroyed apply.
§Default implementation
Does nothing. A backend that implements an extension which references Spaces overrides it.
Sourcefn on_space_ban_created(
&self,
caller: &Self::CallerCtx,
account_id: &Id,
ban: &SpaceBan,
) -> impl Future<Output = ()> + Send
fn on_space_ban_created( &self, caller: &Self::CallerCtx, account_id: &Id, ban: &SpaceBan, ) -> impl Future<Output = ()> + Send
Called after a SpaceBan/set create succeeds, with the stored
ban, so a companion extension can apply the ban to its own
records. Example: draft-atwood-jmap-vtc-00 §Access Control “Space
ban enforcement” (the server “MUST set leftAt on that
VTCParticipant record”; “The ban takes effect immediately on
active calls”).
The handler calls it once per created ban. The error and state
rules of Self::on_chat_destroyed apply.
§Default implementation
Does nothing. A backend that implements an extension which must enforce Space bans overrides it.
Sourcefn on_outbound_event(
&self,
caller: &Self::CallerCtx,
account_id: &Id,
event: &OutboundEvent,
) -> impl Future<Output = ()> + Send
fn on_outbound_event( &self, caller: &Self::CallerCtx, account_id: &Id, event: &OutboundEvent, ) -> impl Future<Output = ()> + Send
Called when the owner’s action must be sent to other participants’
servers: a new Message, a retraction (deletedForAll), an edit, a
reaction added or removed, a group Chat change, a read receipt, a
typing signal or a presence change. A backend that implements
draft-atwood-jmap-chat-federation-00 turns the
OutboundEvent into Peer/deliver
(message, edit or reactionUpdate), Peer/retract,
Peer/groupUpdate, Peer/receipt, Peer/typing or Peer/presence
calls, typically by enqueueing the durable ones (§Persistent Queue).
OutboundEvent::Typing also drives
the local typing push to the Chat’s other local participants.
§When the handler calls this
-
Message/setcreate:OutboundEvent::NewMessage, after the Message is written (draft-atwood-jmap-chat-00 §Message/set: “enqueues the message for outbound delivery”). -
Message/setupdate settingdeletedForAll: true:OutboundEvent::Retract, after the update is written (§Peer/retract “Sender Behavior”: “the server MUST sendPeer/retractto the server of every other participant in the Chat”). If the write fails, nothing is reported. -
Message/setupdate editingbody,bodyType,mentionsorbroadcastMentionsand not deleting the Message:OutboundEvent::Edit, after the update is written. -
Chat/setcreate of a group Chat, or update that changes a group Chat’s members, roles,name,descriptionoravatarBlobId: oneOutboundEvent::GroupUpdateper action, after the write (draft-atwood-jmap-chat-00 §Chat/set). -
Message/setupdate patchingreactions/<senderReactionId>and not deleting the Message: oneOutboundEvent::ReactionUpdateper key that adds a reaction or removes a stored one, after the update is written (draft-atwood-jmap-chat-00 §Adding and Removing Reactions). -
Message/setupdate setting a non-nullreadAton a Message whosesenderIdis not the accountId:OutboundEvent::Receipt, after the update (or theburnOnReadhard-delete) is written, unless the effectivereceiptSharing(Chat.receiptSharing, elsePresenceStatus.receiptSharing) isfalse(draft-atwood-jmap-chat-federation-00 §Peer/receipt “Sender Behavior”). -
Chat/typing:OutboundEvent::Typing, after the request is validated (draft-atwood-jmap-chat-00 §Chat/typing). -
PresenceStatus/setupdate namingpresence,statusTextorstatusEmoji:OutboundEvent::Presence, after the update is written (draft-atwood-jmap-chat-federation-00 §Peer/subscribePresence).
The hook cannot fail the request. A backend handles its own errors here.
§Default implementation
Does nothing, for a server that does not federate.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl<C: MemoryCaller> ChatEvents for MemoryBackend<C>
memory only.