Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Socket/messages-send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ export const makeMessagesSocket = (config: SocketConfig) => {
devices.push(...additionalDevices)
}

const patched = await patchMessageBeforeSending(message, devices.map(d => jidEncode(d.user, isLid ? 'lid' : 's.whatsapp.net', d.device)))
const patched = await patchMessageBeforeSending(message, devices.map(d => jidEncode(d.user, d.server || (isLid ? 'lid' : 's.whatsapp.net'), d.device)))
const bytes = encodeWAMessage(patched)

const { ciphertext, senderKeyDistributionMessage } = await signalRepository.encryptGroupMessage(
Expand All @@ -414,8 +414,8 @@ export const makeMessagesSocket = (config: SocketConfig) => {

const senderKeyJids: string[] = []
// ensure a connection is established with every device
for(const { user, device } of devices) {
const jid = jidEncode(user, isLid ? 'lid' : 's.whatsapp.net', device)
for(const { user, device, server: dServer } of devices) {
const jid = jidEncode(user, dServer || (isLid ? 'lid' : 's.whatsapp.net'), device)
if(!senderKeyMap[jid] || !!participant) {
senderKeyJids.push(jid)
// store that this person has had the sender keys sent to them
Expand Down
4 changes: 2 additions & 2 deletions src/Utils/signal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export const extractDeviceJids = (result: USyncQueryResultList[], myJid: string,

for(const userResult of result) {
const { devices, id } = userResult as { devices: ParsedDeviceInfo, id: string }
const { user } = jidDecode(id)!
const { user, server } = jidDecode(id)!
const deviceList = devices?.deviceList as DeviceListData[]
if(Array.isArray(deviceList)) {
for(const { id: device, keyIndex } of deviceList) {
Expand All @@ -132,7 +132,7 @@ export const extractDeviceJids = (result: USyncQueryResultList[], myJid: string,
(myUser !== user || myDevice !== device) && // either different user or if me user, not this device
(device === 0 || !!keyIndex) // ensure that "key-index" is specified for "non-zero" devices, produces a bad req otherwise
) {
extracted.push({ user, device })
extracted.push({ user, device, server })
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/WABinary/jid-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export type JidServer = 'c.us' | 'g.us' | 'broadcast' | 's.whatsapp.net' | 'call
export type JidWithDevice = {
user: string
device?: number
server?: JidServer
}

export type FullJid = JidWithDevice & {
Expand Down