mirror of
https://mau.dev/mautrix/go.git
synced 2026-03-14 14:25:53 +01:00
bridgev2/networkinterface: add post-save callback for matrix messages
This commit is contained in:
parent
092ba65cad
commit
7a9269e8ff
2 changed files with 5 additions and 0 deletions
|
|
@ -284,6 +284,9 @@ type MatrixMessageResponse struct {
|
|||
// If RemovePending is set, the bridge will remove the provided transaction ID from pending messages
|
||||
// after saving the provided message to the database. This should be used with AddPendingToIgnore.
|
||||
RemovePending networkid.TransactionID
|
||||
// An optional function that is called after the message is saved to the database.
|
||||
// Will not be called if the message is not saved for some reason.
|
||||
PostSave func(context.Context, *database.Message)
|
||||
}
|
||||
|
||||
type FileRestriction struct {
|
||||
|
|
|
|||
|
|
@ -928,6 +928,8 @@ func (portal *Portal) handleMatrixMessage(ctx context.Context, sender *UserLogin
|
|||
err = portal.Bridge.DB.Message.Insert(ctx, message)
|
||||
if err != nil {
|
||||
log.Err(err).Msg("Failed to save message to database")
|
||||
} else if resp.PostSave != nil {
|
||||
resp.PostSave(ctx, message)
|
||||
}
|
||||
if resp.RemovePending != "" {
|
||||
portal.outgoingMessagesLock.Lock()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue