mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
exclude my device from message send
This commit is contained in:
@@ -124,11 +124,8 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
const result = await query(iq)
|
const result = await query(iq)
|
||||||
let resultJids = extractDeviceJids(result)
|
const { device } = jidDecode(authState.creds.me!.id)
|
||||||
if(ignoreZeroDevices) {
|
return extractDeviceJids(result, device, ignoreZeroDevices)
|
||||||
resultJids = resultJids.filter(item => item.device !== 0)
|
|
||||||
}
|
|
||||||
return resultJids
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const assertSession = async(jid: string, force: boolean) => {
|
const assertSession = async(jid: string, force: boolean) => {
|
||||||
|
|||||||
@@ -231,7 +231,7 @@ export const parseAndInjectE2ESession = async(node: BinaryNode, auth: Authentica
|
|||||||
await cipher.initOutgoing(device)
|
await cipher.initOutgoing(device)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const extractDeviceJids = (result: BinaryNode) => {
|
export const extractDeviceJids = (result: BinaryNode, myDeviceId: number, excludeZeroDevices: boolean) => {
|
||||||
const extracted: { user: string, device?: number, agent?: number }[] = []
|
const extracted: { user: string, device?: number, agent?: number }[] = []
|
||||||
for(const node of result.content as BinaryNode[]) {
|
for(const node of result.content as BinaryNode[]) {
|
||||||
const list = getBinaryNodeChild(node, 'list')?.content
|
const list = getBinaryNodeChild(node, 'list')?.content
|
||||||
@@ -242,8 +242,9 @@ export const extractDeviceJids = (result: BinaryNode) => {
|
|||||||
const deviceListNode = getBinaryNodeChild(devicesNode, 'device-list')
|
const deviceListNode = getBinaryNodeChild(devicesNode, 'device-list')
|
||||||
if(Array.isArray(deviceListNode?.content)) {
|
if(Array.isArray(deviceListNode?.content)) {
|
||||||
for(const { tag, attrs } of deviceListNode!.content) {
|
for(const { tag, attrs } of deviceListNode!.content) {
|
||||||
if(tag === 'device') {
|
const device = +attrs.id
|
||||||
extracted.push({ user, device: +attrs.id })
|
if(tag === 'device' && myDeviceId !== device && (!excludeZeroDevices || device !== 0)) {
|
||||||
|
extracted.push({ user, device })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user