morpho-socket 0.4.0 → 0.4.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/package.json
CHANGED
|
@@ -189,11 +189,14 @@ function createCapture(opts = {}) {
|
|
|
189
189
|
return found
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
-
|
|
192
|
+
const userPart = j => String(j || "").split("@")[0].split(":")[0]
|
|
193
|
+
function checkFrame(session, n, ownLid) {
|
|
193
194
|
const found = []
|
|
194
195
|
if (n.tag !== "message") return found
|
|
195
196
|
const a = n.attrs || {}
|
|
196
197
|
const sender = a.participant || a.from
|
|
198
|
+
// the account's own LID (messages sent from the phone / another device) never carries a number: not a problem
|
|
199
|
+
if (ownLid && userPart(sender) === ownLid) return found
|
|
197
200
|
const mode = a.addressing_mode || (isLid(sender) ? "lid" : "pn")
|
|
198
201
|
if (mode === "lid" && !(a.participant_pn || a.sender_pn || a.peer_recipient_pn) && !isSpecial(sender)) {
|
|
199
202
|
found.push(alert(session, "frame_lid_without_number", "warn", { jid: maskJid(sender), addressing_mode: a.addressing_mode ?? null }))
|
|
@@ -229,12 +232,12 @@ function createCapture(opts = {}) {
|
|
|
229
232
|
} catch { stats.errors++ }
|
|
230
233
|
}
|
|
231
234
|
|
|
232
|
-
function onFrame(session, node) {
|
|
235
|
+
function onFrame(session, node, sock) {
|
|
233
236
|
try {
|
|
234
237
|
if (isBin(node) || !frameTags.includes(node?.tag)) return
|
|
235
238
|
bump(stats.frames, node.tag)
|
|
236
239
|
const data = cleanNode(node)
|
|
237
|
-
const alerts = checkFrame(session, node)
|
|
240
|
+
const alerts = checkFrame(session, node, userPart(sock?.user?.lid))
|
|
238
241
|
write({ t: Date.now(), session, kind: "frame", name: node.tag, data, alerts: alerts.length ? alerts.map(a => a.code) : undefined })
|
|
239
242
|
} catch { stats.errors++ }
|
|
240
243
|
}
|
|
@@ -249,7 +252,7 @@ function createCapture(opts = {}) {
|
|
|
249
252
|
undo.push(() => sock.ev.off?.(name, fn))
|
|
250
253
|
}
|
|
251
254
|
if (frameTags.length && sock.ws?.on) {
|
|
252
|
-
const fn = node => onFrame(sessionId, node)
|
|
255
|
+
const fn = node => onFrame(sessionId, node, sock)
|
|
253
256
|
sock.ws.on("frame", fn) // every decoded binary node, before Baileys interprets it
|
|
254
257
|
undo.push(() => sock.ws.off?.("frame", fn))
|
|
255
258
|
}
|