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

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

AttachmentBlob
The stored blob behind an Attachment blobId, as reported by ChatBackend::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 ChatBackend::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 ChatBackend::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 ChatBackend::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 ChatBackend::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§

ChatBackend
Storage backend for JMAP Chat method handlers.

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_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_handlers
Register all JMAP Chat method handlers with dispatcher.
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).