mirror of
https://github.com/tulir/mautrix-whatsapp
synced 2024-12-14 09:23:51 +01:00
Improve post-reconnection resending and fix potential encryption races
This commit is contained in:
parent
337ca45749
commit
0e3bf04daf
3 changed files with 7 additions and 1 deletions
2
go.mod
2
go.mod
|
@ -16,4 +16,4 @@ require (
|
|||
maunium.net/go/mautrix v0.8.4
|
||||
)
|
||||
|
||||
replace github.com/Rhymen/go-whatsapp => github.com/tulir/go-whatsapp v0.4.0-rc.2.0.20210225122703-9332bfd1058f
|
||||
replace github.com/Rhymen/go-whatsapp => github.com/tulir/go-whatsapp v0.4.0-rc.2.0.20210225152147-6bc95e2c807b
|
||||
|
|
2
go.sum
2
go.sum
|
@ -307,6 +307,8 @@ github.com/tulir/go-whatsapp v0.4.0-rc.2.0.20210225114646-8538575a439d h1:qvuNKX
|
|||
github.com/tulir/go-whatsapp v0.4.0-rc.2.0.20210225114646-8538575a439d/go.mod h1:rwwuTh1bKqhgrRvOBAr8hDqtuz8Cc1Quqw/0BeXb+/E=
|
||||
github.com/tulir/go-whatsapp v0.4.0-rc.2.0.20210225122703-9332bfd1058f h1:3/OXcaPXdDRfnj8X29JfSfSdkSNVt2n+qzrJQSlFaqY=
|
||||
github.com/tulir/go-whatsapp v0.4.0-rc.2.0.20210225122703-9332bfd1058f/go.mod h1:rwwuTh1bKqhgrRvOBAr8hDqtuz8Cc1Quqw/0BeXb+/E=
|
||||
github.com/tulir/go-whatsapp v0.4.0-rc.2.0.20210225152147-6bc95e2c807b h1:1RezMfaShkQGGygQc+/ICFKYUPTPc1Dp25uTYEtSDVI=
|
||||
github.com/tulir/go-whatsapp v0.4.0-rc.2.0.20210225152147-6bc95e2c807b/go.mod h1:rwwuTh1bKqhgrRvOBAr8hDqtuz8Cc1Quqw/0BeXb+/E=
|
||||
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=
|
||||
|
|
|
@ -171,6 +171,7 @@ type Portal struct {
|
|||
log log.Logger
|
||||
|
||||
roomCreateLock sync.Mutex
|
||||
encryptLock sync.Mutex
|
||||
|
||||
recentlyHandled [recentlyHandledLength]whatsapp.MessageID
|
||||
recentlyHandledLock sync.Mutex
|
||||
|
@ -1305,7 +1306,10 @@ func (portal *Portal) sendMessageDirect(intent *appservice.IntentAPI, eventType
|
|||
}
|
||||
}
|
||||
if portal.Encrypted && portal.bridge.Crypto != nil {
|
||||
// TODO maybe the locking should be inside mautrix-go?
|
||||
portal.encryptLock.Lock()
|
||||
encrypted, err := portal.bridge.Crypto.Encrypt(portal.MXID, eventType, wrappedContent)
|
||||
portal.encryptLock.Unlock()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to encrypt event: %w", err)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue