Move hook call when processing room events

This commit is contained in:
Neil Alexander 2022-01-28 11:47:43 +00:00
parent 2ea5fd4162
commit 2843d557c6
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
2 changed files with 4 additions and 6 deletions

View file

@ -25,7 +25,6 @@ import (
"github.com/Arceliar/phony"
"github.com/getsentry/sentry-go"
fedapi "github.com/matrix-org/dendrite/federationapi/api"
"github.com/matrix-org/dendrite/internal/hooks"
"github.com/matrix-org/dendrite/roomserver/acls"
"github.com/matrix-org/dendrite/roomserver/api"
"github.com/matrix-org/dendrite/roomserver/internal/query"
@ -105,8 +104,6 @@ func (r *Inputer) Start() error {
if !errors.Is(err, context.DeadlineExceeded) && !errors.Is(err, context.Canceled) {
sentry.CaptureException(err)
}
} else {
go hooks.Run(hooks.KindNewEventPersisted, inputRoomEvent.Event)
}
_ = msg.Ack()
})
@ -176,8 +173,6 @@ func (r *Inputer) InputRoomEvents(
if !errors.Is(err, context.DeadlineExceeded) && !errors.Is(err, context.Canceled) {
sentry.CaptureException(err)
}
} else {
go hooks.Run(hooks.KindNewEventPersisted, inputRoomEvent.Event)
}
select {
case <-ctx.Done():

View file

@ -25,6 +25,7 @@ import (
fedapi "github.com/matrix-org/dendrite/federationapi/api"
"github.com/matrix-org/dendrite/internal"
"github.com/matrix-org/dendrite/internal/eventutil"
"github.com/matrix-org/dendrite/internal/hooks"
"github.com/matrix-org/dendrite/roomserver/api"
"github.com/matrix-org/dendrite/roomserver/internal/helpers"
"github.com/matrix-org/dendrite/roomserver/state"
@ -321,7 +322,9 @@ func (r *Inputer) processRoomEvent(
}
}
// Update the extremities of the event graph for the room
// Everything was OK — the latest events updater didn't error and
// we've sent output events. Finally, generate a hook call.
hooks.Run(hooks.KindNewEventPersisted, event)
return nil
}