From 4c803a6a13a0b36f37e23b0030c2dd2b3ad7e113 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Tue, 4 May 2021 21:44:55 +0300 Subject: [PATCH] Include message tag when logging raw JSON messages --- go.mod | 2 +- go.sum | 2 ++ user.go | 8 ++++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 0495da8..62d3ad1 100644 --- a/go.mod +++ b/go.mod @@ -16,4 +16,4 @@ require ( maunium.net/go/mautrix v0.9.8 ) -replace github.com/Rhymen/go-whatsapp => github.com/tulir/go-whatsapp v0.4.5 +replace github.com/Rhymen/go-whatsapp => github.com/tulir/go-whatsapp v0.4.6 diff --git a/go.sum b/go.sum index 4b2c885..9048b1f 100644 --- a/go.sum +++ b/go.sum @@ -327,6 +327,8 @@ github.com/tulir/go-whatsapp v0.4.4 h1:69AIE/CbmVYpBbug75meWFOS8lilzoafZFctt2JzR github.com/tulir/go-whatsapp v0.4.4/go.mod h1:rwwuTh1bKqhgrRvOBAr8hDqtuz8Cc1Quqw/0BeXb+/E= github.com/tulir/go-whatsapp v0.4.5 h1:rLPm1Hnn5KGnbRwlL3Fwn1dMqb6mFI4hyeS1fNYiVFM= github.com/tulir/go-whatsapp v0.4.5/go.mod h1:rwwuTh1bKqhgrRvOBAr8hDqtuz8Cc1Quqw/0BeXb+/E= +github.com/tulir/go-whatsapp v0.4.6 h1:3Gcb7jrD3ufJcJCn6efI2RcCE0Nc3/Vo+PgkT9HaNZM= +github.com/tulir/go-whatsapp v0.4.6/go.mod h1:3dqwyo5zT8bhptPR1p/TdE+lyovs3ZjycJUiLnc3yhM= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= diff --git a/user.go b/user.go index 26cbe15..bb3452a 100644 --- a/user.go +++ b/user.go @@ -633,7 +633,7 @@ func (user *User) HandleEvent(event interface{}) { if portal != nil { go user.updateChatTag(nil, portal, user.bridge.Config.Bridge.PinnedTag, v.IsPinned) } - case json.RawMessage: + case whatsapp.RawJSONMessage: user.HandleJSONMessage(v) case *waProto.WebMessageInfo: user.updateLastConnectionIfNecessary() @@ -1380,11 +1380,11 @@ func (user *User) HandleConnInfo(info whatsapp.ConnInfo) { } } -func (user *User) HandleJSONMessage(message json.RawMessage) { - if !json.Valid(message) { +func (user *User) HandleJSONMessage(evt whatsapp.RawJSONMessage) { + if !json.Valid(evt.RawMessage) { return } - user.log.Debugfln("JSON message: %s", message) + user.log.Debugfln("JSON message with tag %s: %s", evt.Tag, evt.RawMessage) user.updateLastConnectionIfNecessary() }