Remove checks on SyncAPI consumer

This commit is contained in:
Till Faelligen 2022-10-05 11:05:11 +02:00
parent 6925e1f2d6
commit c0299825c4
No known key found for this signature in database
GPG key ID: 3DF82D8AB9211D4E

View file

@ -93,23 +93,6 @@ func (s *OutputRoomEventConsumer) Start() error {
// sync stream position may race and be incorrectly calculated. // sync stream position may race and be incorrectly calculated.
func (s *OutputRoomEventConsumer) onMessage(ctx context.Context, msgs []*nats.Msg) bool { func (s *OutputRoomEventConsumer) onMessage(ctx context.Context, msgs []*nats.Msg) bool {
msg := msgs[0] // Guaranteed to exist if onMessage is called msg := msgs[0] // Guaranteed to exist if onMessage is called
receivedType := api.OutputType(msg.Header.Get(jetstream.RoomEventType))
ok := false
// Only handle events we care about
for _, eventType := range api.OutputTypes {
if receivedType == eventType {
ok = true
break
}
}
if !ok {
log.WithField("type", receivedType).Debug(
"roomserver output log: ignoring unknown output type",
)
return true
}
// Parse out the event JSON // Parse out the event JSON
var err error var err error
var output api.OutputEvent var output api.OutputEvent
@ -119,7 +102,7 @@ func (s *OutputRoomEventConsumer) onMessage(ctx context.Context, msgs []*nats.Ms
return true return true
} }
switch receivedType { switch output.Type {
case api.OutputTypeNewRoomEvent: case api.OutputTypeNewRoomEvent:
// Ignore redaction events. We will add them to the database when they are // Ignore redaction events. We will add them to the database when they are
// validated (when we receive OutputTypeRedactedEvent) // validated (when we receive OutputTypeRedactedEvent)