mirror of
https://github.com/tulir/mautrix-whatsapp
synced 2024-09-29 13:08:55 +02:00
Fix panic and double puppeting
This commit is contained in:
parent
be3fd24e9a
commit
b45e6b29f5
4 changed files with 8 additions and 14 deletions
4
go.mod
4
go.mod
|
@ -8,7 +8,7 @@ require (
|
||||||
github.com/mattn/go-sqlite3 v1.14.9
|
github.com/mattn/go-sqlite3 v1.14.9
|
||||||
github.com/prometheus/client_golang v1.11.0
|
github.com/prometheus/client_golang v1.11.0
|
||||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
|
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
|
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d
|
||||||
google.golang.org/protobuf v1.27.1
|
google.golang.org/protobuf v1.27.1
|
||||||
gopkg.in/yaml.v2 v2.4.0
|
gopkg.in/yaml.v2 v2.4.0
|
||||||
|
@ -33,7 +33,7 @@ require (
|
||||||
github.com/tidwall/match v1.0.3 // indirect
|
github.com/tidwall/match v1.0.3 // indirect
|
||||||
github.com/tidwall/pretty v1.0.2 // indirect
|
github.com/tidwall/pretty v1.0.2 // indirect
|
||||||
github.com/tidwall/sjson v1.1.5 // 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/crypto v0.0.0-20210921155107-089bfa567519 // indirect
|
||||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 // indirect
|
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 // indirect
|
||||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 // indirect
|
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 // indirect
|
||||||
|
|
8
go.sum
8
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/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 h1:wsUceI/XDyZk3J1FUvuuYlK62zJv2HO2Pzb8A5EWdUE=
|
||||||
github.com/tidwall/sjson v1.1.5/go.mod h1:VuJzsZnTowhSxWdOgsAnb886i4AjEyTkk7tNtsL7EYE=
|
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-20211024113310-f9fc6a1855f2 h1:xpQTMgJGGaF+c8jV/LA/FVXAPJxZbSAGeflOc+Ly6uQ=
|
||||||
go.mau.fi/libsignal v0.0.0-20211016130347-464152efc488/go.mod h1:3XlVlwOfp8f9Wri+C1D4ORqgUsN4ZvunJOoPjQMBhos=
|
go.mau.fi/libsignal v0.0.0-20211024113310-f9fc6a1855f2/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-20211024175202-609be38a9f28 h1:BP4f/gLWTjefHYeTHcUybEJelp57rWkV27kpUC64GsY=
|
||||||
go.mau.fi/whatsmeow v0.0.0-20211022173833-7ca02c1a1895/go.mod h1:GJl+Pfu5TEvDM+lXG/PnX9/yMf6vEMwD8HC4Nq75Vhg=
|
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-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-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
|
|
|
@ -1770,7 +1770,7 @@ func (portal *Portal) HandleMediaMessage(source *User, info *types.MessageInfo,
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(msgWithThumbnail.GetCaption()) > 0 {
|
if msgWithThumbnail != nil && len(msgWithThumbnail.GetCaption()) > 0 {
|
||||||
captionContent := &event.MessageEventContent{
|
captionContent := &event.MessageEventContent{
|
||||||
Body: msgWithThumbnail.GetCaption(),
|
Body: msgWithThumbnail.GetCaption(),
|
||||||
MsgType: event.MsgNotice,
|
MsgType: event.MsgNotice,
|
||||||
|
|
8
user.go
8
user.go
|
@ -287,13 +287,6 @@ func (user *User) IsLoggedIn() bool {
|
||||||
return user.Client != nil && user.Client.IsConnected() && user.Client.IsLoggedIn
|
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() {
|
func (user *User) tryAutomaticDoublePuppeting() {
|
||||||
if !user.bridge.Config.CanDoublePuppet(user.MXID) {
|
if !user.bridge.Config.CanDoublePuppet(user.MXID) {
|
||||||
return
|
return
|
||||||
|
@ -351,6 +344,7 @@ func (user *User) HandleEvent(event interface{}) {
|
||||||
user.log.Warnln("Failed to send initial presence:", err)
|
user.log.Warnln("Failed to send initial presence:", err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
go user.tryAutomaticDoublePuppeting()
|
||||||
case *events.PairSuccess:
|
case *events.PairSuccess:
|
||||||
user.JID = v.ID
|
user.JID = v.ID
|
||||||
user.addToJIDMap()
|
user.addToJIDMap()
|
||||||
|
|
Loading…
Reference in a new issue