summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/Rhymen/go-whatsapp/write.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2020-08-24 23:35:08 +0200
committerGitHub <noreply@github.com>2020-08-24 23:35:08 +0200
commit2f506425c25504662f50f49e742529195d63ff27 (patch)
tree47170c6086cee16549a695329a478fd49174c299 /vendor/github.com/Rhymen/go-whatsapp/write.go
parente8167ee3d73c47353eea1b0bd7062bd2fc3fc127 (diff)
downloadmatterbridge-msglm-2f506425c25504662f50f49e742529195d63ff27.tar.gz
matterbridge-msglm-2f506425c25504662f50f49e742529195d63ff27.tar.bz2
matterbridge-msglm-2f506425c25504662f50f49e742529195d63ff27.zip
Update whatsapp vendor and fix a panic (#1209)
* Fix another whatsapp panic * Update whatsapp vendor
Diffstat (limited to 'vendor/github.com/Rhymen/go-whatsapp/write.go')
-rw-r--r--vendor/github.com/Rhymen/go-whatsapp/write.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/vendor/github.com/Rhymen/go-whatsapp/write.go b/vendor/github.com/Rhymen/go-whatsapp/write.go
index 1a2f4d7b..74f43c42 100644
--- a/vendor/github.com/Rhymen/go-whatsapp/write.go
+++ b/vendor/github.com/Rhymen/go-whatsapp/write.go
@@ -30,6 +30,11 @@ func (wac *Conn) writeJson(data []interface{}) (<-chan string, error) {
messageTag := fmt.Sprintf("%d.--%d", ts, wac.msgCount)
bytes := []byte(fmt.Sprintf("%s,%s", messageTag, d))
+ if wac.timeTag == "" {
+ tss := fmt.Sprintf("%d", ts)
+ wac.timeTag = tss[len(tss)-3:]
+ }
+
ch, err := wac.write(websocket.TextMessage, messageTag, bytes)
if err != nil {
return nil, err
@@ -127,6 +132,9 @@ func (wac *Conn) write(messageType int, answerMessageTag string, data []byte) (<
wac.listener.Unlock()
}
+ if wac == nil || wac.ws == nil {
+ return nil, ErrInvalidWebsocket
+ }
wac.ws.Lock()
err := wac.ws.conn.WriteMessage(messageType, data)
wac.ws.Unlock()