Call before dispatch for group chat messages
This commit is contained in:
parent
db56132d01
commit
d91d11a01c
2
go.mod
2
go.mod
|
@ -64,7 +64,7 @@ require (
|
|||
go.uber.org/zap v1.24.0
|
||||
golang.org/x/crypto v0.7.0
|
||||
golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb
|
||||
google.golang.org/protobuf v1.30.1-0.20230508203708-b8fc77060104 // indirect
|
||||
google.golang.org/protobuf v1.30.1-0.20230508203708-b8fc77060104
|
||||
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
|
||||
gopkg.in/go-playground/validator.v9 v9.31.0
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0
|
||||
|
|
|
@ -211,6 +211,15 @@ func (s *MessageSender) SendGroup(
|
|||
messageID := v1protocol.MessageID(&rawMessage.Sender.PublicKey, wrappedMessage)
|
||||
rawMessage.ID = types.EncodeHex(messageID)
|
||||
|
||||
// We call it only once, and we nil the function after so it doesn't get called again
|
||||
if rawMessage.BeforeDispatch != nil {
|
||||
if err := rawMessage.BeforeDispatch(&rawMessage); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
rawMessage.BeforeDispatch = nil
|
||||
|
||||
// Send to each recipients
|
||||
for _, recipient := range recipients {
|
||||
_, err = s.sendPrivate(ctx, recipient, &rawMessage)
|
||||
|
|
Loading…
Reference in New Issue