Don't 500 /messages if we can't apply history visibility correctly

This commit is contained in:
Neil Alexander 2022-10-05 13:20:04 +01:00
parent c85bc3434f
commit c6bcbb0a18
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944

View file

@ -362,13 +362,16 @@ func (r *messagesReq) retrieveEvents() (
// Apply room history visibility filter
startTime := time.Now()
filteredEvents, err := internal.ApplyHistoryVisibilityFilter(r.ctx, r.snapshot, r.rsAPI, events, nil, r.device.UserID, "messages")
filteredEvents := events
if filtered, ferr := internal.ApplyHistoryVisibilityFilter(r.ctx, r.snapshot, r.rsAPI, events, nil, r.device.UserID, "messages"); ferr == nil {
filteredEvents = filtered
logrus.WithFields(logrus.Fields{
"duration": time.Since(startTime),
"room_id": r.roomID,
"events_before": len(events),
"events_after": len(filteredEvents),
}).Debug("applied history visibility (messages)")
}
return gomatrixserverlib.HeaderedToClientEvents(filteredEvents, gomatrixserverlib.FormatAll), start, end, err
}