When searching for events from a given user, Draupnir has to call /messages in every single protected room. This is a very expensive operation, and on homeservers with less resources can prevent Draupnir from redacting harmful messages when the operation takes too long. A timeline cache of visible events would allow Draupnir and protections to cheaply scan and locate events matching arbitrary criteria.
As an matrix-protection-suite protection developer, I can access a cache of the most recent events in the room timeline and scan them for harmful content or rescan them as state is changed (e.g. new policies are issued, protection config changes). Extensible Events (MSC1767) provides new ways to embed media onto any event within the room timeline. This means that there will be at least three ways to embed text content into a timeline event, and even more in the future. Therefore I need a single API to scan against all text and media embedded within an event, rather than having to manually destructure events adhoc in my protection. This will mean destructuring of events for scanning text content can be maintained in one place by the developers of the matrix-protection-suite and not repeated by protection developers improperly throughout their code. The same will need to apply for extracting images or other media from an event.
Acceptance Criteria
A timeline event cache is available to the protected rooms set that holds the most recent events for a room. Protections can access these events at any time.
An API exists for protection authors to either extract or scan against all text content within an event, without having to know the field names of extensible event fields.
A similar API exists for extracting all media that are embeddable in an event.
A default size for the cache per room should be calculated from visual space. That's to say how many screens an unprivileged Matrix user in a protected room is likely to scroll up in order to catch up on the ongoing chat context or give up. If no suitable value can be derived then just use 10 screens and make an issue to follow up.
All protections that scan or depend upon the timeline are rewritten to use the cache, and notably the RedactionSynchronisationProtection.
Issues
Dependencies
Total Pain
Will block redaction and bad phrase protection rework
Description
When searching for events from a given user, Draupnir has to call
/messages
in every single protected room. This is a very expensive operation, and on homeservers with less resources can prevent Draupnir from redacting harmful messages when the operation takes too long. A timeline cache of visible events would allow Draupnir and protections to cheaply scan and locate events matching arbitrary criteria.As an matrix-protection-suite protection developer, I can access a cache of the most recent events in the room timeline and scan them for harmful content or rescan them as state is changed (e.g. new policies are issued, protection config changes). Extensible Events (MSC1767) provides new ways to embed media onto any event within the room timeline. This means that there will be at least three ways to embed text content into a timeline event, and even more in the future. Therefore I need a single API to scan against all text and media embedded within an event, rather than having to manually destructure events adhoc in my protection. This will mean destructuring of events for scanning text content can be maintained in one place by the developers of the matrix-protection-suite and not repeated by protection developers improperly throughout their code. The same will need to apply for extracting images or other media from an event.
Acceptance Criteria
RedactionSynchronisationProtection
.Issues
Dependencies
Total Pain
Will block redaction and bad phrase protection rework