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::JmapAccounts::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§
- memory
memory - In-memory reference implementation of
ChatBackend. - message
- Message/* method handlers (draft-atwood-jmap-chat-00 §Message).
- testkit
testkit - Backend conformance suite for
ChatBackendimplementations.
Macros§
- chat_
backend_ conformance testkit - Emit one
#[test]per conformance test, each running it on a fresh backend from$make.
Structs§
- Attachment
Blob - The stored blob behind an Attachment
blobId, as reported byChatResolvers::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 byChatSpaces::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
ChatAccessPolicy::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 bySpacePolicy::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
ChatSpaces::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
Access Policy - Chat and Message access gates: send, view, pins, broadcast mentions, slow mode, blocked contacts.
- Chat
Backend - Storage backend for JMAP Chat method handlers.
- Chat
Events - Notifications from the handlers after a change: lifecycle callbacks and outbound events.
- Chat
Message Lifecycle - Message expiry and read-and-burn.
- Chat
Moderation - Group Chat moderation: ChatBan create, update and destroy, and the
kickMemberspatch key. - Chat
Resolvers - Lookups outside chat storage: attachment blobs and FileNode attachments.
- Chat
Restrictions - Per-Chat restriction gates on Message create and update and on Chat update, which a backend bound to an external room (such as a MIMI room) overrides.
- Chat
Settings - Deployment settings and identity: limits, edit history, unread counts, the owner’s user id.
- Chat
Spaces - Space structure: invites, joins, member and role patches, and Space-wide settings.
- Chat
Store - Object writes and type support: the
/setstorage half of a chat backend. - Delegate
Chat Access Policy - Forward every
ChatAccessPolicymethod tochat_access_policy’s target. - Delegate
Chat Events - Forward every
ChatEventsmethod tochat_events’s target. - Delegate
Chat Message Lifecycle - Forward every
ChatMessageLifecyclemethod tochat_message_lifecycle’s target. - Delegate
Chat Moderation - Forward every
ChatModerationmethod tochat_moderation’s target. - Delegate
Chat Resolvers - Forward every
ChatResolversmethod tochat_resolvers’s target. - Delegate
Chat Restrictions - Forward every
ChatRestrictionsmethod tochat_restrictions’s target. - Delegate
Chat Settings - Forward every
ChatSettingsmethod tochat_settings’s target. - Delegate
Chat Spaces - Forward every
ChatSpacesmethod tochat_spaces’s target. - Delegate
Chat Store - Forward every
ChatStoremethod tochat_store’s target. - Delegate
Space Policy - Forward every
SpacePolicymethod tospace_policy’s target. - Space
Policy - Space-scoped authorization gates: custom emoji, SpaceBan and SpaceInvite writes and reads.
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_ ban_ changes - Handle a
ChatBan/changesmethod call (draft-atwood-jmap-chat-00 §ChatBan/changes: “Standard JMAP/changes.”). - handle_
chat_ ban_ get - Handle a
ChatBan/getmethod call (draft-atwood-jmap-chat-00 §ChatBan). - handle_
chat_ ban_ set - Handle a
ChatBan/setmethod call (draft-atwood-jmap-chat-00 §ChatBan). - 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_ conditional - Opt this crate’s registered Foo/set methods in to
draft-ietf-jmap-conditional-02 (
ifUnchangedByandatomic; docs/design/DECISIONS.md decisions 1 and 17). - register_
chat_ handlers - Register all JMAP Chat method handlers with
dispatcher. - register_
chat_ handlers_ with_ history register_chat_handlers, then history-aware/getand/setof the eight chat history types and/query,/queryChangesof those that have them (Chat, Message, Space, ChatContact, CustomEmoji), throughDispatcher::register_history_aware(docs/design/DECISIONS.md decision 1). Handlers that take nousingin the plain registration are bound to the request’s here.- 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).