Add mx_extract_media_events() - #22
Merged
Merged
Conversation
The extractor family covered text and reactions but not media, so a consumer that wanted an image had to re-walk the raw sync and duplicate the msgtype filtering. This walks joined-room timelines for m.image/m.file/m.audio/m.video message events and returns normalized records: url filled from content$url or the encrypted content$file, sha256 surfaced from the encrypted file object (cleartext carries no hash), and the file object passed through verbatim, the relates_to treatment, since decrypting is the caller's business. Events with no address in either place are skipped: nothing fetchable, nothing to report.
# Conflicts: # DESCRIPTION
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The extractor family covers text (
mx_extract_text_events) and reactions (mx_extract_reactions) but not media, so a consumer that wants an image has to re-walk the raw sync and duplicate the msgtype filtering — which is exactly why chat.api's Matrix adapter reportsattachments = FALSEtoday.mx_extract_media_events(sync_resp, self_id)walks joined-room timelines form.image/m.file/m.audio/m.videomessage events and returns normalized records in the family's shape (room_id, event_id, sender, is_self, ts, mentions, relates_to), plus the media fields:urlfills fromcontent$url(cleartext) orcontent$file$url(encrypted), so a consumer that only wants the address reads one field.sha256surfaces from the encrypted file object; cleartext media carries no hash, so NULL there means unverified rather than fabricated.filerides verbatim (therelates_totreatment): decryption is the caller's business, and a partial view of key material helps no one.filename(MSC2530) is carried, withbodydocumented as filename-or-caption.m.stickeris a different event type and out of scope.216 tests pass, including cleartext/encrypted extraction, is_self tagging, the no-address skip, and empty/malformed syncs. Downstream: chat.api's Matrix adapter can now map these onto its new
chat_attachmentrecords and flipattachmentsto installed-version-gated, thereaction_eventspattern.