@spectrum-ts/imessage 9.3.0 → 9.3.1
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/dist/index.js +31 -30
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1701,6 +1701,30 @@ const unsendMessage$1 = async (remote, spaceId, msgId) => {
|
|
|
1701
1701
|
await remote.messages.unsend(toChatGuid(spaceId), toMessageGuid(childRef?.parentGuid ?? msgId), childRef ? { partIndex: childRef.partIndex } : void 0);
|
|
1702
1702
|
};
|
|
1703
1703
|
//#endregion
|
|
1704
|
+
//#region src/remote/client.ts
|
|
1705
|
+
const isSharedMode = (clients) => clients.length === 1 && clients[0]?.phone === "shared";
|
|
1706
|
+
const availablePhones = (clients) => clients.map((c) => c.phone);
|
|
1707
|
+
const clientForPhone = (clients, phone) => {
|
|
1708
|
+
if (isSharedMode(clients)) {
|
|
1709
|
+
const entry = clients[0];
|
|
1710
|
+
if (!entry) throw new Error("No iMessage clients configured");
|
|
1711
|
+
return entry.client;
|
|
1712
|
+
}
|
|
1713
|
+
const entry = clients.find((c) => c.phone === phone);
|
|
1714
|
+
if (!entry) {
|
|
1715
|
+
const list = availablePhones(clients).join(", ") || "<none>";
|
|
1716
|
+
throw new Error(`No iMessage client serves phone ${phone}. Available: ${list}`);
|
|
1717
|
+
}
|
|
1718
|
+
return entry.client;
|
|
1719
|
+
};
|
|
1720
|
+
const randomPhone = (clients) => {
|
|
1721
|
+
if (clients.length === 0) throw new Error("No iMessage phones configured for this account");
|
|
1722
|
+
if (isSharedMode(clients)) return SHARED_PHONE;
|
|
1723
|
+
const entry = clients[Math.floor(Math.random() * clients.length)];
|
|
1724
|
+
if (!entry) throw new Error("No iMessage phones configured for this account");
|
|
1725
|
+
return entry.phone;
|
|
1726
|
+
};
|
|
1727
|
+
//#endregion
|
|
1704
1728
|
//#region src/remote/contact-share.ts
|
|
1705
1729
|
const log$2 = createLogger("spectrum.imessage.contact");
|
|
1706
1730
|
const SHARE_TTL_MS = 1440 * 60 * 1e3;
|
|
@@ -2103,18 +2127,19 @@ const groupStream = (client, phone, recover) => resumableOrderedStream({
|
|
|
2103
2127
|
processMissed: (event) => event.type === "catchup.complete" ? Promise.resolve(toCatchUpCompleteItem(event)) : toGroupItem(client, event, phone, String(event.sequence)),
|
|
2104
2128
|
subscribeLive: (cursor) => withClose(client.groups.subscribeEvents(), cursor)
|
|
2105
2129
|
});
|
|
2106
|
-
const clientStream = (client, pollCache, phone, onInbound, recover) =>
|
|
2107
|
-
messageStream(client, phone, onInbound, recover),
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2130
|
+
const clientStream = (client, pollCache, phone, includeGroupEvents, onInbound, recover) => {
|
|
2131
|
+
const streams = [messageStream(client, phone, onInbound, recover), pollStream(client, pollCache, phone, recover)];
|
|
2132
|
+
if (includeGroupEvents) streams.push(groupStream(client, phone, recover));
|
|
2133
|
+
return mergeStreams(streams);
|
|
2134
|
+
};
|
|
2111
2135
|
const messages$1 = (clients, projectConfig) => {
|
|
2112
2136
|
const pollCache = getPollCache(clients);
|
|
2113
2137
|
const shareEnabled = projectConfig?.profile?.imessageSynced === true;
|
|
2114
2138
|
const recover = getCloudRecover(clients);
|
|
2139
|
+
const includeGroupEvents = !isSharedMode(clients);
|
|
2115
2140
|
return mergeStreams(clients.map((entry) => {
|
|
2116
2141
|
const tracker = shareEnabled ? getContactShareTracker(entry.client) : void 0;
|
|
2117
|
-
return clientStream(entry.client, pollCache, entry.phone, tracker ? (chatGuid) => tracker.maybeShare(chatGuid) : void 0, recover);
|
|
2142
|
+
return clientStream(entry.client, pollCache, entry.phone, includeGroupEvents, tracker ? (chatGuid) => tracker.maybeShare(chatGuid) : void 0, recover);
|
|
2118
2143
|
}));
|
|
2119
2144
|
};
|
|
2120
2145
|
//#endregion
|
|
@@ -2234,30 +2259,6 @@ const toSpectrumMiniApp = (url, layout, live) => asCustomizedMiniApp({
|
|
|
2234
2259
|
...live === void 0 ? {} : { live }
|
|
2235
2260
|
});
|
|
2236
2261
|
//#endregion
|
|
2237
|
-
//#region src/remote/client.ts
|
|
2238
|
-
const isSharedMode = (clients) => clients.length === 1 && clients[0]?.phone === "shared";
|
|
2239
|
-
const availablePhones = (clients) => clients.map((c) => c.phone);
|
|
2240
|
-
const clientForPhone = (clients, phone) => {
|
|
2241
|
-
if (isSharedMode(clients)) {
|
|
2242
|
-
const entry = clients[0];
|
|
2243
|
-
if (!entry) throw new Error("No iMessage clients configured");
|
|
2244
|
-
return entry.client;
|
|
2245
|
-
}
|
|
2246
|
-
const entry = clients.find((c) => c.phone === phone);
|
|
2247
|
-
if (!entry) {
|
|
2248
|
-
const list = availablePhones(clients).join(", ") || "<none>";
|
|
2249
|
-
throw new Error(`No iMessage client serves phone ${phone}. Available: ${list}`);
|
|
2250
|
-
}
|
|
2251
|
-
return entry.client;
|
|
2252
|
-
};
|
|
2253
|
-
const randomPhone = (clients) => {
|
|
2254
|
-
if (clients.length === 0) throw new Error("No iMessage phones configured for this account");
|
|
2255
|
-
if (isSharedMode(clients)) return SHARED_PHONE;
|
|
2256
|
-
const entry = clients[Math.floor(Math.random() * clients.length)];
|
|
2257
|
-
if (!entry) throw new Error("No iMessage phones configured for this account");
|
|
2258
|
-
return entry.phone;
|
|
2259
|
-
};
|
|
2260
|
-
//#endregion
|
|
2261
2262
|
//#region src/index.ts
|
|
2262
2263
|
const isPollContent = (content) => content.type === "poll" || content.type === "poll_option";
|
|
2263
2264
|
const cacheRemoteOutbound = (remote, space, record) => {
|