mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-29 12:42:46 +00:00
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.
This commit is contained in:
parent
3c1474f68f
commit
23a3e04579
19 changed files with 943 additions and 51 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue