@antzsoft/chat-core 1.4.2 → 1.4.3
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 +9 -3
- package/dist/index.cjs +10 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -5
- package/dist/index.d.ts +17 -5
- package/dist/index.js +9 -2
- package/dist/index.js.map +1 -1
- package/dist/internal.d.cts +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/{storage-BqygfDAK.d.cts → storage-D7GPq-Mm.d.cts} +3 -1
- package/dist/{storage-BqygfDAK.d.ts → storage-D7GPq-Mm.d.ts} +3 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -819,9 +819,10 @@ Forwarding creates an **independent copy** of a message in each target conversat
|
|
|
819
819
|
|
|
820
820
|
| Field / method | Type | Description |
|
|
821
821
|
|---|---|---|
|
|
822
|
-
| `messagesApi.forward(messageId, targetConversationIds)` | `Promise<ForwardResult[]>` | Forwards into up to `MAX_FORWARD_TARGETS` (5) conversations in one call — fewer if the source message is highly forwarded, see Limits below. |
|
|
822
|
+
| `messagesApi.forward(messageId, targetConversationIds, attachmentIds?)` | `Promise<ForwardResult[]>` | Forwards into up to `MAX_FORWARD_TARGETS` (5) conversations in one call — fewer if the source message is highly forwarded, see Limits below. Pass `attachmentIds` to forward only a subset of the source message's attachments (e.g. one image out of a multi-image message); omit it to forward the whole message unchanged. An ID not on the source message is ignored. |
|
|
823
823
|
| `Message.forwardedFrom` | `MessageForwardReference \| undefined` | Present on a message created via forwarding. |
|
|
824
824
|
| `MAX_FORWARD_TARGETS` | `number` | `5` — matches the server's normal-case cap. |
|
|
825
|
+
| `HIGHLY_FORWARDED_DEPTH_THRESHOLD` | `number` | `5` — matches the server's `forwardDepth` value that triggers BOTH the "Forwarded many times" label and the reduced fan-out cap. Use this for the label instead of hardcoding a number. |
|
|
825
826
|
|
|
826
827
|
**Limits:**
|
|
827
828
|
|
|
@@ -856,13 +857,18 @@ const failed = results.filter(r => !r.success);
|
|
|
856
857
|
if (failed.length > 0) {
|
|
857
858
|
console.warn(`Forward failed for ${failed.length}/${results.length} conversations`, failed);
|
|
858
859
|
}
|
|
860
|
+
|
|
861
|
+
// Forward only one attachment out of a multi-attachment message (e.g. image 2 of 3)
|
|
862
|
+
await messagesApi.forward(messageId, [convA], [message.content.attachments![1].id]);
|
|
859
863
|
```
|
|
860
864
|
|
|
861
|
-
**
|
|
865
|
+
**Where `forwardedFrom` is populated.** Every place a `Message` object is returned — `messagesApi.list`/`get`, the `new_message` socket event, `syncApi` (reconnect/resync), and REST list/search/starred/pinned — always includes `forwardedFrom` when present. **`conversation_updated`'s `lastMessage` field also includes it** (a conversation-list preview showing a forwarded message can render the "Forwarded" label without a separate message fetch). If `forwardDepth` ever reads as absent/`0` where you expected a value, that's a bug to report, not expected behavior — it should never be silently missing on any of these paths.
|
|
866
|
+
|
|
867
|
+
**Why only one hop of lineage is kept.** `forwardedFrom` always points at the *immediate* message being forwarded, never the ultimate original — matching WhatsApp: if you forward a message that was itself already forwarded, the new copy's `originalMessageId`/`originalSenderId` reference that intermediate copy, not the very first message in the chain. This is intentional: it keeps the true original author untraceable after more than one hop (privacy), while `forwardDepth` still accumulates across the whole chain. `forwardDepth` drives two things, both purely about slowing spread, never about blocking it: the "Forwarded many times" badge, and server-side, the reduced 1-target fan-out cap — both gated on the SAME threshold, `HIGHLY_FORWARDED_DEPTH_THRESHOLD` (currently `5`, exported from the package root). Use that constant for the label rather than hardcoding a number, so the two never drift apart again. There is no API to walk a message's full forward history — only the immediate parent is ever resolvable, and there is no forward-count ceiling that ever blocks forwarding outright.
|
|
862
868
|
|
|
863
869
|
**Attachments are never re-uploaded.** A forwarded attachment reuses the same underlying storage object as the source message — only the message row referencing it is new. This is transparent to SDK consumers; `forward()` handles it server-side.
|
|
864
870
|
|
|
865
|
-
**Rendering:** show a "Forwarded" (or "Forwarded many times" at `forwardDepth >=
|
|
871
|
+
**Rendering:** show a "Forwarded" (or "Forwarded many times" at `forwardDepth >= HIGHLY_FORWARDED_DEPTH_THRESHOLD`) label when `message.forwardedFrom` is present — do not render a sender name or content preview for it (unlike `replyTo`), since the message's own `content` already holds what was forwarded. The built-in `MessageItem` component in both `@antzsoft/chat-web-sdk` and `@antzsoft/chat-rn-sdk` already renders this label using the exported constant and exposes a "Forward" action in the message menu — no extra wiring needed if you're using the prebuilt UI.
|
|
866
872
|
|
|
867
873
|
#### Jump to first unread message
|
|
868
874
|
|
package/dist/index.cjs
CHANGED
|
@@ -108,6 +108,7 @@ __export(src_exports, {
|
|
|
108
108
|
AntzChatPermissionError: () => AntzChatPermissionError,
|
|
109
109
|
AntzChatServerError: () => AntzChatServerError,
|
|
110
110
|
AntzChatValidationError: () => AntzChatValidationError,
|
|
111
|
+
HIGHLY_FORWARDED_DEPTH_THRESHOLD: () => HIGHLY_FORWARDED_DEPTH_THRESHOLD,
|
|
111
112
|
MAX_FORWARD_TARGETS: () => MAX_FORWARD_TARGETS,
|
|
112
113
|
MENTION_ALL_ID: () => MENTION_ALL_ID,
|
|
113
114
|
appConfigApi: () => appConfigApi,
|
|
@@ -1014,6 +1015,7 @@ function resolveSystemMessageText(message, currentUserId) {
|
|
|
1014
1015
|
|
|
1015
1016
|
// src/api/messages.ts
|
|
1016
1017
|
var MAX_FORWARD_TARGETS = 5;
|
|
1018
|
+
var HIGHLY_FORWARDED_DEPTH_THRESHOLD = 5;
|
|
1017
1019
|
var messagesApi = {
|
|
1018
1020
|
async list(conversationId, params = {}) {
|
|
1019
1021
|
const { cursor, direction, ...rest } = params;
|
|
@@ -1113,11 +1115,16 @@ var messagesApi = {
|
|
|
1113
1115
|
* per call, also enforced server-side). Each target is independent — one failing
|
|
1114
1116
|
* (e.g. no longer a participant) does not block the others; check `success`/`error`
|
|
1115
1117
|
* per entry in the returned array.
|
|
1118
|
+
*
|
|
1119
|
+
* Pass `attachmentIds` to forward only a subset of the source message's attachments
|
|
1120
|
+
* (e.g. one image out of a multi-image message) — omit it to forward the whole
|
|
1121
|
+
* message, including all its attachments, unchanged. An ID not present on the
|
|
1122
|
+
* source message is ignored server-side.
|
|
1116
1123
|
*/
|
|
1117
|
-
async forward(messageId, targetConversationIds) {
|
|
1124
|
+
async forward(messageId, targetConversationIds, attachmentIds) {
|
|
1118
1125
|
const { data } = await getApiClient().post(
|
|
1119
1126
|
`/messages/${messageId}/forward`,
|
|
1120
|
-
{ targetConversationIds }
|
|
1127
|
+
{ targetConversationIds, ...attachmentIds ? { attachmentIds } : {} }
|
|
1121
1128
|
);
|
|
1122
1129
|
return data;
|
|
1123
1130
|
}
|
|
@@ -2113,6 +2120,7 @@ var AntzChatClient = class {
|
|
|
2113
2120
|
AntzChatPermissionError,
|
|
2114
2121
|
AntzChatServerError,
|
|
2115
2122
|
AntzChatValidationError,
|
|
2123
|
+
HIGHLY_FORWARDED_DEPTH_THRESHOLD,
|
|
2116
2124
|
MAX_FORWARD_TARGETS,
|
|
2117
2125
|
MENTION_ALL_ID,
|
|
2118
2126
|
appConfigApi,
|