From b45e6b29f5cda7ca27bb43728d45cb8eae1b655b Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Mon, 25 Oct 2021 18:31:37 +0300 Subject: [PATCH] Fix panic and double puppeting --- go.mod | 4 ++-- go.sum | 8 ++++---- portal.go | 2 +- user.go | 8 +------- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/go.mod b/go.mod index 96ecfde..8221610 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/mattn/go-sqlite3 v1.14.9 github.com/prometheus/client_golang v1.11.0 github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e - go.mau.fi/whatsmeow v0.0.0-20211022173833-7ca02c1a1895 + go.mau.fi/whatsmeow v0.0.0-20211024175202-609be38a9f28 golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d google.golang.org/protobuf v1.27.1 gopkg.in/yaml.v2 v2.4.0 @@ -33,7 +33,7 @@ require ( github.com/tidwall/match v1.0.3 // indirect github.com/tidwall/pretty v1.0.2 // indirect github.com/tidwall/sjson v1.1.5 // indirect - go.mau.fi/libsignal v0.0.0-20211016130347-464152efc488 // indirect + go.mau.fi/libsignal v0.0.0-20211024113310-f9fc6a1855f2 // indirect golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 // indirect golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 // indirect diff --git a/go.sum b/go.sum index 653cb79..7037b9f 100644 --- a/go.sum +++ b/go.sum @@ -139,10 +139,10 @@ github.com/tidwall/pretty v1.0.2 h1:Z7S3cePv9Jwm1KwS0513MRaoUe3S01WPbLNV40pwWZU= github.com/tidwall/pretty v1.0.2/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tidwall/sjson v1.1.5 h1:wsUceI/XDyZk3J1FUvuuYlK62zJv2HO2Pzb8A5EWdUE= github.com/tidwall/sjson v1.1.5/go.mod h1:VuJzsZnTowhSxWdOgsAnb886i4AjEyTkk7tNtsL7EYE= -go.mau.fi/libsignal v0.0.0-20211016130347-464152efc488 h1:dIOtV7Fl8bxdOOvBndilSmWFcufBArgq2sZJOqV3Enc= -go.mau.fi/libsignal v0.0.0-20211016130347-464152efc488/go.mod h1:3XlVlwOfp8f9Wri+C1D4ORqgUsN4ZvunJOoPjQMBhos= -go.mau.fi/whatsmeow v0.0.0-20211022173833-7ca02c1a1895 h1:m6Ru2ZDMk+C6/TIUtm8drR1cxoOpERCKyBnbfr0vLYo= -go.mau.fi/whatsmeow v0.0.0-20211022173833-7ca02c1a1895/go.mod h1:GJl+Pfu5TEvDM+lXG/PnX9/yMf6vEMwD8HC4Nq75Vhg= +go.mau.fi/libsignal v0.0.0-20211024113310-f9fc6a1855f2 h1:xpQTMgJGGaF+c8jV/LA/FVXAPJxZbSAGeflOc+Ly6uQ= +go.mau.fi/libsignal v0.0.0-20211024113310-f9fc6a1855f2/go.mod h1:3XlVlwOfp8f9Wri+C1D4ORqgUsN4ZvunJOoPjQMBhos= +go.mau.fi/whatsmeow v0.0.0-20211024175202-609be38a9f28 h1:BP4f/gLWTjefHYeTHcUybEJelp57rWkV27kpUC64GsY= +go.mau.fi/whatsmeow v0.0.0-20211024175202-609be38a9f28/go.mod h1:8FQjyDWAghfKYj9xTAxS23PQwlhjr2cgEGm9rfSA+cg= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= diff --git a/portal.go b/portal.go index 238f8f3..1eb0189 100644 --- a/portal.go +++ b/portal.go @@ -1770,7 +1770,7 @@ func (portal *Portal) HandleMediaMessage(source *User, info *types.MessageInfo, return true } - if len(msgWithThumbnail.GetCaption()) > 0 { + if msgWithThumbnail != nil && len(msgWithThumbnail.GetCaption()) > 0 { captionContent := &event.MessageEventContent{ Body: msgWithThumbnail.GetCaption(), MsgType: event.MsgNotice, diff --git a/user.go b/user.go index d907008..a046a0a 100644 --- a/user.go +++ b/user.go @@ -287,13 +287,6 @@ func (user *User) IsLoggedIn() bool { return user.Client != nil && user.Client.IsConnected() && user.Client.IsLoggedIn } -func (user *User) PostLogin() { - user.sendBridgeState(BridgeState{StateEvent: StateConnected}) - user.bridge.Metrics.TrackConnectionState(user.JID, true) - user.bridge.Metrics.TrackLoginState(user.JID, true) - go user.tryAutomaticDoublePuppeting() -} - func (user *User) tryAutomaticDoublePuppeting() { if !user.bridge.Config.CanDoublePuppet(user.MXID) { return @@ -351,6 +344,7 @@ func (user *User) HandleEvent(event interface{}) { user.log.Warnln("Failed to send initial presence:", err) } }() + go user.tryAutomaticDoublePuppeting() case *events.PairSuccess: user.JID = v.ID user.addToJIDMap()