Add timeout for sending reactions and redactions

This commit is contained in:
Tulir Asokan 2023-11-14 16:27:55 +02:00
parent 0c18f065aa
commit 71ab396c7a
3 changed files with 15 additions and 11 deletions

6
go.mod
View file

@ -11,15 +11,15 @@ require (
github.com/rs/zerolog v1.31.0
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
github.com/tidwall/gjson v1.17.0
go.mau.fi/util v0.2.0
go.mau.fi/util v0.2.1-0.20231114144345-a692409c548f
go.mau.fi/webp v0.1.0
go.mau.fi/whatsmeow v0.0.0-20231112141858-68b25b3f6fe9
go.mau.fi/whatsmeow v0.0.0-20231114143452-e8fa5b64d278
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa
golang.org/x/image v0.14.0
golang.org/x/net v0.18.0
google.golang.org/protobuf v1.31.0
maunium.net/go/maulogger/v2 v2.4.1
maunium.net/go/mautrix v0.16.2-0.20231112104921-da5a51a279a7
maunium.net/go/mautrix v0.16.2-0.20231114144505-09daa655758e
)
require (

12
go.sum
View file

@ -64,12 +64,12 @@ github.com/yuin/goldmark v1.6.0 h1:boZcn2GTjpsynOsC0iJHnBWa4Bi0qzfJjthwauItG68=
github.com/yuin/goldmark v1.6.0/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
go.mau.fi/libsignal v0.1.0 h1:vAKI/nJ5tMhdzke4cTK1fb0idJzz1JuEIpmjprueC+c=
go.mau.fi/libsignal v0.1.0/go.mod h1:R8ovrTezxtUNzCQE5PH30StOQWWeBskBsWE55vMfY9I=
go.mau.fi/util v0.2.0 h1:AMGBEdg9Ya/smb/09dljo9wBwKr432EpfjDWF7aFQg0=
go.mau.fi/util v0.2.0/go.mod h1:AxuJUMCxpzgJ5eV9JbPWKRH8aAJJidxetNdUj7qcb84=
go.mau.fi/util v0.2.1-0.20231114144345-a692409c548f h1:mJhRlbk3AStG2XfKe1MuO2rmikjUPLcO0pglA+GlWuA=
go.mau.fi/util v0.2.1-0.20231114144345-a692409c548f/go.mod h1:MjlzCQEMzJ+G8RsPawHzpLB8rwTo3aPIjG5FzBvQT/c=
go.mau.fi/webp v0.1.0 h1:BHObH/DcFntT9KYun5pDr0Ot4eUZO8k2C7eP7vF4ueA=
go.mau.fi/webp v0.1.0/go.mod h1:e42Z+VMFrUMS9cpEwGRIor+lQWO8oUAyPyMtcL+NMt8=
go.mau.fi/whatsmeow v0.0.0-20231112141858-68b25b3f6fe9 h1:KKiSWzaGPCaf9L0cmpuAkJB2ELccBVol2yHzSW5JE6I=
go.mau.fi/whatsmeow v0.0.0-20231112141858-68b25b3f6fe9/go.mod h1:u557d2vph8xcLrk3CKTBknUHoB6icUpqazA4w+binRU=
go.mau.fi/whatsmeow v0.0.0-20231114143452-e8fa5b64d278 h1:oauy+pDJoTbrzwk00+xqb01FUJ2etQGweIoiAvQK1JU=
go.mau.fi/whatsmeow v0.0.0-20231114143452-e8fa5b64d278/go.mod h1:u557d2vph8xcLrk3CKTBknUHoB6icUpqazA4w+binRU=
go.mau.fi/zeroconfig v0.1.2 h1:DKOydWnhPMn65GbXZOafgkPm11BvFashZWLct0dGFto=
go.mau.fi/zeroconfig v0.1.2/go.mod h1:NcSJkf180JT+1IId76PcMuLTNa1CzsFFZ0nBygIQM70=
golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA=
@ -103,5 +103,5 @@ maunium.net/go/mauflag v1.0.0 h1:YiaRc0tEI3toYtJMRIfjP+jklH45uDHtT80nUamyD4M=
maunium.net/go/mauflag v1.0.0/go.mod h1:nLivPOpTpHnpzEh8jEdSL9UqO9+/KBJFmNRlwKfkPeA=
maunium.net/go/maulogger/v2 v2.4.1 h1:N7zSdd0mZkB2m2JtFUsiGTQQAdP0YeFWT7YMc80yAL8=
maunium.net/go/maulogger/v2 v2.4.1/go.mod h1:omPuYwYBILeVQobz8uO3XC8DIRuEb5rXYlQSuqrbCho=
maunium.net/go/mautrix v0.16.2-0.20231112104921-da5a51a279a7 h1:et04LrG55EM3vZucOJPu/VzO9b03sKHbTZyHEHThA6A=
maunium.net/go/mautrix v0.16.2-0.20231112104921-da5a51a279a7/go.mod h1:fqEsPvpfZqvLvmwaZFm/6W8fD5SLzrMwZbTga+dVP/g=
maunium.net/go/mautrix v0.16.2-0.20231114144505-09daa655758e h1:qoKoP99Aa+FvzZecO3R5efV87b7HmMsr1QPsw7lEIpw=
maunium.net/go/mautrix v0.16.2-0.20231114144505-09daa655758e/go.mod h1:Q7tbypaya4C9JVIjPXhEgeU8puotXRrX4hJvTLGNlLQ=

View file

@ -4659,7 +4659,9 @@ func (portal *Portal) sendReactionToWhatsApp(sender *User, id types.MessageID, t
messageKeyParticipant = proto.String(target.Sender.ToNonAD().String())
}
key = variationselector.Remove(key)
return sender.Client.SendMessage(context.TODO(), portal.Key.JID, &waProto.Message{
ctx, cancel := context.WithTimeout(context.TODO(), 60*time.Second)
defer cancel()
return sender.Client.SendMessage(ctx, portal.Key.JID, &waProto.Message{
ReactionMessage: &waProto.ReactionMessage{
Key: &waProto.MessageKey{
RemoteJid: proto.String(portal.Key.JID.String()),
@ -4745,7 +4747,9 @@ func (portal *Portal) HandleMatrixRedaction(sender *User, evt *event.Event) {
key.Participant = proto.String(msg.Sender.ToNonAD().String())
}
portal.log.Debugfln("Sending redaction %s of %s/%s to WhatsApp", evt.ID, msg.MXID, msg.JID)
_, err := sender.Client.SendMessage(context.TODO(), portal.Key.JID, &waProto.Message{
ctx, cancel := context.WithTimeout(context.TODO(), 60*time.Second)
defer cancel()
_, err := sender.Client.SendMessage(ctx, portal.Key.JID, &waProto.Message{
ProtocolMessage: &waProto.ProtocolMessage{
Type: waProto.ProtocolMessage_REVOKE.Enum(),
Key: key,