Messaging
Class: Messaging
Defined in: api/messaging/manager.ts:67
Messaging manager — inbox enumeration + live decrypt + presence.
See
Methods
fetchEncryptedMessages()
fetchEncryptedMessages(conversations: ConversationSummary[], selfUserId?: string): Promise<RawEncryptedMessage[]>;Defined in: api/messaging/manager.ts:296
Fetch raw encrypted message envelopes for the given conversations
via BatchDeltaSync.
Parameters
| Parameter | Type |
|---|---|
conversations | ConversationSummary[] |
selfUserId? | string |
Returns
Promise<RawEncryptedMessage[]>
listConversations()
listConversations(selfUserId?: string): Promise<ConversationSummary[]>;Defined in: api/messaging/manager.ts:287
Fetch the user's full conversation list via SyncConversations.
Returns one entry per conversation — the same set the SPA shows on
its left panel.
Parameters
| Parameter | Type | Description |
|---|---|---|
selfUserId? | string | Optional override for the calling user's UUID. When omitted, resolved from the chat-bundle's auth slice. |
Returns
Promise<ConversationSummary[]>
on()
on<K>(
event: K,
cb: MessagingEvents[K],
opts?: {
signal?: AbortSignal;
}): Subscription;Defined in: api/messaging/manager.ts:177
Subscribe to a messaging event. First subscription triggers the bundle session bring-up (~3s cold; subsequent subscriptions are free).
Type Parameters
| Type Parameter |
|---|
K extends keyof MessagingEvents |
Parameters
| Parameter | Type | Description |
|---|---|---|
event | K | One of MessagingEvents. |
cb | MessagingEvents[K] | Callback invoked with the event payload. |
opts? | { signal?: AbortSignal; } | Optional signal; aborting it unsubscribes. |
opts.signal? | AbortSignal | - |
Returns
Example
client.messaging.on("message", (msg) => {
const text = new TextDecoder().decode(msg.content);
console.log(`${msg.isSender ? "->" : "<-"} ${text}`);
});sendImage()
sendImage(
convId: string,
image: Uint8Array,
opts?: {
caption?: string;
}): Promise<string>;Defined in: api/messaging/manager.ts:253
Send a persistent image attachment into a conversation. Image stays in chat history (not ephemeral).
Parameters
| Parameter | Type | Description |
|---|---|---|
convId | string | Hyphenated conversation UUID. |
image | Uint8Array | Raw image bytes (PNG / JPEG / WebP). |
opts? | { caption?: string; } | Optional caption shown beside the image. |
opts.caption? | string | - |
Returns
Promise<string>
sendSnap()
sendSnap(
convId: string,
media: Uint8Array,
opts?: {
timer?: number;
}): Promise<string>;Defined in: api/messaging/manager.ts:269
Send a disappearing snap to a conversation (destination kind 122).
Default is view-once; pass { timer: 5 } to override.
Parameters
| Parameter | Type | Description |
|---|---|---|
convId | string | Hyphenated conversation UUID. |
media | Uint8Array | Raw media bytes. |
opts? | { timer?: number; } | Optional timer (display duration in seconds). |
opts.timer? | number | - |
Returns
Promise<string>
sendText()
sendText(convId: string, text: string): Promise<string>;Defined in: api/messaging/manager.ts:241
Send a plain text DM into a conversation. Awaits messaging-session bring-up before dispatching (so the first send pays the ~3s cold cost; subsequent sends are free).
Parameters
| Parameter | Type | Description |
|---|---|---|
convId | string | Hyphenated conversation UUID (from listConversations). |
text | string | UTF-8 message body. |
Returns
Promise<string>
The message ID Snap assigned (or a locally-generated client UUID).
setRead()
setRead(convId: string, messageId: string | bigint): Promise<void>;Defined in: api/messaging/manager.ts:226
Mark messageId in convId as read (fires a read-receipt frame).
Resolves once the bundle has dispatched the notification.
Parameters
| Parameter | Type | Description |
|---|---|---|
convId | string | Hyphenated conversation UUID. |
messageId | string | bigint | Server message id (bigint) or its decimal-string form. |
Returns
Promise<void>
setTyping()
setTyping(convId: string, durationMs: number): Promise<void>;Defined in: api/messaging/manager.ts:206
Show typing indicator in convId for durationMs, then auto-clear.
Wires through the bundle's own typing helper — module 56639 export
zM (sendTypingNotification wrapper) → convMgr.sendTypingNotification(convRef, kind, cb).
The bundle's TypingStateMachine on the recipient side starts a
~3s idle timer on every received pulse and drops the indicator if
no follow-up arrives. To hold the indicator across windows longer
than 3s we re-pulse every 2.5s. Auto-clear is implicit:
returning from this function (or aborting / rejecting) stops the
pulse loop, and the recipient's idle timer takes the state to
"none" within ~3s — no peer ever sees a stale typing dot.
Parameters
| Parameter | Type |
|---|---|
convId | string |
durationMs | number |
Returns
Promise<void>
Example
await messaging.setTyping(convId, 1500);
await messaging.sendText(convId, "hello");setViewing()
setViewing(convId: string, durationMs: number): Promise<void>;Defined in: api/messaging/manager.ts:214
Mark convId as actively viewed (chat-open / focused) for durationMs,
then auto-clear with an exitConversation pulse.
Parameters
| Parameter | Type |
|---|---|
convId | string |
durationMs | number |
Returns
Promise<void>