aboutsummaryrefslogtreecommitdiff
path: root/syncapi
diff options
context:
space:
mode:
authorTill <2353100+S7evinK@users.noreply.github.com>2022-08-19 11:04:26 +0200
committerGitHub <noreply@github.com>2022-08-19 11:04:26 +0200
commit365da70a23cec9595a2854ed47f970f03cfde0a9 (patch)
tree1d195baf279bf0707ea8ac079ce1f8df519ed3f3 /syncapi
parent5cacca92d2b888d022f9fa346b8068ce13087b00 (diff)
Set historyVisibility for backfilled events over federation (#2656)
This should hopefully deflake Backfill works correctly with history visibility set to joined as we were using the default shared visibility, even if the events are set to joined (or something else)
Diffstat (limited to 'syncapi')
-rw-r--r--syncapi/routing/messages.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/syncapi/routing/messages.go b/syncapi/routing/messages.go
index 9db3d8e1..03614302 100644
--- a/syncapi/routing/messages.go
+++ b/syncapi/routing/messages.go
@@ -350,8 +350,10 @@ func (r *messagesReq) retrieveEvents() (
startTime := time.Now()
filteredEvents, err := internal.ApplyHistoryVisibilityFilter(r.ctx, r.db, r.rsAPI, events, nil, r.device.UserID, "messages")
logrus.WithFields(logrus.Fields{
- "duration": time.Since(startTime),
- "room_id": r.roomID,
+ "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
}
@@ -513,6 +515,9 @@ func (r *messagesReq) backfill(roomID string, backwardsExtremities map[string][]
// Store the events in the database, while marking them as unfit to show
// up in responses to sync requests.
+ if res.HistoryVisibility == "" {
+ res.HistoryVisibility = gomatrixserverlib.HistoryVisibilityShared
+ }
for i := range res.Events {
_, err = r.db.WriteEvent(
context.Background(),
@@ -521,7 +526,7 @@ func (r *messagesReq) backfill(roomID string, backwardsExtremities map[string][]
[]string{},
[]string{},
nil, true,
- gomatrixserverlib.HistoryVisibilityShared,
+ res.HistoryVisibility,
)
if err != nil {
return nil, err
@@ -534,6 +539,9 @@ func (r *messagesReq) backfill(roomID string, backwardsExtremities map[string][]
// last `limit` events
events = events[len(events)-limit:]
}
+ for _, ev := range events {
+ ev.Visibility = res.HistoryVisibility
+ }
return events, nil
}