From db71c497f048760bedc722766e9519b71ff54d1a Mon Sep 17 00:00:00 2001 From: Wim Date: Tue, 27 Aug 2024 18:46:15 +0200 Subject: [PATCH] Fix whatsmeow API changes --- bridge/whatsappmulti/handlers.go | 11 ++++++----- bridge/whatsappmulti/helpers.go | 6 +++--- bridge/whatsappmulti/whatsapp.go | 24 ++++++++++++------------ 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/bridge/whatsappmulti/handlers.go b/bridge/whatsappmulti/handlers.go index 8791df5e0f..90a7c7a667 100644 --- a/bridge/whatsappmulti/handlers.go +++ b/bridge/whatsappmulti/handlers.go @@ -27,7 +27,6 @@ func (b *Bwhatsapp) eventHandler(evt interface{}) { } func (b *Bwhatsapp) handleGroupInfo(event *events.GroupInfo) { - b.Log.Debugf("Receiving event %#v", event) switch { @@ -57,6 +56,7 @@ func (b *Bwhatsapp) handleUserJoin(event *events.GroupInfo) { b.Remote <- rmsg } } + func (b *Bwhatsapp) handleUserLeave(event *events.GroupInfo) { for _, leftJid := range event.Leave { senderName := b.getSenderNameFromJID(leftJid) @@ -74,6 +74,7 @@ func (b *Bwhatsapp) handleUserLeave(event *events.GroupInfo) { b.Remote <- rmsg } } + func (b *Bwhatsapp) handleTopicChange(event *events.GroupInfo) { msg := event.Topic senderJid := msg.TopicSetBy @@ -151,9 +152,9 @@ func (b *Bwhatsapp) handleTextMessage(messageInfo types.MessageInfo, msg *proto. senderJID = types.NewJID(ci.GetParticipant(), types.DefaultUserServer) } - if ci.MentionedJid != nil { + if ci.MentionedJID != nil { // handle user mentions - for _, mentionedJID := range ci.MentionedJid { + for _, mentionedJID := range ci.MentionedJID { numberAndSuffix := strings.SplitN(mentionedJID, "@", 2) // mentions comes as telephone numbers and we don't want to expose it to other bridges @@ -441,10 +442,10 @@ func (b *Bwhatsapp) handleDelete(messageInfo *proto.ProtocolMessage) { rmsg := config.Message{ Account: b.Account, Protocol: b.Protocol, - ID: getMessageIdFormat(sender, *messageInfo.Key.Id), + ID: getMessageIdFormat(sender, *messageInfo.Key.ID), Event: config.EventMsgDelete, Text: config.EventMsgDelete, - Channel: *messageInfo.Key.RemoteJid, + Channel: *messageInfo.Key.RemoteJID, } b.Log.Debugf("<= Sending message from %s to gateway", b.Account) diff --git a/bridge/whatsappmulti/helpers.go b/bridge/whatsappmulti/helpers.go index cecbf5a9f9..5eac958e64 100644 --- a/bridge/whatsappmulti/helpers.go +++ b/bridge/whatsappmulti/helpers.go @@ -157,7 +157,7 @@ func (b *Bwhatsapp) getNewReplyContext(parentID string) (*proto.ContextInfo, err sender := fmt.Sprintf("%s@%s", replyInfo.Sender.User, replyInfo.Sender.Server) ctx := &proto.ContextInfo{ - StanzaId: &replyInfo.MessageID, + StanzaID: &replyInfo.MessageID, Participant: &sender, QuotedMessage: &proto.Message{Conversation: goproto.String("")}, } @@ -191,11 +191,11 @@ func (b *Bwhatsapp) parseMessageID(id string) (*Replyable, error) { } func getParentIdFromCtx(ci *proto.ContextInfo) string { - if ci != nil && ci.StanzaId != nil { + if ci != nil && ci.StanzaID != nil { senderJid, err := types.ParseJID(*ci.Participant) if err == nil { - return getMessageIdFormat(senderJid, *ci.StanzaId) + return getMessageIdFormat(senderJid, *ci.StanzaID) } } diff --git a/bridge/whatsappmulti/whatsapp.go b/bridge/whatsappmulti/whatsapp.go index 99e564463b..e7c0f691a4 100644 --- a/bridge/whatsappmulti/whatsapp.go +++ b/bridge/whatsappmulti/whatsapp.go @@ -239,10 +239,10 @@ func (b *Bwhatsapp) PostDocumentMessage(msg config.Message, filetype string) (st Mimetype: &filetype, Caption: &caption, MediaKey: resp.MediaKey, - FileEncSha256: resp.FileEncSHA256, - FileSha256: resp.FileSHA256, + FileEncSHA256: resp.FileEncSHA256, + FileSHA256: resp.FileSHA256, FileLength: goproto.Uint64(resp.FileLength), - Url: &resp.URL, + URL: &resp.URL, DirectPath: &resp.DirectPath, ContextInfo: ctx, } @@ -277,10 +277,10 @@ func (b *Bwhatsapp) PostImageMessage(msg config.Message, filetype string) (strin Mimetype: &filetype, Caption: &caption, MediaKey: resp.MediaKey, - FileEncSha256: resp.FileEncSHA256, - FileSha256: resp.FileSHA256, + FileEncSHA256: resp.FileEncSHA256, + FileSHA256: resp.FileSHA256, FileLength: goproto.Uint64(resp.FileLength), - Url: &resp.URL, + URL: &resp.URL, DirectPath: &resp.DirectPath, ContextInfo: ctx, } @@ -311,10 +311,10 @@ func (b *Bwhatsapp) PostVideoMessage(msg config.Message, filetype string) (strin Mimetype: &filetype, Caption: &caption, MediaKey: resp.MediaKey, - FileEncSha256: resp.FileEncSHA256, - FileSha256: resp.FileSHA256, + FileEncSHA256: resp.FileEncSHA256, + FileSHA256: resp.FileSHA256, FileLength: goproto.Uint64(resp.FileLength), - Url: &resp.URL, + URL: &resp.URL, DirectPath: &resp.DirectPath, ContextInfo: ctx, } @@ -344,10 +344,10 @@ func (b *Bwhatsapp) PostAudioMessage(msg config.Message, filetype string) (strin message.AudioMessage = &proto.AudioMessage{ Mimetype: &filetype, MediaKey: resp.MediaKey, - FileEncSha256: resp.FileEncSHA256, - FileSha256: resp.FileSHA256, + FileEncSHA256: resp.FileEncSHA256, + FileSHA256: resp.FileSHA256, FileLength: goproto.Uint64(resp.FileLength), - Url: &resp.URL, + URL: &resp.URL, DirectPath: &resp.DirectPath, ContextInfo: ctx, }