// Message-level REST endpoints that sit alongside the native WS protocol. Recall goes through REST // (not a Tinode WS operation) -- ported from the old app's context-menu.jsx recallOwnMessage, which // calls this then hard-deletes the message from the local topic cache itself. import { imPost } from './client'; export interface RecallResult { topic: string; seq: number; status: string; version: number; updated_at: string; } /** * This backend tracks its own optimistic-concurrency `version` per message (distinct from Tinode's * `seq` -- confirmed in docs/IM-前后端对接文档.md:1248, `{"version":1,"reason":"..."}` request, * `{"version":2,...}` response), which is NOT delivered anywhere in the native WS `{data}` packet * this app reads messages from (confirmed live: a real message's WS payload carries no `version` * field at all). Since there's currently no source for a message's true current version, this * defaults to 1 (the version of any never-before-edited-or-recalled message, the overwhelmingly * common case) -- a real edit/recall race would surface as a version-conflict error from the * server, which the caller should treat as "refetch and retry," not silently ignore. */ export function recallMessage(topic: string, seq: number, version = 1, reason?: string) { return imPost(`/topics/${encodeURIComponent(topic)}/messages/${seq}/recall`, { version, reason }); }