aboutsummaryrefslogtreecommitdiff
path: root/syncapi/consumers
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2022-10-13 14:50:52 +0100
committerGitHub <noreply@github.com>2022-10-13 14:50:52 +0100
commit23a3e04579172de89266e9554428b71172c58495 (patch)
treed1a03b1be93f55fffc799bf395be9ba7ccf7b3da /syncapi/consumers
parent3c1474f68f2ac5e564d2bd4bd15f01d2a73f2845 (diff)
Event relations (#2790)
This adds support for tracking `m.relates_to`, as well as adding support for the various `/room/{roomID}/relations/...` endpoints to the CS API.
Diffstat (limited to 'syncapi/consumers')
-rw-r--r--syncapi/consumers/roomserver.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/syncapi/consumers/roomserver.go b/syncapi/consumers/roomserver.go
index c7a11dbb..cfbb0532 100644
--- a/syncapi/consumers/roomserver.go
+++ b/syncapi/consumers/roomserver.go
@@ -148,6 +148,16 @@ func (s *OutputRoomEventConsumer) onRedactEvent(
log.WithError(err).Error("RedactEvent error'd")
return err
}
+
+ if err = s.db.RedactRelations(ctx, msg.RedactedBecause.RoomID(), msg.RedactedEventID); err != nil {
+ log.WithFields(log.Fields{
+ "room_id": msg.RedactedBecause.RoomID(),
+ "event_id": msg.RedactedBecause.EventID(),
+ "redacted_event_id": msg.RedactedEventID,
+ }).WithError(err).Warn("Failed to redact relations")
+ return err
+ }
+
// fake a room event so we notify clients about the redaction, as if it were
// a normal event.
return s.onNewRoomEvent(ctx, api.OutputNewRoomEvent{
@@ -271,6 +281,14 @@ func (s *OutputRoomEventConsumer) onNewRoomEvent(
return err
}
+ if err = s.db.UpdateRelations(ctx, ev); err != nil {
+ log.WithFields(log.Fields{
+ "event_id": ev.EventID(),
+ "type": ev.Type(),
+ }).WithError(err).Warn("Failed to update relations")
+ return err
+ }
+
s.pduStream.Advance(pduPos)
s.notifier.OnNewEvent(ev, ev.RoomID(), nil, types.StreamingToken{PDUPosition: pduPos})
@@ -315,6 +333,15 @@ func (s *OutputRoomEventConsumer) onOldRoomEvent(
}).WithError(err).Warn("failed to index fulltext element")
}
+ if err = s.db.UpdateRelations(ctx, ev); err != nil {
+ log.WithFields(log.Fields{
+ "room_id": ev.RoomID(),
+ "event_id": ev.EventID(),
+ "type": ev.Type(),
+ }).WithError(err).Warn("Failed to update relations")
+ return err
+ }
+
if pduPos, err = s.notifyJoinedPeeks(ctx, ev, pduPos); err != nil {
log.WithError(err).Errorf("Failed to notifyJoinedPeeks for PDU pos %d", pduPos)
return err