summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/Rhymen/go-whatsapp/write.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2019-08-26 23:22:34 +0200
committerGitHub <noreply@github.com>2019-08-26 23:22:34 +0200
commitd525f1c9e4ac39b74575052b61c4de72de794b4e (patch)
tree90f444dd4046c7d29ed08c005648c573deb484b2 /vendor/github.com/Rhymen/go-whatsapp/write.go
parent921f2dfcdf1a6263220b55eb55716e497373dfcf (diff)
downloadmatterbridge-msglm-d525f1c9e4ac39b74575052b61c4de72de794b4e.tar.gz
matterbridge-msglm-d525f1c9e4ac39b74575052b61c4de72de794b4e.tar.bz2
matterbridge-msglm-d525f1c9e4ac39b74575052b61c4de72de794b4e.zip
Update Rhymen/go-whatsapp vendor (#876)
Diffstat (limited to 'vendor/github.com/Rhymen/go-whatsapp/write.go')
-rw-r--r--vendor/github.com/Rhymen/go-whatsapp/write.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/vendor/github.com/Rhymen/go-whatsapp/write.go b/vendor/github.com/Rhymen/go-whatsapp/write.go
index 4ea63dca..2b07ca6b 100644
--- a/vendor/github.com/Rhymen/go-whatsapp/write.go
+++ b/vendor/github.com/Rhymen/go-whatsapp/write.go
@@ -78,6 +78,36 @@ func (wac *Conn) sendKeepAlive() error {
return nil
}
+/*
+ When phone is unreachable, WhatsAppWeb sends ["admin","test"] time after time to try a successful contact.
+ Tested with Airplane mode and no connection at all.
+*/
+func (wac *Conn) sendAdminTest() (bool, error) {
+ data := []interface{}{"admin", "test"}
+
+ r, err := wac.writeJson(data)
+ if err != nil {
+ return false, errors.Wrap(err, "error sending admin test")
+ }
+
+ var response []interface{}
+
+ select {
+ case resp := <-r:
+ if err := json.Unmarshal([]byte(resp), &response); err != nil {
+ return false, fmt.Errorf("error decoding response message: %v\n", err)
+ }
+ case <-time.After(wac.msgTimeout):
+ return false, ErrConnectionTimeout
+ }
+
+ if len(response) == 2 && response[0].(string) == "Pong" && response[1].(bool) == true {
+ return true, nil
+ } else{
+ return false, nil
+ }
+}
+
func (wac *Conn) write(messageType int, answerMessageTag string, data []byte) (<-chan string, error) {
var ch chan string
if answerMessageTag != "" {