Include message tag when logging raw JSON messages

This commit is contained in:
Tulir Asokan 2021-05-04 21:44:55 +03:00
parent 947f3466b7
commit 4c803a6a13
3 changed files with 7 additions and 5 deletions

2
go.mod
View file

@ -16,4 +16,4 @@ require (
maunium.net/go/mautrix v0.9.8 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

2
go.sum
View file

@ -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.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 h1:rLPm1Hnn5KGnbRwlL3Fwn1dMqb6mFI4hyeS1fNYiVFM=
github.com/tulir/go-whatsapp v0.4.5/go.mod h1:rwwuTh1bKqhgrRvOBAr8hDqtuz8Cc1Quqw/0BeXb+/E= 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.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= 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= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=

View file

@ -633,7 +633,7 @@ func (user *User) HandleEvent(event interface{}) {
if portal != nil { if portal != nil {
go user.updateChatTag(nil, portal, user.bridge.Config.Bridge.PinnedTag, v.IsPinned) go user.updateChatTag(nil, portal, user.bridge.Config.Bridge.PinnedTag, v.IsPinned)
} }
case json.RawMessage: case whatsapp.RawJSONMessage:
user.HandleJSONMessage(v) user.HandleJSONMessage(v)
case *waProto.WebMessageInfo: case *waProto.WebMessageInfo:
user.updateLastConnectionIfNecessary() user.updateLastConnectionIfNecessary()
@ -1380,11 +1380,11 @@ func (user *User) HandleConnInfo(info whatsapp.ConnInfo) {
} }
} }
func (user *User) HandleJSONMessage(message json.RawMessage) { func (user *User) HandleJSONMessage(evt whatsapp.RawJSONMessage) {
if !json.Valid(message) { if !json.Valid(evt.RawMessage) {
return return
} }
user.log.Debugfln("JSON message: %s", message) user.log.Debugfln("JSON message with tag %s: %s", evt.Tag, evt.RawMessage)
user.updateLastConnectionIfNecessary() user.updateLastConnectionIfNecessary()
} }