@pmate/chat-sdk 0.12.0-next.19 → 0.12.0-next.20
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.
|
@@ -28,13 +28,15 @@ function decodeIncoming(message, scope) {
|
|
|
28
28
|
if (message.opcode !== 1 || !message.body || typeof message.body !== "object")
|
|
29
29
|
return;
|
|
30
30
|
const body = message.body;
|
|
31
|
-
|
|
31
|
+
const invitation = body.kind === "contact" && ["friendRequest", "requestFriend"].includes(String(body.action));
|
|
32
|
+
if ((!invitation && body.kind !== "message") || (invitation ? body.payload?.appId : body.content?.appId) !== scope.appId || chatTeamId(body) !== scope.teamId)
|
|
32
33
|
return;
|
|
33
|
-
|
|
34
|
+
const threadKind = invitation ? "dm" : body.threadKind;
|
|
35
|
+
if (threadKind !== "dm" && threadKind !== "group")
|
|
34
36
|
return;
|
|
35
|
-
if (
|
|
37
|
+
if (threadKind === "dm" && message.from !== scope.profileId && message.to !== scope.profileId)
|
|
36
38
|
return;
|
|
37
|
-
const threadId =
|
|
38
|
-
return { appId: scope.appId, teamId: scope.teamId, threadId, threadKind
|
|
39
|
+
const threadId = threadKind === "dm" ? dmThreadId(scope.appId, message.from, message.to, scope.teamId) : groupThreadId(scope.appId, message.to, scope.teamId);
|
|
40
|
+
return { appId: scope.appId, teamId: scope.teamId, threadId, threadKind, messageId: message.hash, id: message.hash,
|
|
39
41
|
timestamp: message.t, serverCreatedAt: message.t, clientCreatedAt: message.t, from: message.from, to: message.to, body: message.body, recipients: message.recipients };
|
|
40
42
|
}
|
package/package.json
CHANGED