cleanup: remove string lid / jid refs and improve hosted support
This commit is contained in:
+1
-1
@@ -707,7 +707,7 @@ export const makeChatsSocket = (config: SocketConfig) => {
|
||||
const jid = attrs.from
|
||||
const participant = attrs.participant || attrs.from
|
||||
|
||||
if (shouldIgnoreJid(jid!) && jid !== '@s.whatsapp.net') {
|
||||
if (shouldIgnoreJid(jid!) && jid !== S_WHATSAPP_NET) {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -1021,7 +1021,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
participant: attrs.participant
|
||||
}
|
||||
|
||||
if (shouldIgnoreJid(remoteJid!) && remoteJid !== '@s.whatsapp.net') {
|
||||
if (shouldIgnoreJid(remoteJid!) && remoteJid !== S_WHATSAPP_NET) {
|
||||
logger.debug({ remoteJid }, 'ignoring receipt from jid')
|
||||
await sendMessageAck(node)
|
||||
return
|
||||
@@ -1101,7 +1101,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
|
||||
const handleNotification = async (node: BinaryNode) => {
|
||||
const remoteJid = node.attrs.from
|
||||
if (shouldIgnoreJid(remoteJid!) && remoteJid !== '@s.whatsapp.net') {
|
||||
if (shouldIgnoreJid(remoteJid!) && remoteJid !== S_WHATSAPP_NET) {
|
||||
logger.debug({ remoteJid, id: node.attrs.id }, 'ignored notification')
|
||||
await sendMessageAck(node)
|
||||
return
|
||||
@@ -1137,7 +1137,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
}
|
||||
|
||||
const handleMessage = async (node: BinaryNode) => {
|
||||
if (shouldIgnoreJid(node.attrs.from!) && node.attrs.from !== '@s.whatsapp.net') {
|
||||
if (shouldIgnoreJid(node.attrs.from!) && node.attrs.from !== S_WHATSAPP_NET) {
|
||||
logger.debug({ key: node.attrs.key }, 'ignored message')
|
||||
await sendMessageAck(node, NACK_REASONS.UnhandledError)
|
||||
return
|
||||
@@ -1290,22 +1290,6 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
const from = infoChild.attrs.from! || infoChild.attrs['call-creator']!
|
||||
status = getCallStatusFromNode(infoChild)
|
||||
|
||||
if (isLidUser(from) && infoChild.tag === 'relaylatency') {
|
||||
const verify = await callOfferCache.get(callId)
|
||||
if (!verify) {
|
||||
status = 'offer'
|
||||
const callLid: WACallEvent = {
|
||||
chatId: attrs.from!,
|
||||
from,
|
||||
id: callId,
|
||||
date: new Date(+attrs.t! * 1000),
|
||||
offline: !!attrs.offline,
|
||||
status
|
||||
}
|
||||
await callOfferCache.set(callId, callLid)
|
||||
}
|
||||
}
|
||||
|
||||
const call: WACallEvent = {
|
||||
chatId: attrs.from!,
|
||||
from,
|
||||
|
||||
@@ -281,7 +281,7 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
|
||||
const requestedLidUsers = new Set<string>()
|
||||
for (const jid of toFetch) {
|
||||
if (jid.includes('@lid') || jid.includes('@hosted.lid')) {
|
||||
if (isLidUser(jid) || isHostedLidUser(jid)) {
|
||||
const user = jidDecode(jid)?.user
|
||||
if (user) requestedLidUsers.add(user)
|
||||
}
|
||||
@@ -405,10 +405,10 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
if (jidsRequiringFetch.length) {
|
||||
// LID if mapped, otherwise original
|
||||
const wireJids = [
|
||||
...jidsRequiringFetch.filter(jid => !!jid.includes('@lid') || !!jid.includes('@hosted.lid')),
|
||||
...jidsRequiringFetch.filter(jid => !!isLidUser(jid) || !!isHostedLidUser(jid)),
|
||||
...(
|
||||
(await signalRepository.lidMapping.getLIDsForPNs(
|
||||
jidsRequiringFetch.filter(jid => !!jid.includes('@s.whatsapp.net') || !!jid.includes('@hosted'))
|
||||
jidsRequiringFetch.filter(jid => !!isPnUser(jid) || !!isHostedPnUser(jid)
|
||||
)) || []
|
||||
).map(a => a.lid)
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user