@antzsoft/chat-core 1.1.2 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -5
- package/dist/index.cjs +93 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +37 -3
- package/dist/index.d.ts +37 -3
- package/dist/index.js +93 -25
- package/dist/index.js.map +1 -1
- package/docs/integration-guide.html +231 -13
- package/package.json +1 -1
|
@@ -155,7 +155,7 @@ section.sec>h2:hover{color:#fff}
|
|
|
155
155
|
|
|
156
156
|
<div class="section-label">What's New</div>
|
|
157
157
|
<ul>
|
|
158
|
-
<li><a href="#whats-new">v1.1.
|
|
158
|
+
<li><a href="#whats-new">v1.1.4 Release Notes</a></li>
|
|
159
159
|
</ul>
|
|
160
160
|
|
|
161
161
|
<div class="section-label">Getting Started</div>
|
|
@@ -242,11 +242,11 @@ section.sec>h2:hover{color:#fff}
|
|
|
242
242
|
<h2>What's New</h2>
|
|
243
243
|
<p style="color:var(--muted);font-size:13px;margin-bottom:20px">Version history and release notes. Click a version to expand.</p>
|
|
244
244
|
|
|
245
|
-
<!-- ── v1.1.
|
|
246
|
-
<div class="wn-version open" id="wn-
|
|
247
|
-
<div class="wn-header" onclick="toggleVersion('wn-
|
|
245
|
+
<!-- ── v1.1.4 (current) ── -->
|
|
246
|
+
<div class="wn-version open" id="wn-114">
|
|
247
|
+
<div class="wn-header" onclick="toggleVersion('wn-114')">
|
|
248
248
|
<div class="wn-title">
|
|
249
|
-
<span class="wn-ver">v1.1.
|
|
249
|
+
<span class="wn-ver">v1.1.4</span>
|
|
250
250
|
<span class="wn-badge current">Current</span>
|
|
251
251
|
<span class="wn-date">May 2026</span>
|
|
252
252
|
</div>
|
|
@@ -254,6 +254,179 @@ section.sec>h2:hover{color:#fff}
|
|
|
254
254
|
</div>
|
|
255
255
|
<div class="wn-body">
|
|
256
256
|
|
|
257
|
+
<div class="wn-item" id="wn-114-1">
|
|
258
|
+
<div class="wn-item-header" onclick="toggleItem('wn-114-1')">
|
|
259
|
+
<span class="wn-tag fix">Fix</span>
|
|
260
|
+
<span class="wn-item-title">Socket ack timeout eliminated for rapid or large messages</span>
|
|
261
|
+
<span class="wn-chevron-sm">▾</span>
|
|
262
|
+
</div>
|
|
263
|
+
<div class="wn-item-body">
|
|
264
|
+
<p>Sending many messages in quick succession — especially long text messages or in group chats with online recipients — could trigger a <code>Socket ack timeout: send_message</code> error on the client, even though the messages were delivered successfully. The root cause was that the server was performing delivery tracking, room broadcasts, and push notifications synchronously before returning the socket acknowledgement, which could exceed the 5-second ack window.</p>
|
|
265
|
+
<p>The server now returns the ack immediately after the message is written to the database. All subsequent work (delivery status tracking, <code>new_message</code> broadcast to recipients, push notifications) runs in the background. <strong>No behaviour change is visible to users</strong> — delivery ticks, message broadcasts, and push notifications all still fire; they just no longer block the ack.</p>
|
|
266
|
+
<p>No SDK or integration changes required. This fix is a server-side change paired with a client-side queue improvement (see below).</p>
|
|
267
|
+
</div>
|
|
268
|
+
</div>
|
|
269
|
+
|
|
270
|
+
<div class="wn-item" id="wn-114-2">
|
|
271
|
+
<div class="wn-item-header" onclick="toggleItem('wn-114-2')">
|
|
272
|
+
<span class="wn-tag fix">Fix</span>
|
|
273
|
+
<span class="wn-item-title">Per-conversation send queue — parallel sends across conversations</span>
|
|
274
|
+
<span class="wn-chevron-sm">▾</span>
|
|
275
|
+
</div>
|
|
276
|
+
<div class="wn-item-body">
|
|
277
|
+
<p>The SDK's internal <code>send_message</code> queue was previously shared across all conversations. This meant that sending messages in Conversation A would block outgoing messages in Conversation B until each ack completed, even though the two conversations are fully independent.</p>
|
|
278
|
+
<p>The queue is now keyed per <code>conversationId</code>. Messages within the same conversation are still serialised (guaranteeing order), but messages across different conversations are sent in parallel. The <code>QUEUE_MAX_SIZE</code> limit of 100 pending messages also now applies per conversation rather than globally.</p>
|
|
279
|
+
<p>No integration changes required. This is an internal SDK improvement in <code>@antzsoft/chat-core</code>.</p>
|
|
280
|
+
</div>
|
|
281
|
+
</div>
|
|
282
|
+
|
|
283
|
+
</div>
|
|
284
|
+
</div><!-- /.wn-version -->
|
|
285
|
+
|
|
286
|
+
<!-- ── v1.1.3 ── -->
|
|
287
|
+
<div class="wn-version" id="wn-113">
|
|
288
|
+
<div class="wn-header" onclick="toggleVersion('wn-113')">
|
|
289
|
+
<div class="wn-title">
|
|
290
|
+
<span class="wn-ver">v1.1.3</span>
|
|
291
|
+
<span class="wn-date">May 2026</span>
|
|
292
|
+
</div>
|
|
293
|
+
<span class="wn-chevron">▾</span>
|
|
294
|
+
</div>
|
|
295
|
+
<div class="wn-body">
|
|
296
|
+
|
|
297
|
+
<div class="wn-item" id="wn-113-1">
|
|
298
|
+
<div class="wn-item-header" onclick="toggleItem('wn-113-1')">
|
|
299
|
+
<span class="wn-tag new">New</span>
|
|
300
|
+
<span class="wn-item-title">usersApi.updateProfile() — self-user profile update</span>
|
|
301
|
+
<span class="wn-chevron-sm">▾</span>
|
|
302
|
+
</div>
|
|
303
|
+
<div class="wn-item-body">
|
|
304
|
+
<p>The self user can now update their own profile (name, email, phone) instantly without waiting for the 2-hour background sync cycle.</p>
|
|
305
|
+
<pre><code><span class="kw">await</span> usersApi.<span class="fn">updateProfile</span>({ firstName: <span class="str">'Jane'</span>, lastName: <span class="str">'Smith'</span>, email: <span class="str">'jane@example.com'</span> });</code></pre>
|
|
306
|
+
<p><strong>Admin-updated fields (firstName, lastName) via external identity provider:</strong> the chat module will reflect those changes either on the next 2-hour sync or the next time the app initialises the chat client. Webhook-based instant sync will be introduced in a future release.</p>
|
|
307
|
+
<p class="wn-ref">→ <a href="#users-api">Users API</a> for the full reference</p>
|
|
308
|
+
</div>
|
|
309
|
+
</div>
|
|
310
|
+
|
|
311
|
+
<div class="wn-item" id="wn-113-2">
|
|
312
|
+
<div class="wn-item-header" onclick="toggleItem('wn-113-2')">
|
|
313
|
+
<span class="wn-tag new">New</span>
|
|
314
|
+
<span class="wn-item-title">Group icon — remove support</span>
|
|
315
|
+
<span class="wn-chevron-sm">▾</span>
|
|
316
|
+
</div>
|
|
317
|
+
<div class="wn-item-body">
|
|
318
|
+
<p>Admins can now remove a group icon in addition to setting or replacing one. Tapping the new <strong>✕</strong> button (top-right of the group avatar in Group Info) clears the icon immediately — the asset is deleted from storage and the conversation reverts to its initials avatar.</p>
|
|
319
|
+
<pre><code><span class="cm">// Remove icon — admin only</span>
|
|
320
|
+
<span class="kw">const</span> updated = <span class="kw">await</span> conversationsApi.<span class="fn">removeIcon</span>(groupId);
|
|
321
|
+
<span class="cm">// updated.iconUrl === undefined</span></code></pre>
|
|
322
|
+
<p>Like upload, remove is admin-only; non-admins receive <code>403 Forbidden</code>. No icon is ever left orphaned in storage.</p>
|
|
323
|
+
<p class="wn-ref">→ <a href="#step-convs">Step 6 — Conversations</a> (group icon section) for the full pipeline</p>
|
|
324
|
+
</div>
|
|
325
|
+
</div>
|
|
326
|
+
|
|
327
|
+
<div class="wn-item" id="wn-113-3">
|
|
328
|
+
<div class="wn-item-header" onclick="toggleItem('wn-113-3')">
|
|
329
|
+
<span class="wn-tag new">New</span>
|
|
330
|
+
<span class="wn-item-title">Leave / Delete / Exit — WhatsApp-style behavior</span>
|
|
331
|
+
<span class="wn-chevron-sm">▾</span>
|
|
332
|
+
</div>
|
|
333
|
+
<div class="wn-item-body">
|
|
334
|
+
<p><code>leave(id)</code> exits a group but keeps it in the list (read-only). <code>leave(id, true)</code> exits and removes it atomically. <code>delete(id)</code> hides any conversation from the caller's list — no longer admin-only, works for DMs ("Delete Chat") and already-exited groups ("Delete Group"). When the last admin exits, the server auto-promotes the longest-standing member instead of returning <code>400</code>.</p>
|
|
335
|
+
<p class="wn-ref">→ <a href="#step-convs">Step 6 — Conversations</a> for code examples</p>
|
|
336
|
+
</div>
|
|
337
|
+
</div>
|
|
338
|
+
|
|
339
|
+
<div class="wn-item" id="wn-113-4">
|
|
340
|
+
<div class="wn-item-header" onclick="toggleItem('wn-113-4')">
|
|
341
|
+
<span class="wn-tag new">New</span>
|
|
342
|
+
<span class="wn-item-title">Message visibility windows — gap messages hidden after re-add</span>
|
|
343
|
+
<span class="wn-chevron-sm">▾</span>
|
|
344
|
+
</div>
|
|
345
|
+
<div class="wn-item-body">
|
|
346
|
+
<p>Messages sent while a user was not a member (gap periods) are now always hidden. Re-adding after a plain exit preserves prior history; re-adding after "Exit and Delete" shows only messages from the re-add point. DM "Delete Chat" also resets the window — when the other party messages again, only new messages are visible. No client changes required.</p>
|
|
347
|
+
</div>
|
|
348
|
+
</div>
|
|
349
|
+
|
|
350
|
+
<div class="wn-item" id="wn-113-5">
|
|
351
|
+
<div class="wn-item-header" onclick="toggleItem('wn-113-5')">
|
|
352
|
+
<span class="wn-tag new">New</span>
|
|
353
|
+
<span class="wn-item-title">useConversations() — leaveGroup, leaveAndDeleteGroup, deleteConversation</span>
|
|
354
|
+
<span class="wn-chevron-sm">▾</span>
|
|
355
|
+
</div>
|
|
356
|
+
<div class="wn-item-body">
|
|
357
|
+
<p>Three new mutations added to <code>useConversations()</code> in both web and RN SDKs: <code>leaveGroup</code>, <code>leaveAndDeleteGroup</code>, and <code>deleteConversation</code> (RN) / <code>deleteGroup</code> (web). Cache is updated optimistically — no manual invalidation needed.</p>
|
|
358
|
+
</div>
|
|
359
|
+
</div>
|
|
360
|
+
|
|
361
|
+
</div>
|
|
362
|
+
</div><!-- /.wn-version -->
|
|
363
|
+
|
|
364
|
+
<!-- ── v1.1.2 ── -->
|
|
365
|
+
<div class="wn-version" id="wn-112">
|
|
366
|
+
<div class="wn-header" onclick="toggleVersion('wn-112')">
|
|
367
|
+
<div class="wn-title">
|
|
368
|
+
<span class="wn-ver">v1.1.2</span>
|
|
369
|
+
<span class="wn-date">May 2026</span>
|
|
370
|
+
</div>
|
|
371
|
+
<span class="wn-chevron">▾</span>
|
|
372
|
+
</div>
|
|
373
|
+
<div class="wn-body">
|
|
374
|
+
|
|
375
|
+
<div class="wn-item" id="wn-112-0a">
|
|
376
|
+
<div class="wn-item-header" onclick="toggleItem('wn-112-0a')">
|
|
377
|
+
<span class="wn-tag new">New</span>
|
|
378
|
+
<span class="wn-item-title">usersApi.updateProfile() — immediate profile update</span>
|
|
379
|
+
<span class="wn-chevron-sm">▾</span>
|
|
380
|
+
</div>
|
|
381
|
+
<div class="wn-item-body">
|
|
382
|
+
<p>A new <code>usersApi.updateProfile(payload)</code> method lets the host app push profile field changes to the chat server immediately — without waiting for the next background sync cycle.</p>
|
|
383
|
+
<p>This is especially useful in <strong>non-builtin (external/SSO) modes</strong>: when the user updates their name or email in the main identity provider, the host app can call <code>updateProfile()</code> so the chat UI reflects the change right away rather than waiting up to 2 hours for the next cron sync.</p>
|
|
384
|
+
<pre><code><span class="kw">import</span> { usersApi } <span class="kw">from</span> <span class="str">'@antzsoft/chat-core'</span>;
|
|
385
|
+
|
|
386
|
+
<span class="kw">await</span> usersApi.<span class="fn">updateProfile</span>({
|
|
387
|
+
firstName: <span class="str">'Jane'</span>,
|
|
388
|
+
lastName: <span class="str">'Smith'</span>,
|
|
389
|
+
email: <span class="str">'jane@example.com'</span>,
|
|
390
|
+
displayName: <span class="str">'Jane S.'</span>, <span class="cm">// optional</span>
|
|
391
|
+
phone: <span class="str">'+919900000000'</span>,
|
|
392
|
+
});</code></pre>
|
|
393
|
+
<table>
|
|
394
|
+
<tr><th>Field</th><th>Builtin</th><th>Non-builtin</th></tr>
|
|
395
|
+
<tr><td><code>firstName</code>, <code>lastName</code>, <code>email</code></td><td>Written directly</td><td>Written immediately; may be overwritten on next sync if user-service returns different values</td></tr>
|
|
396
|
+
<tr><td><code>displayName</code>, <code>phone</code></td><td>Written directly</td><td>Written immediately</td></tr>
|
|
397
|
+
<tr><td><code>username</code>, <code>status</code></td><td colspan="2">Not allowed</td></tr>
|
|
398
|
+
</table>
|
|
399
|
+
<p><strong>Uniqueness:</strong> <code>email</code> and <code>phone</code> must each be unique within the tenant. A <code>409 Conflict</code> is returned if another user already holds the same value.</p>
|
|
400
|
+
<p class="wn-ref">→ <a href="#users-api">Users API</a> for the full reference</p>
|
|
401
|
+
</div>
|
|
402
|
+
</div>
|
|
403
|
+
|
|
404
|
+
<div class="wn-item" id="wn-112-0b">
|
|
405
|
+
<div class="wn-item-header" onclick="toggleItem('wn-112-0b')">
|
|
406
|
+
<span class="wn-tag new">New</span>
|
|
407
|
+
<span class="wn-item-title">On-connect per-user profile sync</span>
|
|
408
|
+
<span class="wn-chevron-sm">▾</span>
|
|
409
|
+
</div>
|
|
410
|
+
<div class="wn-item-body">
|
|
411
|
+
<p>In non-builtin modes, <code>AntzChatClient.connect()</code> now triggers a fire-and-forget background sync of the current user's profile from the upstream user-service if the shadow record hasn't been synced in the last 6 hours.</p>
|
|
412
|
+
<p>Previously only the 2-hour bulk cron kept shadow records up to date. Now profile fields (<code>firstName</code>, <code>lastName</code>, <code>displayName</code>, <code>email</code>, <code>username</code>, <code>phone</code>, <code>status</code>) are refreshed on every fresh SDK initialisation, providing near-immediate consistency for users who reconnect after a period of inactivity.</p>
|
|
413
|
+
<p><strong>No client action required.</strong> This is handled automatically inside <code>connect()</code>.</p>
|
|
414
|
+
</div>
|
|
415
|
+
</div>
|
|
416
|
+
|
|
417
|
+
<div class="wn-item" id="wn-112-0c">
|
|
418
|
+
<div class="wn-item-header" onclick="toggleItem('wn-112-0c')">
|
|
419
|
+
<span class="wn-tag new">New</span>
|
|
420
|
+
<span class="wn-item-title">Phone number uniqueness enforced per tenant</span>
|
|
421
|
+
<span class="wn-chevron-sm">▾</span>
|
|
422
|
+
</div>
|
|
423
|
+
<div class="wn-item-body">
|
|
424
|
+
<p><code>phone</code> is now unique within a tenant — the same phone number cannot be registered to two different users under the same tenant. A <code>409 Conflict</code> is returned on registration or profile update if the number is already in use.</p>
|
|
425
|
+
<p>Same-phone across different tenants is still allowed (a user can have the same phone in tenant A and tenant B).</p>
|
|
426
|
+
<p><strong>No client action required</strong> for existing data. New uniqueness is enforced at write time only.</p>
|
|
427
|
+
</div>
|
|
428
|
+
</div>
|
|
429
|
+
|
|
257
430
|
<div class="wn-item" id="wn-112-1">
|
|
258
431
|
<div class="wn-item-header" onclick="toggleItem('wn-112-1')">
|
|
259
432
|
<span class="wn-tag new">New</span>
|
|
@@ -942,17 +1115,21 @@ section.sec>h2:hover{color:#fff}
|
|
|
942
1115
|
<div class="wn-item" id="wn-106-7">
|
|
943
1116
|
<div class="wn-item-header" onclick="toggleItem('wn-106-7')">
|
|
944
1117
|
<span class="wn-tag new">New</span>
|
|
945
|
-
<span class="wn-item-title">Group icon — create &
|
|
1118
|
+
<span class="wn-item-title">Group icon — create, update & remove</span>
|
|
946
1119
|
<span class="wn-chevron-sm">▾</span>
|
|
947
1120
|
</div>
|
|
948
1121
|
<div class="wn-item-body">
|
|
949
|
-
<p>Group conversations now support a custom icon. Admins can set or
|
|
1122
|
+
<p>Group conversations now support a custom icon. Admins can set, replace, or remove it at any time. The icon is stored server-side and a fresh signed URL is returned on every conversation response.</p>
|
|
950
1123
|
<pre><code><span class="cm">// Upload icon — admin only</span>
|
|
951
1124
|
<span class="kw">const</span> updated = <span class="kw">await</span> client.<span class="fn">uploadIcon</span>(groupId, {
|
|
952
1125
|
<span class="at">uri</span>: file.uri, <span class="at">name</span>: <span class="str">'icon.jpg'</span>, <span class="at">type</span>: <span class="str">'image/jpeg'</span>, <span class="at">size</span>: file.size,
|
|
953
1126
|
});
|
|
954
|
-
<span class="cm">// updated.iconUrl → fresh signed URL</span
|
|
955
|
-
|
|
1127
|
+
<span class="cm">// updated.iconUrl → fresh signed URL</span>
|
|
1128
|
+
|
|
1129
|
+
<span class="cm">// Remove icon — admin only</span>
|
|
1130
|
+
<span class="kw">const</span> noIcon = <span class="kw">await</span> conversationsApi.<span class="fn">removeIcon</span>(groupId);
|
|
1131
|
+
<span class="cm">// noIcon.iconUrl === undefined</span></code></pre>
|
|
1132
|
+
<p>Non-admins receive <code>403 Forbidden</code> on both operations. The URL is never stored in the DB — regenerated from <code>iconMeta.storageKey</code> on every response. Replacing or removing an icon automatically deletes the previous asset from storage.</p>
|
|
956
1133
|
<p class="wn-ref">→ <a href="#step-convs">Step 6 — Conversations</a> (group icon section) for the full upload pipeline</p>
|
|
957
1134
|
</div>
|
|
958
1135
|
</div>
|
|
@@ -1697,6 +1874,17 @@ chatClient.<span class="fn">disconnect</span>();
|
|
|
1697
1874
|
<span class="cm">// Search users by name / username / email</span>
|
|
1698
1875
|
<span class="kw">const</span> { data: results } = <span class="kw">await</span> usersApi.<span class="fn">list</span>({ <span class="at">query</span>: <span class="str">'john'</span> });
|
|
1699
1876
|
|
|
1877
|
+
<span class="cm">// Update current user's profile — works in both builtin and non-builtin modes.</span>
|
|
1878
|
+
<span class="cm">// In non-builtin modes use this to push a change immediately without waiting</span>
|
|
1879
|
+
<span class="cm">// for the next 2-hour background sync from the upstream user-service.</span>
|
|
1880
|
+
<span class="kw">await</span> usersApi.<span class="fn">updateProfile</span>({
|
|
1881
|
+
firstName: <span class="str">'Jane'</span>,
|
|
1882
|
+
lastName: <span class="str">'Smith'</span>,
|
|
1883
|
+
email: <span class="str">'jane@example.com'</span>, <span class="cm">// 409 if taken by another user in this tenant</span>
|
|
1884
|
+
displayName: <span class="str">'Jane S.'</span>,
|
|
1885
|
+
phone: <span class="str">'+919900000000'</span>, <span class="cm">// 409 if taken by another user in this tenant</span>
|
|
1886
|
+
});
|
|
1887
|
+
|
|
1700
1888
|
<span class="cm">// Create DM — returns existing if already exists</span>
|
|
1701
1889
|
<span class="kw">const</span> dm = <span class="kw">await</span> conversationsApi.<span class="fn">createDirect</span>({ <span class="at">userId</span>: <span class="str">'target-user-id'</span> });
|
|
1702
1890
|
|
|
@@ -1735,8 +1923,15 @@ chatClient.<span class="fn">disconnect</span>();
|
|
|
1735
1923
|
<span class="cm">// - iconMeta = { storageKey, provider, bucket, mimeType, size } embedded in conversation doc</span>
|
|
1736
1924
|
<span class="cm">// - Non-admins get 403 Forbidden at server level</span>
|
|
1737
1925
|
|
|
1926
|
+
<span class="cm">// Remove the group icon (admin only)</span>
|
|
1927
|
+
<span class="cm">// Deletes asset from storage + clears iconMeta. Returns conversation with iconUrl: undefined.</span>
|
|
1928
|
+
<span class="kw">const</span> noIcon = <span class="kw">await</span> conversationsApi.<span class="fn">removeIcon</span>(group.id);
|
|
1929
|
+
<span class="cm">// → DELETE /conversations/:id/icon</span>
|
|
1930
|
+
<span class="cm">// Server: validateAdmin() → deleteByKey(iconMeta.storageKey) → $unset iconMeta</span>
|
|
1931
|
+
<span class="cm">// noIcon.iconUrl === undefined</span>
|
|
1932
|
+
|
|
1738
1933
|
<span class="cm">// Web/RN SDK components (GroupInfoPanel, NewChatModal, ChatHeader) handle this automatically.</span>
|
|
1739
|
-
<span class="cm">// Camera button shown only to admins. No code needed in your app.</span>
|
|
1934
|
+
<span class="cm">// Camera button + remove (✕) button shown only to admins. No code needed in your app.</span>
|
|
1740
1935
|
|
|
1741
1936
|
<span class="cm">// Participants</span>
|
|
1742
1937
|
<span class="kw">const</span> members = <span class="kw">await</span> conversationsApi.<span class="fn">getMembers</span>(conversationId);
|
|
@@ -1745,11 +1940,34 @@ chatClient.<span class="fn">disconnect</span>();
|
|
|
1745
1940
|
<span class="kw">await</span> conversationsApi.<span class="fn">removeParticipant</span>(conversationId, <span class="str">'user-2'</span>);
|
|
1746
1941
|
<span class="kw">await</span> conversationsApi.<span class="fn">updateParticipantRole</span>(conversationId, <span class="str">'user-1'</span>, <span class="str">'admin'</span>);
|
|
1747
1942
|
|
|
1748
|
-
<span class="cm">// Pin · Mute
|
|
1943
|
+
<span class="cm">// Pin · Mute</span>
|
|
1749
1944
|
<span class="kw">await</span> conversationsApi.<span class="fn">pin</span>(conversationId); <span class="cm">// 400 if already at 5 pinned</span>
|
|
1750
1945
|
<span class="kw">await</span> conversationsApi.<span class="fn">mute</span>(conversationId, <span class="str">'2025-12-31T23:59:59Z'</span>); <span class="cm">// omit date = indefinite</span>
|
|
1751
|
-
|
|
1752
|
-
<span class="
|
|
1946
|
+
|
|
1947
|
+
<span class="cm">// ── 1:1 Chat ──────────────────────────────────────────────────────────────────</span>
|
|
1948
|
+
<span class="cm">// "Delete Chat" — hides from caller's list only. Other participant unaffected.</span>
|
|
1949
|
+
<span class="cm">// If the other person messages again the chat reappears, showing only new messages.</span>
|
|
1950
|
+
<span class="kw">await</span> conversationsApi.<span class="fn">delete</span>(dmConversationId);
|
|
1951
|
+
|
|
1952
|
+
<span class="cm">// ── Group Chat ─────────────────────────────────────────────────────────────────</span>
|
|
1953
|
+
<span class="cm">// "Exit Group" — leave but keep in list (read-only). Auto-promotes if last admin.</span>
|
|
1954
|
+
<span class="kw">await</span> conversationsApi.<span class="fn">leave</span>(groupId);
|
|
1955
|
+
|
|
1956
|
+
<span class="cm">// "Exit and Delete" — leave + remove from list atomically.</span>
|
|
1957
|
+
<span class="kw">await</span> conversationsApi.<span class="fn">leave</span>(groupId, <span class="kw">true</span>);
|
|
1958
|
+
|
|
1959
|
+
<span class="cm">// "Delete Group" — hide an already-exited group from the list. Any participant.</span>
|
|
1960
|
+
<span class="kw">await</span> conversationsApi.<span class="fn">delete</span>(groupId);</code></pre>
|
|
1961
|
+
|
|
1962
|
+
<div class="callout info">
|
|
1963
|
+
<strong>Leave / Delete semantics</strong>
|
|
1964
|
+
<ul style="margin:8px 0 0;padding-left:20px;line-height:1.7">
|
|
1965
|
+
<li><strong>Exit Group</strong> — <code>leave(id)</code>. Caller becomes inactive, stays in list read-only. If the caller is the only admin, the server auto-promotes the longest-standing active member before completing the exit.</li>
|
|
1966
|
+
<li><strong>Exit and Delete</strong> — <code>leave(id, true)</code>. Atomic: exit + hide from list in one server write. No race window.</li>
|
|
1967
|
+
<li><strong>Delete Group</strong> (after exit) — <code>delete(id)</code>. Caller must already be inactive. Hides from their list only. Any participant, no admin role required.</li>
|
|
1968
|
+
<li><strong>Delete Chat</strong> (1:1) — <code>delete(id)</code>. Hides from caller's list. DMs have no admin concept. When the other participant messages again, the chat reappears for the caller with only new messages visible.</li>
|
|
1969
|
+
</ul>
|
|
1970
|
+
</div>
|
|
1753
1971
|
|
|
1754
1972
|
<div class="callout info">
|
|
1755
1973
|
<strong>Pin limit — max 5</strong> — The server enforces a maximum of 5 pinned conversations per user. Attempting to pin a 6th returns <code>400 Bad Request</code>. Gate your UI before calling the API:
|
package/package.json
CHANGED