send: ignore own device in all cases

Closes #1167
This commit is contained in:
Tulir Asokan
2026-06-11 11:51:19 +03:00
parent 4e622162b9
commit 3706a7d315
2 changed files with 12 additions and 6 deletions
+6 -3
View File
@@ -1285,6 +1285,9 @@ func (cli *Client) encryptMessageForDevices(
sessionAddressToJID := make(map[string]types.JID, len(allDevices))
sessionAddresses := make([]string, 0, len(allDevices))
for _, jid := range allDevices {
if jid == ownJID || jid == ownLID {
continue
}
encryptionIdentity := jid
if jid.Server == types.DefaultUserServer {
// TODO query LID from server for missing entries
@@ -1313,10 +1316,10 @@ func (cli *Client) encryptMessageForDevices(
for _, jid := range allDevices {
plaintext := msgPlaintext
if jid == ownJID || jid == ownLID {
continue
}
if (jid.User == ownJID.User || jid.User == ownLID.User) && dsmPlaintext != nil {
if jid == ownJID || jid == ownLID {
continue
}
plaintext = dsmPlaintext
}
encrypted, isPreKey, err := cli.encryptMessageForDeviceAndWrap(
+6 -3
View File
@@ -530,6 +530,9 @@ func (cli *Client) encryptMessageForDevicesV3(
sessionAddressToJID := make(map[string]types.JID, len(allDevices))
sessionAddresses := make([]string, 0, len(allDevices))
for _, jid := range allDevices {
if jid == ownID {
continue
}
addr := jid.SignalAddress().String()
sessionAddresses = append(sessionAddresses, addr)
sessionAddressToJID[addr] = jid
@@ -547,11 +550,11 @@ func (cli *Client) encryptMessageForDevicesV3(
bundles := cli.fetchPreKeysNoError(ctx, retryDevices)
for _, jid := range allDevices {
if jid == ownID {
continue
}
var dsmForDevice *waMsgTransport.MessageTransport_Protocol_Integral_DeviceSentMessage
if jid.User == ownID.User {
if jid == ownID {
continue
}
dsmForDevice = dsm
}
encrypted, err := cli.encryptMessageForDeviceAndWrapV3(ctx, payload, skdm, dsmForDevice, jid, bundles[jid], encAttrs)