mirror of
https://github.com/42wim/matterbridge.git
synced 2025-05-24 18:57:40 +03:00
Fix whatsmeow API changes
This commit is contained in:
parent
f04a171086
commit
db71c497f0
@ -27,7 +27,6 @@ func (b *Bwhatsapp) eventHandler(evt interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bwhatsapp) handleGroupInfo(event *events.GroupInfo) {
|
func (b *Bwhatsapp) handleGroupInfo(event *events.GroupInfo) {
|
||||||
|
|
||||||
b.Log.Debugf("Receiving event %#v", event)
|
b.Log.Debugf("Receiving event %#v", event)
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
@ -57,6 +56,7 @@ func (b *Bwhatsapp) handleUserJoin(event *events.GroupInfo) {
|
|||||||
b.Remote <- rmsg
|
b.Remote <- rmsg
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bwhatsapp) handleUserLeave(event *events.GroupInfo) {
|
func (b *Bwhatsapp) handleUserLeave(event *events.GroupInfo) {
|
||||||
for _, leftJid := range event.Leave {
|
for _, leftJid := range event.Leave {
|
||||||
senderName := b.getSenderNameFromJID(leftJid)
|
senderName := b.getSenderNameFromJID(leftJid)
|
||||||
@ -74,6 +74,7 @@ func (b *Bwhatsapp) handleUserLeave(event *events.GroupInfo) {
|
|||||||
b.Remote <- rmsg
|
b.Remote <- rmsg
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bwhatsapp) handleTopicChange(event *events.GroupInfo) {
|
func (b *Bwhatsapp) handleTopicChange(event *events.GroupInfo) {
|
||||||
msg := event.Topic
|
msg := event.Topic
|
||||||
senderJid := msg.TopicSetBy
|
senderJid := msg.TopicSetBy
|
||||||
@ -151,9 +152,9 @@ func (b *Bwhatsapp) handleTextMessage(messageInfo types.MessageInfo, msg *proto.
|
|||||||
senderJID = types.NewJID(ci.GetParticipant(), types.DefaultUserServer)
|
senderJID = types.NewJID(ci.GetParticipant(), types.DefaultUserServer)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ci.MentionedJid != nil {
|
if ci.MentionedJID != nil {
|
||||||
// handle user mentions
|
// handle user mentions
|
||||||
for _, mentionedJID := range ci.MentionedJid {
|
for _, mentionedJID := range ci.MentionedJID {
|
||||||
numberAndSuffix := strings.SplitN(mentionedJID, "@", 2)
|
numberAndSuffix := strings.SplitN(mentionedJID, "@", 2)
|
||||||
|
|
||||||
// mentions comes as telephone numbers and we don't want to expose it to other bridges
|
// 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{
|
rmsg := config.Message{
|
||||||
Account: b.Account,
|
Account: b.Account,
|
||||||
Protocol: b.Protocol,
|
Protocol: b.Protocol,
|
||||||
ID: getMessageIdFormat(sender, *messageInfo.Key.Id),
|
ID: getMessageIdFormat(sender, *messageInfo.Key.ID),
|
||||||
Event: config.EventMsgDelete,
|
Event: config.EventMsgDelete,
|
||||||
Text: config.EventMsgDelete,
|
Text: config.EventMsgDelete,
|
||||||
Channel: *messageInfo.Key.RemoteJid,
|
Channel: *messageInfo.Key.RemoteJID,
|
||||||
}
|
}
|
||||||
|
|
||||||
b.Log.Debugf("<= Sending message from %s to gateway", b.Account)
|
b.Log.Debugf("<= Sending message from %s to gateway", b.Account)
|
||||||
|
@ -157,7 +157,7 @@ func (b *Bwhatsapp) getNewReplyContext(parentID string) (*proto.ContextInfo, err
|
|||||||
|
|
||||||
sender := fmt.Sprintf("%s@%s", replyInfo.Sender.User, replyInfo.Sender.Server)
|
sender := fmt.Sprintf("%s@%s", replyInfo.Sender.User, replyInfo.Sender.Server)
|
||||||
ctx := &proto.ContextInfo{
|
ctx := &proto.ContextInfo{
|
||||||
StanzaId: &replyInfo.MessageID,
|
StanzaID: &replyInfo.MessageID,
|
||||||
Participant: &sender,
|
Participant: &sender,
|
||||||
QuotedMessage: &proto.Message{Conversation: goproto.String("")},
|
QuotedMessage: &proto.Message{Conversation: goproto.String("")},
|
||||||
}
|
}
|
||||||
@ -191,11 +191,11 @@ func (b *Bwhatsapp) parseMessageID(id string) (*Replyable, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getParentIdFromCtx(ci *proto.ContextInfo) string {
|
func getParentIdFromCtx(ci *proto.ContextInfo) string {
|
||||||
if ci != nil && ci.StanzaId != nil {
|
if ci != nil && ci.StanzaID != nil {
|
||||||
senderJid, err := types.ParseJID(*ci.Participant)
|
senderJid, err := types.ParseJID(*ci.Participant)
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return getMessageIdFormat(senderJid, *ci.StanzaId)
|
return getMessageIdFormat(senderJid, *ci.StanzaID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,10 +239,10 @@ func (b *Bwhatsapp) PostDocumentMessage(msg config.Message, filetype string) (st
|
|||||||
Mimetype: &filetype,
|
Mimetype: &filetype,
|
||||||
Caption: &caption,
|
Caption: &caption,
|
||||||
MediaKey: resp.MediaKey,
|
MediaKey: resp.MediaKey,
|
||||||
FileEncSha256: resp.FileEncSHA256,
|
FileEncSHA256: resp.FileEncSHA256,
|
||||||
FileSha256: resp.FileSHA256,
|
FileSHA256: resp.FileSHA256,
|
||||||
FileLength: goproto.Uint64(resp.FileLength),
|
FileLength: goproto.Uint64(resp.FileLength),
|
||||||
Url: &resp.URL,
|
URL: &resp.URL,
|
||||||
DirectPath: &resp.DirectPath,
|
DirectPath: &resp.DirectPath,
|
||||||
ContextInfo: ctx,
|
ContextInfo: ctx,
|
||||||
}
|
}
|
||||||
@ -277,10 +277,10 @@ func (b *Bwhatsapp) PostImageMessage(msg config.Message, filetype string) (strin
|
|||||||
Mimetype: &filetype,
|
Mimetype: &filetype,
|
||||||
Caption: &caption,
|
Caption: &caption,
|
||||||
MediaKey: resp.MediaKey,
|
MediaKey: resp.MediaKey,
|
||||||
FileEncSha256: resp.FileEncSHA256,
|
FileEncSHA256: resp.FileEncSHA256,
|
||||||
FileSha256: resp.FileSHA256,
|
FileSHA256: resp.FileSHA256,
|
||||||
FileLength: goproto.Uint64(resp.FileLength),
|
FileLength: goproto.Uint64(resp.FileLength),
|
||||||
Url: &resp.URL,
|
URL: &resp.URL,
|
||||||
DirectPath: &resp.DirectPath,
|
DirectPath: &resp.DirectPath,
|
||||||
ContextInfo: ctx,
|
ContextInfo: ctx,
|
||||||
}
|
}
|
||||||
@ -311,10 +311,10 @@ func (b *Bwhatsapp) PostVideoMessage(msg config.Message, filetype string) (strin
|
|||||||
Mimetype: &filetype,
|
Mimetype: &filetype,
|
||||||
Caption: &caption,
|
Caption: &caption,
|
||||||
MediaKey: resp.MediaKey,
|
MediaKey: resp.MediaKey,
|
||||||
FileEncSha256: resp.FileEncSHA256,
|
FileEncSHA256: resp.FileEncSHA256,
|
||||||
FileSha256: resp.FileSHA256,
|
FileSHA256: resp.FileSHA256,
|
||||||
FileLength: goproto.Uint64(resp.FileLength),
|
FileLength: goproto.Uint64(resp.FileLength),
|
||||||
Url: &resp.URL,
|
URL: &resp.URL,
|
||||||
DirectPath: &resp.DirectPath,
|
DirectPath: &resp.DirectPath,
|
||||||
ContextInfo: ctx,
|
ContextInfo: ctx,
|
||||||
}
|
}
|
||||||
@ -344,10 +344,10 @@ func (b *Bwhatsapp) PostAudioMessage(msg config.Message, filetype string) (strin
|
|||||||
message.AudioMessage = &proto.AudioMessage{
|
message.AudioMessage = &proto.AudioMessage{
|
||||||
Mimetype: &filetype,
|
Mimetype: &filetype,
|
||||||
MediaKey: resp.MediaKey,
|
MediaKey: resp.MediaKey,
|
||||||
FileEncSha256: resp.FileEncSHA256,
|
FileEncSHA256: resp.FileEncSHA256,
|
||||||
FileSha256: resp.FileSHA256,
|
FileSHA256: resp.FileSHA256,
|
||||||
FileLength: goproto.Uint64(resp.FileLength),
|
FileLength: goproto.Uint64(resp.FileLength),
|
||||||
Url: &resp.URL,
|
URL: &resp.URL,
|
||||||
DirectPath: &resp.DirectPath,
|
DirectPath: &resp.DirectPath,
|
||||||
ContextInfo: ctx,
|
ContextInfo: ctx,
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user