Skip to content

Commit

Permalink
signalmeow: don't use embedded pointers in SendMessageResult
Browse files Browse the repository at this point in the history
Fixes #533
  • Loading branch information
tulir committed Aug 17, 2024
1 parent 49831b6 commit 39b408d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
2 changes: 1 addition & 1 deletion pkg/connector/handlematrix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
18 changes: 9 additions & 9 deletions pkg/signalmeow/sending.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,8 @@ type FailedSendResult struct {
}
type SendMessageResult struct {
WasSuccessful bool
*SuccessfulSendResult
*FailedSendResult
SuccessfulSendResult
FailedSendResult
}
type GroupMessageSendResult struct {
SuccessfullySentTo []SuccessfulSendResult
Expand Down Expand Up @@ -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,
Expand All @@ -743,15 +743,15 @@ 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,
},
}
}
result := SendMessageResult{
WasSuccessful: true,
SuccessfulSendResult: &SuccessfulSendResult{
SuccessfulSendResult: SuccessfulSendResult{
Recipient: recipientID,
Unidentified: sentUnidentified,
},
Expand All @@ -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
}
Expand Down

0 comments on commit 39b408d

Please sign in to comment.