4
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2025-09-11 01:52:30 +00:00

Update whatsapp vendor and fix a panic (#1209)

* Fix another whatsapp panic

* Update whatsapp vendor
This commit is contained in:
Wim
2020-08-24 23:35:08 +02:00
committed by GitHub
parent e8167ee3d7
commit 2f506425c2
13 changed files with 228 additions and 27 deletions

View File

@@ -133,6 +133,14 @@ type ChatListHandler interface {
HandleChatList(contacts []Chat)
}
/**
The BatteryMessageHandler interface needs to be implemented to receive percentage the device connected dispatched by the dispatcher.
*/
type BatteryMessageHandler interface {
Handler
HandleBatteryMessage(battery BatteryMessage)
}
/*
AddHandler adds an handler to the list of handler that receive dispatched messages.
The provided handler must at least implement the Handler interface. Additionally implemented
@@ -285,6 +293,17 @@ func (wac *Conn) handleWithCustomHandlers(message interface{}, handlers []Handle
}
}
}
case BatteryMessage:
for _, h := range handlers {
if x, ok := h.(BatteryMessageHandler); ok {
if wac.shouldCallSynchronously(h) {
x.HandleBatteryMessage(m)
} else {
go x.HandleBatteryMessage(m)
}
}
}
case *proto.WebMessageInfo:
for _, h := range handlers {
@@ -379,6 +398,10 @@ func (wac *Conn) dispatch(msg interface{}) {
wac.handle(ParseProtoMessage(v))
}
}
} else if con, ok := message.Content.([]binary.Node); ok {
for a := range con {
wac.handle(ParseNodeMessage(con[a]))
}
}
} else if message.Description == "response" && message.Attributes["type"] == "contacts" {
wac.updateContacts(message.Content)