Expand description
JMAP Chat extension method handlers.
§Usage
Implement ChatBackend for your storage layer, then call
register_chat_handlers to wire all method names into a
jmap_server::Dispatcher:
let mut dispatcher: Dispatcher<()> = Dispatcher::new();
register_chat_handlers(&mut dispatcher, Arc::new(backend));§memory feature (reference implementation)
Enable the memory feature to expose the memory::MemoryBackend
reference implementation of ChatBackend. This is the same
backend used by this crate’s own integration tests, intended for
downstream contributors to study and for smoke tests / examples
that do not want to stand up a real database. Not production.
API stability is opt-in via this feature and may break across minor
versions while the crate is pre-1.0.
§Permission enforcement: backend canonical
All Space/set permission gates live in the backend’s
apply_space_patch implementation (see memory::MemoryBackend
under the memory feature for the reference impl). The handler
handle_space_set does NOT permission-check.
The pure helper required_permissions_for_op
maps each SpacePatchOp variant to its required
ChatPermissions per draft-atwood-jmap-chat-00 §Space/set. Backends consume this
helper inside apply_space_patch after resolving the caller’s
effective permissions from the Space members entry whose id is
the accountId (the owner, per draft §Terminology). The gates apply
whether or not jmap_server::JmapBackend::principal_id resolves a
caller identity.
Handlers MUST NOT consume the helper for gating — backends are the
single source of truth. This mirrors the workspace-wide rule
documented in workspace AGENTS.md “Caller identity (foundation
seam)”:
- Handlers do NO permission checking.
- Defense-in-depth handler pre-checks are allowed but the backend MUST re-verify atomically with the mutation.
Modules§
- message
- Message/* method handlers (draft-atwood-jmap-chat-00 §Message).
Structs§
- Attachment
Blob - The stored blob behind an Attachment
blobId, as reported byChatBackend::attachment_blob. - Built
Push - A built
ChatMessagePushand the Web Push urgency to deliver it with. - Chat
Limits - Implementation-defined per-Space content limits enforced by
Space/sethandlers. - Companion
Streams - The companion WebSocket capabilities the server advertises, which
decide whether the companion
dataTypesvalues"vtc"and"scene"are recognized in aChatStreamEnableframe. - Ephemeral
Subscription - The ephemeral subscription of one WebSocket connection, normalized
from a
ChatStreamEnableframe. - OpResult
- The outcome of a single
SpacePatchOpapplied byChatBackend::apply_space_patch. - Owner
Flags - The account owner’s standing in the Chat at delivery time, which decides the broadcast scopes that target them.
- Push
Item - The stored records one
ChatMessageEntryis built from. - Slow
Mode Error - Outcome of a
ChatBackend::slow_mode_checkrejection. - Space
Metadata Patch - A typed view of the five top-level metadata fields that
Space/setupdatecan mutate (draft-atwood-jmap-chat-00 §Space/set, fieldsname,description,iconBlobId,isPublic,isPubliclyPreviewable).
Enums§
- Chat
Contact Property - Property selector for
crate::ChatContact/getand/set. - Chat
Property - Property selector for
crate::Chat/getand/set. - DidAuth
Rejection - Why a DID-form peer identity is not bound to the signing key.
- DidDocument
- A resolved DID Document and whether it may come from a cache.
- Emoji
SetOp - Identifies the kind of
CustomEmoji/setoperation being authorized byChatBackend::may_set_custom_emoji. - Group
Update Action - The
actionof aOutboundEvent::GroupUpdate(draft-atwood-jmap-chat-federation-00 §Peer/groupUpdate). - IdScope
- Which ids a subscribed data type covers.
- Invite
Join Refusal - Why
ChatBackend::join_space_with_inviterefused a redemption. - Message
Property - Property selector for
crate::Message/getand/set. - Outbound
Event - One outbound event the
Message/set,Chat/set,Chat/typingorPresenceStatus/sethandler reports. - Reaction
Action - The
actionof aOutboundEvent::ReactionUpdate(draft-atwood-jmap-chat-federation-00 §Peer/deliverreactionUpdate). - Read
Position Property - Property selector for
crate::ReadPosition/getand/set. - Required
Permissions - Result of
required_permissions_for_op— typed alternative to a sentinel-string return value. - Space
Patch Op - A single Space/set update mutation operation.
- Space
Property - Property selector for
crate::Space/getand/set.
Traits§
- Chat
Backend - Storage backend for JMAP Chat method handlers.
Functions§
- build_
chat_ message_ push - Build the
ChatMessagePushfor one new inbound message under one subscription’sChatPushConfigforaccount_id. - chat_
state_ change_ for - The
StateChangeto push tosubfor the types inchanged, orNonewhen nothing is left to send. - fit_
chat_ message_ push - Fit
pushto a platform payload limit ofmax_bytesserialized JSON bytes, returning the payloads to deliver in order. ANoneelement stands for one message whose entry cannot fit; the caller delivers aStateChangefor theMessagedata type in its place. - handle_
ban_ changes - Handle a
SpaceBan/changesmethod call (draft-atwood-jmap-chat-00 §SpaceBan). - handle_
ban_ get - Handle a
SpaceBan/getmethod call (draft-atwood-jmap-chat-00 §SpaceBan). - handle_
ban_ set - Handle a
SpaceBan/setmethod call (draft-atwood-jmap-chat-00 §SpaceBan). - handle_
chat_ changes - Handle a
Chat/changesmethod call (draft-atwood-jmap-chat-00 §Chat). - handle_
chat_ get - Handle a
Chat/getmethod call (draft-atwood-jmap-chat-00 §Chat). - handle_
chat_ query - Handle a
Chat/querymethod call (draft-atwood-jmap-chat-00 §Chat). - handle_
chat_ query_ changes - Handle a
Chat/queryChangesmethod call (draft-atwood-jmap-chat-00 §Chat). - handle_
chat_ set - Handle a
Chat/setmethod call (draft-atwood-jmap-chat-00 §Chat). - handle_
chat_ typing - Handle a
Chat/typingmethod call (draft-atwood-jmap-chat-00 §Chat). - handle_
contact_ changes - Handle a
ChatContact/changesmethod call (draft-atwood-jmap-chat-00 §ChatContact). - handle_
contact_ get - Handle a
ChatContact/getmethod call (draft-atwood-jmap-chat-00 §ChatContact). - handle_
contact_ query - Handle a
ChatContact/querymethod call (draft-atwood-jmap-chat-00 §ChatContact). - handle_
contact_ query_ changes - Handle a
ChatContact/queryChangesmethod call (draft-atwood-jmap-chat-00 §ChatContact). - handle_
contact_ set - Handle a
ChatContact/setmethod call (draft-atwood-jmap-chat-00 §ChatContact). - handle_
emoji_ changes - Handle a
CustomEmoji/changesmethod call (draft-atwood-jmap-chat-00 §CustomEmoji). - handle_
emoji_ get - Handle a
CustomEmoji/getmethod call (draft-atwood-jmap-chat-00 §CustomEmoji). - handle_
emoji_ query - Handle a
CustomEmoji/querymethod call (draft-atwood-jmap-chat-00 §CustomEmoji). - handle_
emoji_ query_ changes - Handle a
CustomEmoji/queryChangesmethod call (draft-atwood-jmap-chat-00 §CustomEmoji). - handle_
emoji_ set - Handle a
CustomEmoji/setmethod call (draft-atwood-jmap-chat-00 §CustomEmoji). - handle_
invite_ changes - Handle a
SpaceInvite/changesmethod call (draft-atwood-jmap-chat-00 §SpaceInvite). - handle_
invite_ get - Handle a
SpaceInvite/getmethod call (draft-atwood-jmap-chat-00 §SpaceInvite). - handle_
invite_ set - Handle a
SpaceInvite/setmethod call (draft-atwood-jmap-chat-00 §SpaceInvite). - handle_
position_ changes - Handle a
ReadPosition/changesmethod call (draft-atwood-jmap-chat-00 §ReadPosition). - handle_
position_ get - Handle a
ReadPosition/getmethod call (draft-atwood-jmap-chat-00 §ReadPosition). - handle_
position_ set - Handle a
ReadPosition/setmethod call (draft-atwood-jmap-chat-00 §ReadPosition). - handle_
presence_ changes - Handle a
PresenceStatus/changesmethod call (draft-atwood-jmap-chat-00 §PresenceStatus). - handle_
presence_ get - Handle a
PresenceStatus/getmethod call (draft-atwood-jmap-chat-00 §PresenceStatus). - handle_
presence_ set - Handle a
PresenceStatus/setmethod call (draft-atwood-jmap-chat-00 §PresenceStatus). - handle_
space_ changes - Handle a
Space/changesmethod call (draft-atwood-jmap-chat-00 §Space). - handle_
space_ get - Handle a
Space/getmethod call (draft-atwood-jmap-chat-00 §Space). - handle_
space_ join - Handle a
Space/joinmethod call (draft-atwood-jmap-chat-00 §Space). - handle_
space_ query - Handle a
Space/querymethod call (draft-atwood-jmap-chat-00 §Space). - handle_
space_ query_ changes - Handle a
Space/queryChangesmethod call (draft-atwood-jmap-chat-00 §Space). - handle_
space_ set - Handle a
Space/setmethod call (draft-atwood-jmap-chat-00 §Space). - owner_
unread_ count - The owner of
account_id’s total unread message count across all non-muted Chats, forbuild_chat_message_push. - project_
presence - The
ChatPresenceEventthe owner ofaccount_idmay receive forevent, orNoneif it must be dropped. - register_
chat_ handlers - Register all JMAP Chat method handlers with
dispatcher. - required_
permissions_ for_ op - Returns the set of permissions required to apply this
SpacePatchOpvariant, per draft-atwood-jmap-chat-00 §Space/set L1256-1295 (jmap-chat-spec 91672c9). - resolve_
channel_ permissions - Resolve a member’s effective permissions in one channel Chat, per draft-atwood-jmap-chat-00 §Space Permission Resolution.
- should_
deliver_ typing - Whether
eventmay be delivered to the owner ofaccount_id. - should_
push - Whether a
ChatMessagePushfor the new inbound messagemsggoes to a subscription whosechatPushentry foraccount_idiscfg. - strip_
unsupported_ chat_ push - Remove
chatPushentries for accounts not incapsfrom a stored subscription’sextramap before it is returned. - sweep_
expired - Apply every expiry deadline in
account_idthat has passed atnow. - validate_
chat_ push - Check the
chatPushproperty in aPushSubscription’sextramap before it is stored. - verify_
did_ binding - Checks that
signing_key, thepeerSigningKeyskey that verified the request signature, is bound todid(draft-atwood-jmap-chat-did-00 §DID-Bound Verification steps 2 and 3).