mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-08-02 06:12:45 +00:00
Finish implementing redactions (#1189)
* Add a bit more logging to the fedsender * bugfix: continue sending PDUs if ones are added whilst sending another PDU Without this, the queue goes back to sleep on `<-oq.notifyPDUs` which won't fire because `pendingPDUs` is already > 0. This should fix a flakey sytest. * Break if no txn is sent * WIP syncapi work * More debugging * Bump GMSL version to pull in working Event.Redact * Remove logging * Make redactions work on v3+ * Fix more tests
This commit is contained in:
parent
a5a51b4141
commit
d9648b0615
14 changed files with 131 additions and 25 deletions
|
@ -24,6 +24,7 @@ import (
|
|||
userapi "github.com/matrix-org/dendrite/userapi/api"
|
||||
|
||||
"github.com/matrix-org/dendrite/eduserver/cache"
|
||||
"github.com/matrix-org/dendrite/internal/eventutil"
|
||||
"github.com/matrix-org/dendrite/internal/sqlutil"
|
||||
"github.com/matrix-org/dendrite/roomserver/api"
|
||||
"github.com/matrix-org/dendrite/syncapi/storage/tables"
|
||||
|
@ -597,6 +598,26 @@ func (d *Database) IncrementalSync(
|
|||
return res, nil
|
||||
}
|
||||
|
||||
func (d *Database) RedactEvent(ctx context.Context, redactedEventID string, redactedBecause *gomatrixserverlib.HeaderedEvent) error {
|
||||
redactedEvents, err := d.Events(ctx, []string{redactedEventID})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(redactedEvents) == 0 {
|
||||
logrus.WithField("event_id", redactedEventID).WithField("redaction_event", redactedBecause.EventID()).Warnf("missing redacted event for redaction")
|
||||
return nil
|
||||
}
|
||||
eventToRedact := redactedEvents[0].Unwrap()
|
||||
redactionEvent := redactedBecause.Unwrap()
|
||||
ev, err := eventutil.RedactEvent(&redactionEvent, &eventToRedact)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
newEvent := ev.Headered(redactedBecause.RoomVersion)
|
||||
return d.OutputEvents.UpdateEventJSON(ctx, &newEvent)
|
||||
}
|
||||
|
||||
// getResponseWithPDUsForCompleteSync creates a response and adds all PDUs needed
|
||||
// to it. It returns toPos and joinedRoomIDs for use of adding EDUs.
|
||||
// nolint:nakedret
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue