1
0
Fork 0
mirror of https://github.com/mautrix/whatsapp.git synced 2026-07-11 08:26:08 -04:00

Compare commits

..

1 commit

Author SHA1 Message Date
Nick Mills-Barrett
9bd940726f
dependencies: bump whatsmeow 2026-07-09 09:48:24 +01:00
11 changed files with 24 additions and 49 deletions

2
go.mod
View file

@ -12,7 +12,7 @@ require (
github.com/tidwall/gjson v1.19.0
go.mau.fi/util v0.9.10
go.mau.fi/webp v0.3.0
go.mau.fi/whatsmeow v0.0.0-20260709092057-73fe7355f59f
go.mau.fi/whatsmeow v0.0.0-20260708165445-a2136cc8d5db
golang.org/x/image v0.42.0
golang.org/x/net v0.56.0
golang.org/x/sync v0.21.0

4
go.sum
View file

@ -75,8 +75,8 @@ go.mau.fi/util v0.9.10 h1:wzvz5iDHyqDXB8vgisD4d3SzucLXNM3iNY+1O1RoHtg=
go.mau.fi/util v0.9.10/go.mod h1:YQOxySn+ZE3qSYqNxvyX7Yi3suA8YK17PS6QqBREW7A=
go.mau.fi/webp v0.3.0 h1:gVHQZtz21Ziwj+CDuklbX9mqpsnDIFKxs/BJyV7iZzA=
go.mau.fi/webp v0.3.0/go.mod h1:rlZFTev+dYxhvk+XNBP/5GcTt4gXmzAB4DU0aGUYIQo=
go.mau.fi/whatsmeow v0.0.0-20260709092057-73fe7355f59f h1:VZkwFBEQ9TbB9IWsldw8BJDhHbEBElm9VD2VQXbSc9s=
go.mau.fi/whatsmeow v0.0.0-20260709092057-73fe7355f59f/go.mod h1:9dmNTYZ/1pHjPw/bz+azBsGjAkcrZbqzMrKcvG5bJ8U=
go.mau.fi/whatsmeow v0.0.0-20260708165445-a2136cc8d5db h1:giO0YkqIJlbKURx7kj4i7zicLKj2ZODMM5X1tZAadH0=
go.mau.fi/whatsmeow v0.0.0-20260708165445-a2136cc8d5db/go.mod h1:9dmNTYZ/1pHjPw/bz+azBsGjAkcrZbqzMrKcvG5bJ8U=
go.mau.fi/zeroconfig v0.2.0 h1:e/OGEERqVRRKlgaro7E6bh8xXiKFSXB3eNNIud7FUjU=
go.mau.fi/zeroconfig v0.2.0/go.mod h1:J0Vn0prHNOm493oZoQ84kq83ZaNCYZnq+noI1b1eN8w=
golang.org/x/crypto v0.53.0 h1:QZ4Muo8THX6CizN2vPPd5fBGHyogrdK9fG4wLPFUsto=

View file

@ -750,7 +750,7 @@ func (wa *WhatsAppClient) convertHistorySyncMessage(
// TODO use proper intent
intent := wa.Main.Bridge.Bot
wrapped := &bridgev2.BackfillMessage{
ConvertedMessage: wa.Main.MsgConv.ToMatrix(ctx, portal, wa.Client, intent, msg, rawMsg, info, nil, isViewOnce, true, nil),
ConvertedMessage: wa.Main.MsgConv.ToMatrix(ctx, portal, wa.Client, intent, msg, rawMsg, info, isViewOnce, true, nil),
Sender: wa.makeEventSender(ctx, info.Sender),
ID: waid.MakeMessageID(info.Chat, info.Sender, info.ID),
TxnID: networkid.TransactionID(waid.MakeMessageID(info.Chat, info.Sender, info.ID)),

View file

@ -52,7 +52,6 @@ func (wa *WhatsAppClient) getPortalKeyByMessageSource(ms types.MessageSource) ne
}
type MessageInfoWrapper struct {
OrigSource types.MessageSource
Info types.MessageInfo
wa *WhatsAppClient
}
@ -201,7 +200,7 @@ func (evt *WAMessageEvent) ConvertEdit(ctx context.Context, portal *bridgev2.Por
ctx = context.WithValue(ctx, msgconv.ContextKeyEditTargetID, evt.Message.GetProtocolMessage().GetKey().GetID())
cm := evt.wa.Main.MsgConv.ToMatrix(
ctx, portal, evt.wa.Client, intent, editedMsg, evt.MsgEvent.RawMessage, &evt.Info, &evt.OrigSource, evt.isViewOnce(), false, previouslyConvertedPart,
ctx, portal, evt.wa.Client, intent, editedMsg, evt.MsgEvent.RawMessage, &evt.Info, evt.isViewOnce(), false, previouslyConvertedPart,
)
if evt.isUndecryptableUpsertSubEvent && isFailedMedia(cm) {
evt.postHandle = func() {
@ -286,7 +285,7 @@ func (evt *WAMessageEvent) HandleExisting(ctx context.Context, portal *bridgev2.
func (evt *WAMessageEvent) ConvertMessage(ctx context.Context, portal *bridgev2.Portal, intent bridgev2.MatrixAPI) (*bridgev2.ConvertedMessage, error) {
evt.wa.EnqueuePortalResync(portal, false)
converted := evt.wa.Main.MsgConv.ToMatrix(
ctx, portal, evt.wa.Client, intent, evt.Message, evt.MsgEvent.RawMessage, &evt.Info, &evt.OrigSource, evt.isViewOnce(), false, nil,
ctx, portal, evt.wa.Client, intent, evt.Message, evt.MsgEvent.RawMessage, &evt.Info, evt.isViewOnce(), false, nil,
)
if isFailedMedia(converted) {
evt.postHandle = func() {

View file

@ -177,7 +177,7 @@ func (wa *WhatsAppClient) HandleMatrixReaction(ctx context.Context, msg *bridgev
defer wa.mcTrack(msg, time.Now(), &retErr)
var req whatsmeow.SendRequestExtra
if msg.Portal.Metadata.(*waid.PortalMetadata).CommunityAnnouncementGroup {
reactionMsg.EncReactionMessage, err = wa.Client.EncryptReaction(ctx, msgconv.MessageIDToInfo(ctx, wa.Client, messageID), reactionMsg.ReactionMessage)
reactionMsg.EncReactionMessage, err = wa.Client.EncryptReaction(ctx, msgconv.MessageIDToInfo(wa.Client, messageID), reactionMsg.ReactionMessage)
if err != nil {
return nil, fmt.Errorf("failed to encrypt reaction: %w", err)
}

View file

@ -358,7 +358,6 @@ func (wa *WhatsAppClient) handleWAMessage(ctx context.Context, evt *events.Messa
evt.UnwrapRaw()
parsedMessageType = getMessageType(evt.Message)
}
origSource := evt.Info.MessageSource
wa.rerouteWAMessage(ctx, "message", &evt.Info.MessageSource, evt.Info.ID)
wa.UserLogin.Log.Trace().
Any("info", evt.Info).
@ -410,7 +409,6 @@ func (wa *WhatsAppClient) handleWAMessage(ctx context.Context, evt *events.Messa
res := wa.UserLogin.QueueRemoteEvent(&WAMessageEvent{
MessageInfoWrapper: &MessageInfoWrapper{
OrigSource: origSource,
Info: evt.Info,
wa: wa,
},

View file

@ -67,11 +67,10 @@ func getMessageType(waMsg *waE2E.Message) string {
return "encrypted comment"
case waMsg.CommentMessage != nil:
return "comment"
case waMsg.PollCreationMessage != nil || waMsg.PollCreationMessageV2 != nil || waMsg.PollCreationMessageV3 != nil ||
waMsg.PollCreationMessageV5 != nil || waMsg.PollCreationMessageV6 != nil:
case waMsg.PollCreationMessage != nil || waMsg.PollCreationMessageV2 != nil || waMsg.PollCreationMessageV3 != nil:
return "poll create"
case waMsg.PollCreationMessageV4 != nil:
return "poll create (v4)"
case waMsg.PollCreationMessageV4 != nil || waMsg.PollCreationMessageV5 != nil:
return "poll create (vNext)"
case waMsg.PollUpdateMessage != nil:
return "poll update"
case waMsg.ProtocolMessage != nil:

View file

@ -143,7 +143,7 @@ func (mc *MessageConverter) ToWhatsApp(
if err != nil {
return nil, nil, fmt.Errorf("failed to parse message ID: %w", err)
}
rootMsgInfo := MessageIDToInfo(ctx, client, parsedID)
rootMsgInfo := MessageIDToInfo(client, parsedID)
message, err = client.EncryptComment(ctx, rootMsgInfo, message)
if err != nil {
return nil, nil, fmt.Errorf("failed to encrypt comment: %w", err)

View file

@ -136,7 +136,6 @@ func (mc *MessageConverter) ToMatrix(
waMsg *waE2E.Message,
rawWaMsg *waE2E.Message,
info *types.MessageInfo,
origSource *types.MessageSource,
isViewOnce bool,
isBackfill bool,
previouslyConvertedPart *bridgev2.ConvertedMessagePart,
@ -176,14 +175,8 @@ func (mc *MessageConverter) ToMatrix(
part, contextInfo = mc.convertPollCreationMessage(ctx, waMsg.PollCreationMessageV2)
case waMsg.PollCreationMessageV3 != nil:
part, contextInfo = mc.convertPollCreationMessage(ctx, waMsg.PollCreationMessageV3)
//case waMsg.PollCreationMessageV4 != nil:
// part, contextInfo = mc.convertPollCreationMessage(ctx, waMsg.PollCreationMessageV4)
case waMsg.PollCreationMessageV5 != nil:
part, contextInfo = mc.convertPollCreationMessage(ctx, waMsg.PollCreationMessageV5)
case waMsg.PollCreationMessageV6 != nil:
part, contextInfo = mc.convertPollCreationMessage(ctx, waMsg.PollCreationMessageV6)
case waMsg.PollUpdateMessage != nil:
part, contextInfo = mc.convertPollUpdateMessage(ctx, info, origSource, waMsg.PollUpdateMessage)
part, contextInfo = mc.convertPollUpdateMessage(ctx, info, waMsg.PollUpdateMessage)
case waMsg.EventMessage != nil:
part, contextInfo = mc.convertEventMessage(ctx, waMsg.EventMessage)
case waMsg.PinInChatMessage != nil:

View file

@ -115,7 +115,7 @@ func (mc *MessageConverter) PollVoteToWhatsApp(
zerolog.Ctx(ctx).Err(err).Msg("Failed to parse message ID")
return nil, fmt.Errorf("failed to parse message ID")
}
pollMsgInfo := MessageIDToInfo(ctx, client, parsedMsgID)
pollMsgInfo := MessageIDToInfo(client, parsedMsgID)
pollMsgInfo.Type = "poll"
optionHashes := make([][]byte, 0, len(content.Response.Answers))
if pollMsg.Metadata.(*waid.MessageMetadata).IsMatrixPoll {
@ -146,23 +146,13 @@ func (mc *MessageConverter) PollVoteToWhatsApp(
return &waE2E.Message{PollUpdateMessage: pollUpdate}, err
}
func MessageIDToInfo(ctx context.Context, client *whatsmeow.Client, parsedMsgID *waid.ParsedMessageID) *types.MessageInfo {
chat := parsedMsgID.Chat
sender := parsedMsgID.Sender
if client.Store.LIDMigrationTimestamp != 0 && chat.Server == types.DefaultUserServer {
chatLID, _ := client.Store.LIDs.GetLIDForPN(ctx, chat)
senderLID, _ := client.Store.LIDs.GetLIDForPN(ctx, sender)
if !chatLID.IsEmpty() && !senderLID.IsEmpty() {
chat = chatLID
sender = senderLID
}
}
func MessageIDToInfo(client *whatsmeow.Client, parsedMsgID *waid.ParsedMessageID) *types.MessageInfo {
return &types.MessageInfo{
MessageSource: types.MessageSource{
Chat: chat,
Sender: sender,
IsFromMe: sender.User == client.Store.GetLID().User || sender.User == client.Store.GetJID().User,
IsGroup: chat.Server == types.GroupServer,
Chat: parsedMsgID.Chat,
Sender: parsedMsgID.Sender,
IsFromMe: parsedMsgID.Sender.User == client.Store.GetLID().User || parsedMsgID.Sender.User == client.Store.GetJID().User,
IsGroup: parsedMsgID.Chat.Server == types.GroupServer,
},
ID: parsedMsgID.ID,
}

View file

@ -170,7 +170,7 @@ var failedPollUpdatePart = &bridgev2.ConvertedMessagePart{
DontBridge: true,
}
func (mc *MessageConverter) convertPollUpdateMessage(ctx context.Context, info *types.MessageInfo, origSource *types.MessageSource, msg *waE2E.PollUpdateMessage) (*bridgev2.ConvertedMessagePart, *waE2E.ContextInfo) {
func (mc *MessageConverter) convertPollUpdateMessage(ctx context.Context, info *types.MessageInfo, msg *waE2E.PollUpdateMessage) (*bridgev2.ConvertedMessagePart, *waE2E.ContextInfo) {
log := zerolog.Ctx(ctx)
pollMessageID := KeyToMessageID(ctx, getClient(ctx), info.Chat, info.Sender, msg.PollCreationMessageKey)
pollMessage, err := mc.Bridge.DB.Message.GetPartByID(ctx, getPortal(ctx).Receiver, pollMessageID, "")
@ -181,12 +181,8 @@ func (mc *MessageConverter) convertPollUpdateMessage(ctx context.Context, info *
log.Warn().Str("target_message_id", string(pollMessageID)).Msg("Poll update target message not found")
return failedPollUpdatePart, nil
}
infoForDecrypt := *info
if origSource != nil {
infoForDecrypt.MessageSource = *origSource
}
vote, err := getClient(ctx).DecryptPollVote(ctx, &events.Message{
Info: infoForDecrypt,
Info: *info,
Message: &waE2E.Message{PollUpdateMessage: msg},
})
if err != nil {