mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-08-01 13:52:46 +00:00
Implement core redaction logic (#1185)
* Implement core redaction logic - Add a new `redactions_table.go` which tracks the mapping of the redaction event ID and the redacted event ID - Mark redactions as 'validated' when we have both events. - When redactions are validated, add `unsigned.redacted_because` and modify the `eventJSON` accordingly. Note: We currently do NOT redact the event content - it's gated behind a feature flag - until we have tested redactions a bit more. * Linting
This commit is contained in:
parent
65084c5052
commit
52c77cb4b4
8 changed files with 414 additions and 4 deletions
|
@ -14,6 +14,7 @@ type EventJSONPair struct {
|
|||
}
|
||||
|
||||
type EventJSON interface {
|
||||
// Insert the event JSON. On conflict, replace the event JSON with the new value (for redactions).
|
||||
InsertEventJSON(ctx context.Context, tx *sql.Tx, eventNID types.EventNID, eventJSON []byte) error
|
||||
BulkSelectEventJSON(ctx context.Context, eventNIDs []types.EventNID) ([]EventJSONPair, error)
|
||||
}
|
||||
|
@ -126,3 +127,23 @@ type Published interface {
|
|||
SelectPublishedFromRoomID(ctx context.Context, roomID string) (published bool, err error)
|
||||
SelectAllPublishedRooms(ctx context.Context, published bool) ([]string, error)
|
||||
}
|
||||
|
||||
type RedactionInfo struct {
|
||||
// whether this redaction is validated (we have both events)
|
||||
Validated bool
|
||||
// the ID of the event being redacted
|
||||
RedactsEventID string
|
||||
// the ID of the redaction event
|
||||
RedactionEventID string
|
||||
}
|
||||
|
||||
type Redactions interface {
|
||||
InsertRedaction(ctx context.Context, txn *sql.Tx, info RedactionInfo) error
|
||||
// SelectRedactedEvent returns the redaction info for the given redaction event ID, or nil if there is no match.
|
||||
SelectRedactedEvent(ctx context.Context, txn *sql.Tx, redactionEventID string) (*RedactionInfo, error)
|
||||
// SelectRedactionEvent returns the redaction info for the given redacted event ID, or nil if there is no match.
|
||||
SelectRedactionEvent(ctx context.Context, txn *sql.Tx, redactedEventID string) (*RedactionInfo, error)
|
||||
// Mark this redaction event as having been validated. This means we have both sides of the redaction and have
|
||||
// successfully redacted the event JSON.
|
||||
MarkRedactionValidated(ctx context.Context, txn *sql.Tx, redactionEventID string, validated bool) error
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue