summaryrefslogtreecommitdiffstats
path: root/bridge/whatsapp/handlers.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2020-11-29 15:26:45 +0100
committerWim <wim@42.be>2020-11-29 15:37:20 +0100
commit640a9995f4c8b4c7262b233d3acabda4bb651e3e (patch)
treebe7d34af0ab3ecb8e0b40560fd19b5d5d69607c0 /bridge/whatsapp/handlers.go
parent95625f687198b547b95874d9c73149e870c61ba2 (diff)
downloadmatterbridge-msglm-640a9995f4c8b4c7262b233d3acabda4bb651e3e.tar.gz
matterbridge-msglm-640a9995f4c8b4c7262b233d3acabda4bb651e3e.tar.bz2
matterbridge-msglm-640a9995f4c8b4c7262b233d3acabda4bb651e3e.zip
Refactor handleTextMessage (whatsapp)
Diffstat (limited to 'bridge/whatsapp/handlers.go')
-rw-r--r--bridge/whatsapp/handlers.go22
1 files changed, 9 insertions, 13 deletions
diff --git a/bridge/whatsapp/handlers.go b/bridge/whatsapp/handlers.go
index 0692f784..a08cba75 100644
--- a/bridge/whatsapp/handlers.go
+++ b/bridge/whatsapp/handlers.go
@@ -79,12 +79,10 @@ func (b *Bwhatsapp) HandleTextMessage(message whatsapp.TextMessage) {
return
}
- messageTime := time.Unix(int64(message.Info.Timestamp), 0) // TODO check how behaves between timezones
groupJID := message.Info.RemoteJid
-
senderJID := message.Info.SenderJid
+
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 {
senderJID = *message.Info.Source.Participant
}
@@ -113,17 +111,14 @@ func (b *Bwhatsapp) HandleTextMessage(message whatsapp.TextMessage) {
}
}
- b.Log.Debugf("<= Sending message from %s on %s to gateway", senderJID, b.Account)
-
rmsg := config.Message{
- UserID: senderJID,
- Username: senderName,
- Text: message.Text,
- Timestamp: messageTime,
- Channel: groupJID,
- Account: b.Account,
- Protocol: b.Protocol,
- Extra: make(map[string][]interface{}),
+ UserID: senderJID,
+ Username: senderName,
+ Text: message.Text,
+ Channel: groupJID,
+ Account: b.Account,
+ Protocol: b.Protocol,
+ Extra: make(map[string][]interface{}),
// ParentID: TODO, // TODO handle thread replies // map from Info.QuotedMessageID string
ID: message.Info.Id,
}
@@ -132,6 +127,7 @@ func (b *Bwhatsapp) HandleTextMessage(message whatsapp.TextMessage) {
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.Remote <- rmsg