diff --git a/pkg/message/service/message_service.go b/pkg/message/service/message_service.go index b2b21c72..c84f2cef 100644 --- a/pkg/message/service/message_service.go +++ b/pkg/message/service/message_service.go @@ -375,6 +375,10 @@ func (m *messageService) DeleteMessageEveryone(data *MessageStruct, instance *in m.loggerWrapper.GetLogger(instance.Id).LogError("[%s] Error validating message fields", instance.Id) return "", "", errors.New("invalid phone number") } + // The chat JID lands inside the revoke's protocolMessage Key: with the "+" + // prefix CreateJID adds, receiving devices look up a chat that doesn't + // exist and silently ignore the revoke. See utils.CanonicalJID. + recipient = utils.CanonicalJID(recipient) m.loggerWrapper.GetLogger(instance.Id).LogInfo("Revoking message %s from %s", data.MessageID, recipient) @@ -403,6 +407,9 @@ func (m *messageService) EditMessage(data *EditMessageStruct, instance *instance m.loggerWrapper.GetLogger(instance.Id).LogError("[%s] Error validating message fields", instance.Id) return "", "", errors.New("invalid phone number") } + // Same as DeleteMessageEveryone: the JID lands inside the edit's + // protocolMessage Key, so the "+" prefix makes recipients ignore it. + recipient = utils.CanonicalJID(recipient) resp, err := client.SendMessage( context.Background(), diff --git a/pkg/user/service/user_service.go b/pkg/user/service/user_service.go index 1ac63b1a..6f089a9f 100644 --- a/pkg/user/service/user_service.go +++ b/pkg/user/service/user_service.go @@ -335,6 +335,10 @@ func (u *userService) GetAvatar(data *GetAvatarStruct, instance *instance_model. if !ok { return nil, errors.New("invalid phone number") } + // GetProfilePictureInfo runs a usync IQ against the JID as-is; the "+" + // prefix CreateJID adds to phone numbers makes it query a nonexistent user + // and time out (~75s). See utils.CanonicalJID. + jid = utils.CanonicalJID(jid) u.loggerWrapper.GetLogger(instance.Id).LogInfo("[%s] Requesting avatar for JID: %s, Preview: %v", instance.Id, jid, data.Preview) diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index e7593477..e9e6ed70 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -636,3 +636,10 @@ func PrepareNumberForWhatsAppCheck(phone string, formatJid bool) (string, error) } return numbers[0], nil } + +// CanonicalJID normalizes a JID user part by stripping the leading "+" that +// some clients include, so lookups and comparisons match the stored form. +func CanonicalJID(jid whatsmeow_types.JID) whatsmeow_types.JID { + jid.User = strings.TrimPrefix(jid.User, "+") + return jid +}