Repository navigation
Read pictures and encrypted messages in history - #33
Merged
Merged
Conversation
chat_send() and chat_edit() take content, a named list of keys for the message's own content, such as a namespaced "ai.cornball.agent" that one client reads and the rest ignore. Matrix adds them beside body and msgtype, in the cleartext path through mx_send() (as rich goes, since mx_send_text() takes no extra content, with the mentions, thread and markdown it would have built) and in the encrypted path as extra content inside the ciphertext. An edit puts them in m.new_content. A key chat.api writes itself is refused. Received, a cleartext message's raw now carries the event's whole content as raw$content, looked up from the sync by event id as the times are: mx_extract_text_events() keeps 6 fields and drops the rest. A decrypted record has content already, and history's raw is the event, so raw$content reads the same on all 3. The loopback adapter records the keys there too; the other adapters take the argument and ignore it, as they ignore rich.
The keys went in m.new_content only. A client showing the edit event itself, its original out of view, saw the fallback without them. They now go in both, as chat_edit() already does with formatted text. Asked for by the app that reads the keys.
chat_message()'s raw now promises the event's whole content in raw$content for a Matrix message. A picture reached chat_poll() with the media record alone as its raw.
chat_history() on Matrix skipped every picture and every encrypted event. A restart's backfill reads history, so it never saw a picture sent while a bot was down, and saw nothing of an encrypted room. History now reads its page through the poll's own media and decrypt steps and builds the same messages, through helpers both share.
# Conflicts: # R/matrix.R
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.
chat_history()on Matrix skipped 2 kinds of event:chat_history()puts inbound media in a message'sattachments, aschat_poll()does. Matrix's history dropped every msgtype other than text, notice and emote.m.room.message, so on an E2EE client an encrypted room's history was empty.A consumer's restart backfill reads history. So a picture sent while it was down was never seen, and an encrypted room came back with no context.
History now reads its page the way the poll reads a sync: the same media extractor and the same decrypt step, with the page wrapped in the shape a sync has. Both build their messages through 2 shared helpers (
matrix_decrypted_message(),matrix_media_message()), so one event gives the samechat_messagefrom either. A test compares the two field for field.Stacked on #32 (base
content-keys), since both changechat_poll()'s message builders. It moves tomainwhen #32 merges. No version bump yet.Tests: 23 new assertions in
test_matrix.R, 16 of which fail on #32's code.test_matrix.R598,test_matrix_mxclient.R202 andtest_contract.R312, all passing.