Skip to content

Commit

Permalink
crypto/helper: allow overriding post-decrypt function
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Sep 12, 2024
1 parent d472be3 commit e16b681
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions crypto/cryptohelper/cryptohelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ type CryptoHelper struct {

LoginAs *mautrix.ReqLogin

ASEventProcessor crypto.ASEventProcessor
ASEventProcessor crypto.ASEventProcessor
CustomPostDecrypt func(context.Context, *event.Event)

DBAccountID string
}
Expand Down Expand Up @@ -320,7 +321,9 @@ func (helper *CryptoHelper) HandleEncrypted(ctx context.Context, evt *event.Even

func (helper *CryptoHelper) postDecrypt(ctx context.Context, decrypted *event.Event) {
decrypted.Mautrix.EventSource |= event.SourceDecrypted
if helper.ASEventProcessor != nil {
if helper.CustomPostDecrypt != nil {
helper.CustomPostDecrypt(ctx, decrypted)
} else if helper.ASEventProcessor != nil {
helper.ASEventProcessor.Dispatch(ctx, decrypted)
} else {
helper.client.Syncer.(mautrix.DispatchableSyncer).Dispatch(ctx, decrypted)
Expand Down

0 comments on commit e16b681

Please sign in to comment.