mirror of
https://github.com/42wim/matterbridge.git
synced 2024-11-15 00:19:24 +01:00
Refactor handleTextMessage (whatsapp)
This commit is contained in:
parent
95625f6871
commit
640a9995f4
@ -79,12 +79,10 @@ func (b *Bwhatsapp) HandleTextMessage(message whatsapp.TextMessage) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
messageTime := time.Unix(int64(message.Info.Timestamp), 0) // TODO check how behaves between timezones
|
|
||||||
groupJID := message.Info.RemoteJid
|
groupJID := message.Info.RemoteJid
|
||||||
|
|
||||||
senderJID := message.Info.SenderJid
|
senderJID := message.Info.SenderJid
|
||||||
|
|
||||||
if len(senderJID) == 0 {
|
if len(senderJID) == 0 {
|
||||||
// TODO workaround till https://github.com/Rhymen/go-whatsapp/issues/86 resolved
|
|
||||||
if message.Info.Source != nil && message.Info.Source.Participant != nil {
|
if message.Info.Source != nil && message.Info.Source.Participant != nil {
|
||||||
senderJID = *message.Info.Source.Participant
|
senderJID = *message.Info.Source.Participant
|
||||||
}
|
}
|
||||||
@ -113,13 +111,10 @@ func (b *Bwhatsapp) HandleTextMessage(message whatsapp.TextMessage) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
b.Log.Debugf("<= Sending message from %s on %s to gateway", senderJID, b.Account)
|
|
||||||
|
|
||||||
rmsg := config.Message{
|
rmsg := config.Message{
|
||||||
UserID: senderJID,
|
UserID: senderJID,
|
||||||
Username: senderName,
|
Username: senderName,
|
||||||
Text: message.Text,
|
Text: message.Text,
|
||||||
Timestamp: messageTime,
|
|
||||||
Channel: groupJID,
|
Channel: groupJID,
|
||||||
Account: b.Account,
|
Account: b.Account,
|
||||||
Protocol: b.Protocol,
|
Protocol: b.Protocol,
|
||||||
@ -132,6 +127,7 @@ func (b *Bwhatsapp) HandleTextMessage(message whatsapp.TextMessage) {
|
|||||||
rmsg.Avatar = avatarURL
|
rmsg.Avatar = avatarURL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
b.Log.Debugf("<= Sending message from %s on %s to gateway", senderJID, b.Account)
|
||||||
b.Log.Debugf("<= Message is %#v", rmsg)
|
b.Log.Debugf("<= Message is %#v", rmsg)
|
||||||
|
|
||||||
b.Remote <- rmsg
|
b.Remote <- rmsg
|
||||||
|
Loading…
Reference in New Issue
Block a user