Skip to content

Commit

Permalink
Fix whatsmeow API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
42wim committed Aug 27, 2024
1 parent f04a171 commit db71c49
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
11 changes: 6 additions & 5 deletions bridge/whatsappmulti/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions bridge/whatsappmulti/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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("")},
}
Expand Down Expand Up @@ -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)
}
}

Expand Down
24 changes: 12 additions & 12 deletions bridge/whatsappmulti/whatsapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down Expand Up @@ -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,
}
Expand Down Expand Up @@ -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,
}
Expand Down Expand Up @@ -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,
}
Expand Down

0 comments on commit db71c49

Please sign in to comment.