Skip to main content

Crate jmap_chat_server

Crate jmap_chat_server 

Source
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));

§websocket feature (ephemeral events over RFC 8887)

Enable websocket for the websocket module: the jmap-websocket extension handler for ChatStreamEnable / ChatStreamDisable (draft-atwood-jmap-chat-wss-00) and the server-wide hub the deployment publishes events to. Off by default, so a deployment without the WebSocket transport does not pull in jmap-websocket.

§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§

memorymemory
In-memory reference implementation of ChatBackend.
message
Message/* method handlers (draft-atwood-jmap-chat-00 §Message).
testkittestkit
Backend conformance suite for ChatBackend implementations.
websocketwebsocket
ChatStreamEnable / ChatStreamDisable and the ephemeral events they turn on, as a jmap_websocket extension (draft-atwood-jmap-chat-wss-00 §Ephemeral Chat Events).

Macros§

chat_backend_conformancetestkit
Emit one #[test] per conformance test, each running it on a fresh backend from $make.

Structs§

AttachmentBlob
The stored blob behind an Attachment blobId, as reported by ChatResolvers::attachment_blob.
BuiltPush
A built ChatMessagePush and the Web Push urgency to deliver it with.
ChatLimits
Implementation-defined per-Space content limits enforced by Space/set handlers.
CompanionStreams
The companion WebSocket capabilities the server advertises, which decide whether the companion dataTypes values "vtc" and "scene" are recognized in a ChatStreamEnable frame.
EphemeralSubscription
The ephemeral subscription of one WebSocket connection, normalized from a ChatStreamEnable frame.
OpResult
The outcome of a single SpacePatchOp applied by ChatSpaces::apply_space_patch.
OwnerFlags
The account owner’s standing in the Chat at delivery time, which decides the broadcast scopes that target them.
PushItem
The stored records one ChatMessageEntry is built from.
SlowModeError
Outcome of a ChatAccessPolicy::slow_mode_check rejection.
SpaceMetadataPatch
A typed view of the five top-level metadata fields that Space/set update can mutate (draft-atwood-jmap-chat-00 §Space/set, fields name, description, iconBlobId, isPublic, isPubliclyPreviewable).

Enums§

ChatContactProperty
Property selector for crate::ChatContact /get and /set.
ChatProperty
Property selector for crate::Chat /get and /set.
DidAuthRejection
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.
EmojiSetOp
Identifies the kind of CustomEmoji/set operation being authorized by SpacePolicy::may_set_custom_emoji.
GroupUpdateAction
The action of a OutboundEvent::GroupUpdate (draft-atwood-jmap-chat-federation-00 §Peer/groupUpdate).
IdScope
Which ids a subscribed data type covers.
InviteJoinRefusal
Why ChatSpaces::join_space_with_invite refused a redemption.
MessageProperty
Property selector for crate::Message /get and /set.
OutboundEvent
One outbound event the Message/set, Chat/set, Chat/typing or PresenceStatus/set handler reports.
ReactionAction
The action of a OutboundEvent::ReactionUpdate (draft-atwood-jmap-chat-federation-00 §Peer/deliver reactionUpdate).
ReadPositionProperty
Property selector for crate::ReadPosition /get and /set.
RequiredPermissions
Result of required_permissions_for_op — typed alternative to a sentinel-string return value.
SpacePatchOp
A single Space/set update mutation operation.
SpaceProperty
Property selector for crate::Space /get and /set.

Traits§

ChatAccessPolicy
Chat and Message access gates: send, view, pins, broadcast mentions, slow mode, blocked contacts.
ChatBackend
Storage backend for JMAP Chat method handlers.
ChatEvents
Notifications from the handlers after a change: lifecycle callbacks and outbound events.
ChatMessageLifecycle
Message expiry and read-and-burn.
ChatModeration
Group Chat moderation: ChatBan create, update and destroy, and the kickMembers patch key.
ChatResolvers
Lookups outside chat storage: attachment blobs and FileNode attachments.
ChatRestrictions
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.
ChatSettings
Deployment settings and identity: limits, edit history, unread counts, the owner’s user id.
ChatSpaces
Space structure: invites, joins, member and role patches, and Space-wide settings.
ChatStore
Object writes and type support: the /set storage half of a chat backend.
DelegateChatAccessPolicy
Forward every ChatAccessPolicy method to chat_access_policy’s target.
DelegateChatEvents
Forward every ChatEvents method to chat_events’s target.
DelegateChatMessageLifecycle
Forward every ChatMessageLifecycle method to chat_message_lifecycle’s target.
DelegateChatModeration
Forward every ChatModeration method to chat_moderation’s target.
DelegateChatResolvers
Forward every ChatResolvers method to chat_resolvers’s target.
DelegateChatRestrictions
Forward every ChatRestrictions method to chat_restrictions’s target.
DelegateChatSettings
Forward every ChatSettings method to chat_settings’s target.
DelegateChatSpaces
Forward every ChatSpaces method to chat_spaces’s target.
DelegateChatStore
Forward every ChatStore method to chat_store’s target.
DelegateSpacePolicy
Forward every SpacePolicy method to space_policy’s target.
SpacePolicy
Space-scoped authorization gates: custom emoji, SpaceBan and SpaceInvite writes and reads.

Functions§

build_chat_message_push
Build the ChatMessagePush for one new inbound message under one subscription’s ChatPushConfig for account_id.
chat_state_change_for
The StateChange to push to sub for the types in changed, or None when nothing is left to send.
fit_chat_message_push
Fit push to a platform payload limit of max_bytes serialized JSON bytes, returning the payloads to deliver in order. A None element stands for one message whose entry cannot fit; the caller delivers a StateChange for the Message data type in its place.
handle_ban_changes
Handle a SpaceBan/changes method call (draft-atwood-jmap-chat-00 §SpaceBan).
handle_ban_get
Handle a SpaceBan/get method call (draft-atwood-jmap-chat-00 §SpaceBan).
handle_ban_set
Handle a SpaceBan/set method call (draft-atwood-jmap-chat-00 §SpaceBan).
handle_chat_ban_changes
Handle a ChatBan/changes method call (draft-atwood-jmap-chat-00 §ChatBan/changes: “Standard JMAP /changes.”).
handle_chat_ban_get
Handle a ChatBan/get method call (draft-atwood-jmap-chat-00 §ChatBan).
handle_chat_ban_set
Handle a ChatBan/set method call (draft-atwood-jmap-chat-00 §ChatBan).
handle_chat_changes
Handle a Chat/changes method call (draft-atwood-jmap-chat-00 §Chat).
handle_chat_get
Handle a Chat/get method call (draft-atwood-jmap-chat-00 §Chat).
handle_chat_query
Handle a Chat/query method call (draft-atwood-jmap-chat-00 §Chat).
handle_chat_query_changes
Handle a Chat/queryChanges method call (draft-atwood-jmap-chat-00 §Chat).
handle_chat_set
Handle a Chat/set method call (draft-atwood-jmap-chat-00 §Chat).
handle_chat_typing
Handle a Chat/typing method call (draft-atwood-jmap-chat-00 §Chat).
handle_contact_changes
Handle a ChatContact/changes method call (draft-atwood-jmap-chat-00 §ChatContact).
handle_contact_get
Handle a ChatContact/get method call (draft-atwood-jmap-chat-00 §ChatContact).
handle_contact_query
Handle a ChatContact/query method call (draft-atwood-jmap-chat-00 §ChatContact).
handle_contact_query_changes
Handle a ChatContact/queryChanges method call (draft-atwood-jmap-chat-00 §ChatContact).
handle_contact_set
Handle a ChatContact/set method call (draft-atwood-jmap-chat-00 §ChatContact).
handle_emoji_changes
Handle a CustomEmoji/changes method call (draft-atwood-jmap-chat-00 §CustomEmoji).
handle_emoji_get
Handle a CustomEmoji/get method call (draft-atwood-jmap-chat-00 §CustomEmoji).
handle_emoji_query
Handle a CustomEmoji/query method call (draft-atwood-jmap-chat-00 §CustomEmoji).
handle_emoji_query_changes
Handle a CustomEmoji/queryChanges method call (draft-atwood-jmap-chat-00 §CustomEmoji).
handle_emoji_set
Handle a CustomEmoji/set method call (draft-atwood-jmap-chat-00 §CustomEmoji).
handle_invite_changes
Handle a SpaceInvite/changes method call (draft-atwood-jmap-chat-00 §SpaceInvite).
handle_invite_get
Handle a SpaceInvite/get method call (draft-atwood-jmap-chat-00 §SpaceInvite).
handle_invite_set
Handle a SpaceInvite/set method call (draft-atwood-jmap-chat-00 §SpaceInvite).
handle_position_changes
Handle a ReadPosition/changes method call (draft-atwood-jmap-chat-00 §ReadPosition).
handle_position_get
Handle a ReadPosition/get method call (draft-atwood-jmap-chat-00 §ReadPosition).
handle_position_set
Handle a ReadPosition/set method call (draft-atwood-jmap-chat-00 §ReadPosition).
handle_presence_changes
Handle a PresenceStatus/changes method call (draft-atwood-jmap-chat-00 §PresenceStatus).
handle_presence_get
Handle a PresenceStatus/get method call (draft-atwood-jmap-chat-00 §PresenceStatus).
handle_presence_set
Handle a PresenceStatus/set method call (draft-atwood-jmap-chat-00 §PresenceStatus).
handle_space_changes
Handle a Space/changes method call (draft-atwood-jmap-chat-00 §Space).
handle_space_get
Handle a Space/get method call (draft-atwood-jmap-chat-00 §Space).
handle_space_join
Handle a Space/join method call (draft-atwood-jmap-chat-00 §Space).
handle_space_query
Handle a Space/query method call (draft-atwood-jmap-chat-00 §Space).
handle_space_query_changes
Handle a Space/queryChanges method call (draft-atwood-jmap-chat-00 §Space).
handle_space_set
Handle a Space/set method 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, for build_chat_message_push.
project_presence
The ChatPresenceEvent the owner of account_id may receive for event, or None if it must be dropped.
register_chat_conditional
Opt this crate’s registered Foo/set methods in to draft-ietf-jmap-conditional-02 (ifUnchangedBy and atomic; 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 /get and /set of the eight chat history types and /query, /queryChanges of those that have them (Chat, Message, Space, ChatContact, CustomEmoji), through Dispatcher::register_history_aware (docs/design/DECISIONS.md decision 1). Handlers that take no using in the plain registration are bound to the request’s here.
required_permissions_for_op
Returns the set of permissions required to apply this SpacePatchOp variant, 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 event may be delivered to the owner of account_id.
should_push
Whether a ChatMessagePush for the new inbound message msg goes to a subscription whose chatPush entry for account_id is cfg.
strip_unsupported_chat_push
Remove chatPush entries for accounts not in caps from a stored subscription’s extra map before it is returned.
sweep_expired
Apply every expiry deadline in account_id that has passed at now.
validate_chat_push
Check the chatPush property in a PushSubscription’s extra map before it is stored.
verify_did_binding
Checks that signing_key, the peerSigningKeys key that verified the request signature, is bound to did (draft-atwood-jmap-chat-did-00 §DID-Bound Verification steps 2 and 3).