From c6bcbb0a18e0b2eb16788f59e2535cd4a640ec57 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Wed, 5 Oct 2022 13:20:04 +0100 Subject: [PATCH] Don't 500 `/messages` if we can't apply history visibility correctly --- syncapi/routing/messages.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/syncapi/routing/messages.go b/syncapi/routing/messages.go index 8f3ed3f5b..c5ddcb7db 100644 --- a/syncapi/routing/messages.go +++ b/syncapi/routing/messages.go @@ -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") - 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)") + 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 }