send, usync: fix lid Usync (including onWhatsApp), and send phash
This commit is contained in:
@@ -23,6 +23,7 @@ import {
|
||||
encryptMediaRetryRequest,
|
||||
extractDeviceJids,
|
||||
generateMessageIDV2,
|
||||
generateParticipantHashV2,
|
||||
generateWAMessage,
|
||||
getStatusCodeForMediaRetry,
|
||||
getUrlFromDirectPath,
|
||||
@@ -257,7 +258,7 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
deviceResults.push({
|
||||
user,
|
||||
device,
|
||||
wireJid: jid
|
||||
wireJid: jid // again this makes no sense
|
||||
})
|
||||
return null
|
||||
}
|
||||
@@ -311,7 +312,7 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
const query = new USyncQuery().withContext('message').withDeviceProtocol()
|
||||
|
||||
for (const jid of toFetch) {
|
||||
query.withUser(new USyncUser().withId(jid))
|
||||
query.withUser(new USyncUser().withId(jid)) // todo: investigate - the idea here is that <user> should have an inline lid field with the lid being the pn equivalent
|
||||
}
|
||||
|
||||
const result = await sock.executeUSyncQuery(query)
|
||||
@@ -808,6 +809,7 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
const finalJid = jid
|
||||
|
||||
// ADDRESSING CONSISTENCY: Match own identity to conversation context
|
||||
// TODO: investigate if this is true
|
||||
let ownId = meId
|
||||
if (isLid && meLid) {
|
||||
ownId = meLid
|
||||
@@ -844,7 +846,7 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
additionalAttributes = { ...additionalAttributes, device_fanout: 'false' }
|
||||
}
|
||||
|
||||
const { user, device } = jidDecode(participant.jid)!
|
||||
const { user, device } = jidDecode(participant.jid)! // rajeh: how does this even make sense TODO check out
|
||||
devices.push({
|
||||
user,
|
||||
device,
|
||||
@@ -883,13 +885,13 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
}
|
||||
|
||||
if (normalizeMessageContent(message)?.pinInChatMessage) {
|
||||
extraAttrs['decrypt-fail'] = 'hide'
|
||||
extraAttrs['decrypt-fail'] = 'hide' // todo: expand for reactions and other types
|
||||
}
|
||||
|
||||
if (isGroup || isStatus) {
|
||||
const [groupData, senderKeyMap] = await Promise.all([
|
||||
(async () => {
|
||||
let groupData = useCachedGroupMetadata && cachedGroupMetadata ? await cachedGroupMetadata(jid) : undefined
|
||||
let groupData = useCachedGroupMetadata && cachedGroupMetadata ? await cachedGroupMetadata(jid) : undefined // todo: should we rely on the cache specially if the cache is outdated and the metadata has new fields?
|
||||
if (groupData && Array.isArray(groupData?.participants)) {
|
||||
logger.trace({ jid, participants: groupData.participants.length }, 'using cached group metadata')
|
||||
} else if (!isStatus) {
|
||||
@@ -900,7 +902,7 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
})(),
|
||||
(async () => {
|
||||
if (!participant && !isStatus) {
|
||||
const result = await authState.keys.get('sender-key-memory', [jid])
|
||||
const result = await authState.keys.get('sender-key-memory', [jid]) // TODO: check out what if the sender key memory doesn't include the LID stuff now?
|
||||
return result[jid] || {}
|
||||
}
|
||||
|
||||
@@ -1072,6 +1074,10 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
participants.push(...meNodes)
|
||||
participants.push(...otherNodes)
|
||||
|
||||
if (meJids.length > 0 || otherJids.length > 0) {
|
||||
extraAttrs['phash'] = generateParticipantHashV2([...meJids, ...otherJids])
|
||||
}
|
||||
|
||||
shouldIncludeDeviceIdentity = shouldIncludeDeviceIdentity || s1 || s2
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user