From 39b408ddf147bfdc1c3673e1c9241e97d63dba10 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Sat, 17 Aug 2024 14:13:39 +0300 Subject: [PATCH] signalmeow: don't use embedded pointers in SendMessageResult Fixes #533 --- go.mod | 2 +- go.sum | 4 ++-- pkg/connector/handlematrix.go | 2 +- pkg/signalmeow/sending.go | 18 +++++++++--------- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/go.mod b/go.mod index e6f6a8ec..3ea65bd2 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa golang.org/x/net v0.28.0 google.golang.org/protobuf v1.34.2 - maunium.net/go/mautrix v0.20.0 + maunium.net/go/mautrix v0.20.1-0.20240817111253-2355d70426f4 nhooyr.io/websocket v1.8.17 ) diff --git a/go.sum b/go.sum index c9c1c81a..3cabb480 100644 --- a/go.sum +++ b/go.sum @@ -90,7 +90,7 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 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/mautrix v0.20.0 h1:bzQnVQR+LvQxV1YlAr7BSWCS8AWa0Ov0lyPhbbChM0o= -maunium.net/go/mautrix v0.20.0/go.mod h1:V725r8w7oddsS7CxnmTAp634A4nwJCFY7J3jiTMUz2c= +maunium.net/go/mautrix v0.20.1-0.20240817111253-2355d70426f4 h1:S4+mHwQC2CiCTl0cn21zd4V8JiqGYMYlsde2v7jC8bE= +maunium.net/go/mautrix v0.20.1-0.20240817111253-2355d70426f4/go.mod h1:V725r8w7oddsS7CxnmTAp634A4nwJCFY7J3jiTMUz2c= nhooyr.io/websocket v1.8.17 h1:KEVeLJkUywCKVsnLIDlD/5gtayKp8VoCkksHCGGfT9Y= nhooyr.io/websocket v1.8.17/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c= diff --git a/pkg/connector/handlematrix.go b/pkg/connector/handlematrix.go index 888d702b..87cebe2a 100644 --- a/pkg/connector/handlematrix.go +++ b/pkg/connector/handlematrix.go @@ -247,7 +247,7 @@ func (s *SignalClient) HandleMatrixReadReceipt(ctx context.Context, receipt *bri result := s.Client.SendMessage(ctx, libsignalgo.NewACIServiceID(destination), signalmeow.ReadReceptMessageForTimestamps(messages)) cancel() if !result.WasSuccessful { - zerolog.Ctx(ctx).Err(result.FailedSendResult.Error). + zerolog.Ctx(ctx).Err(result.Error). Stringer("destination", destination). Uints64("message_ids", messages). Msg("Failed to send read receipt to Signal") diff --git a/pkg/signalmeow/sending.go b/pkg/signalmeow/sending.go index 053e3354..cc156c92 100644 --- a/pkg/signalmeow/sending.go +++ b/pkg/signalmeow/sending.go @@ -296,8 +296,8 @@ type FailedSendResult struct { } type SendMessageResult struct { WasSuccessful bool - *SuccessfulSendResult - *FailedSendResult + SuccessfulSendResult + FailedSendResult } type GroupMessageSendResult struct { SuccessfullySentTo []SuccessfulSendResult @@ -717,21 +717,21 @@ func (cli *Client) SendMessage(ctx context.Context, recipientID libsignalgo.Serv // Treat needs PNI signature as "this is a message request" and don't send receipts/typing if needsPNISignature && (content.TypingMessage != nil || content.ReceiptMessage != nil) { zerolog.Ctx(ctx).Debug().Msg("Not sending typing/receipt message to recipient as needs PNI signature flag is set") - res := &SuccessfulSendResult{Recipient: recipientID} + res := SuccessfulSendResult{Recipient: recipientID} if content.GetReceiptMessage().GetType() == signalpb.ReceiptMessage_READ { // Still send sync messages for read receipts - cli.sendSyncCopy(ctx, content, messageTimestamp, res) + cli.sendSyncCopy(ctx, content, messageTimestamp, &res) } return SendMessageResult{WasSuccessful: true, SuccessfulSendResult: res} } isDeliveryReceipt := content.ReceiptMessage != nil && content.GetReceiptMessage().GetType() == signalpb.ReceiptMessage_DELIVERY if recipientID == cli.Store.ACIServiceID() && !isDeliveryReceipt { - res := &SuccessfulSendResult{ + res := SuccessfulSendResult{ Recipient: recipientID, Unidentified: false, } - ok := cli.sendSyncCopy(ctx, content, messageTimestamp, res) + ok := cli.sendSyncCopy(ctx, content, messageTimestamp, &res) return SendMessageResult{ WasSuccessful: ok, SuccessfulSendResult: res, @@ -743,7 +743,7 @@ func (cli *Client) SendMessage(ctx context.Context, recipientID libsignalgo.Serv if err != nil { return SendMessageResult{ WasSuccessful: false, - FailedSendResult: &FailedSendResult{ + FailedSendResult: FailedSendResult{ Recipient: recipientID, Error: err, }, @@ -751,7 +751,7 @@ func (cli *Client) SendMessage(ctx context.Context, recipientID libsignalgo.Serv } result := SendMessageResult{ WasSuccessful: true, - SuccessfulSendResult: &SuccessfulSendResult{ + SuccessfulSendResult: SuccessfulSendResult{ Recipient: recipientID, Unidentified: sentUnidentified, }, @@ -768,7 +768,7 @@ func (cli *Client) SendMessage(ctx context.Context, recipientID libsignalgo.Serv } } - cli.sendSyncCopy(ctx, content, messageTimestamp, result.SuccessfulSendResult) + cli.sendSyncCopy(ctx, content, messageTimestamp, &result.SuccessfulSendResult) return result }