Skip to content

Fix #207: Add support for PlainText events when tailing.#211

Merged
Benjamin-Loison merged 2 commits into
8go:mainfrom
kcexn:fix-tail-plain-text-event
Jun 25, 2026
Merged

Fix #207: Add support for PlainText events when tailing.#211
Benjamin-Loison merged 2 commits into
8go:mainfrom
kcexn:fix-tail-plain-text-event

Conversation

@kcexn

@kcexn kcexn commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

In #207 running matrix-commander-rs --tail <N> was panicking when streaming events from unencrypted (public) rooms as the PlainText TimelineEvent is unsupported. #208 stops the --tail flag from panicking but doesn't add support for PlainText events. This PR adds:

  • Support for plain text events when using the --tail flag.
  • Support for NoticeMessage events in handle_originalsyncmessagelikeevent so that room notices appear in the tailed output.

kcexn added 2 commits June 25, 2026 18:31
- Added support for handling synchronous notice events.
- Added some documentation for the use of cast_ref_unchecked.
@kcexn kcexn mentioned this pull request Jun 25, 2026
@kcexn

kcexn commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

Looks like mclient.rs changed when I ran cargo fmt.

@Benjamin-Loison

Copy link
Copy Markdown
Collaborator
Personal notes:

DuckDuckGo search NoticeMessageEventContent.

The payload for a notice message.

DuckDuckGo search Matrix notice message.

home-assistant/core/pull/108030#issue-2080783740:

This format is a so called "bot notice" is used for bot to post information into a room. This message will not cause notification on the members of the room.

Google search Matrix notice message.

I have verified the src/mclient.rs change being cargo fmt one.

cargo run -- --tail 20 --room '!fOZKtmbCJlBYsrJEag:matrix.org'
Output:
   Compiling matrix-commander v1.0.1 (/home/ubuntu/matrix-commander-rs)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 38.12s
     Running `target/debug/matrix-commander-rs --tail 20 --room ''\!'fOZKtmbCJlBYsrJEag:matrix.org'`
Message: type Text: body "B", room "!fOZKtmbCJlBYsrJEag:matrix.org", sender "@benjamin_loison:matrix.org", event id "$R9FE3blSYzqxXyMMGUAm7BBRTz6TfXjSA8euCNec9UQ", formatted None,
cargo run -- --tail 20 --room '!sNARMdEsFZERaQAJzl:matrix.org'
Output:
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.29s
     Running `target/debug/matrix-commander-rs --tail 20 --room ''\!'sNARMdEsFZERaQAJzl:matrix.org'`
Message: type Text: body "B", room "!sNARMdEsFZERaQAJzl:matrix.org", sender "@benjamin_loison:matrix.org", event id "$gC_umVkXT4IrnI2cZtOwDgHRx5BxZ3SyTrlkkMkWm0o", formatted None, 
Message: type Text: body "C", room "!sNARMdEsFZERaQAJzl:matrix.org", sender "@benjamin_loison:matrix.org", event id "$xFzqRlw6MYKNOrprWhNyP2pKC6vY95fdavZ1UCQJLl4", formatted None, 
Message: type Text: body "D", room "!sNARMdEsFZERaQAJzl:matrix.org", sender "@benjamin_loison:matrix.org", event id "$N4opf7pYH_efkTrKx5CWusawzlffsNYg6v4N-L8ohB8", formatted None, 
Message: type Text: body "E", room "!sNARMdEsFZERaQAJzl:matrix.org", sender "@benjamin_loison:matrix.org", event id "$WiADAB8d9-eXSh6QfRPcArc0ARjMKxWmxZ3FFfZkbXU", formatted None, 
Message: type Text: body "C", room "!sNARMdEsFZERaQAJzl:matrix.org", sender "@benjamin_loison:matrix.org", event id "$tRFx-UDQlk7cmeJtzeUAbXy303xdTtdrHJwaQtfO-JA", formatted None, 
Message: type Text: body "c", room "!sNARMdEsFZERaQAJzl:matrix.org", sender "@benjamin_loison:matrix.org", event id "$2CGM1oUriVNr-RcleAFnKlVpaFhjizdopvrW8236cLM", formatted None,
cargo run -- --tail 20 --room '!fOZKtmbCJlBYsrJEag:matrix.org' --output json
Output:
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.28s
     Running `target/debug/matrix-commander-rs --tail 20 --room ''\!'fOZKtmbCJlBYsrJEag:matrix.org' --output json`
Message: type Text: body "B", room "!fOZKtmbCJlBYsrJEag:matrix.org", sender "@benjamin_loison:matrix.org", event id "$R9FE3blSYzqxXyMMGUAm7BBRTz6TfXjSA8euCNec9UQ", formatted None,
cargo run -- --tail 20 --room '!sNARMdEsFZERaQAJzl:matrix.org' --output json
Output:
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.28s
     Running `target/debug/matrix-commander-rs --tail 20 --room ''\!'sNARMdEsFZERaQAJzl:matrix.org' --output json`
Message: type Text: body "B", room "!sNARMdEsFZERaQAJzl:matrix.org", sender "@benjamin_loison:matrix.org", event id "$gC_umVkXT4IrnI2cZtOwDgHRx5BxZ3SyTrlkkMkWm0o", formatted None, 
Message: type Text: body "C", room "!sNARMdEsFZERaQAJzl:matrix.org", sender "@benjamin_loison:matrix.org", event id "$xFzqRlw6MYKNOrprWhNyP2pKC6vY95fdavZ1UCQJLl4", formatted None, 
Message: type Text: body "D", room "!sNARMdEsFZERaQAJzl:matrix.org", sender "@benjamin_loison:matrix.org", event id "$N4opf7pYH_efkTrKx5CWusawzlffsNYg6v4N-L8ohB8", formatted None, 
Message: type Text: body "E", room "!sNARMdEsFZERaQAJzl:matrix.org", sender "@benjamin_loison:matrix.org", event id "$WiADAB8d9-eXSh6QfRPcArc0ARjMKxWmxZ3FFfZkbXU", formatted None, 
Message: type Text: body "C", room "!sNARMdEsFZERaQAJzl:matrix.org", sender "@benjamin_loison:matrix.org", event id "$tRFx-UDQlk7cmeJtzeUAbXy303xdTtdrHJwaQtfO-JA", formatted None, 
Message: type Text: body "c", room "!sNARMdEsFZERaQAJzl:matrix.org", sender "@benjamin_loison:matrix.org", event id "$2CGM1oUriVNr-RcleAFnKlVpaFhjizdopvrW8236cLM", formatted None,

After restoring if !output.is_text() {:

cargo run -- --tail 20 --room '!sNARMdEsFZERaQAJzl:matrix.org' --output json
Output:
   Compiling matrix-commander v1.0.1 (/home/ubuntu/matrix-commander-rs)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 25.14s
     Running `target/debug/matrix-commander-rs --tail 20 --room ''\!'sNARMdEsFZERaQAJzl:matrix.org' --output json`
...
{"content":{"body":"c","m.mentions":{},"msgtype":"m.text"},"event_id":"$2CGM1oUriVNr-RcleAFnKlVpaFhjizdopvrW8236cLM","origin_server_ts":1782329500725,"room_id":"!sNARMdEsFZERaQAJzl:matrix.org","sender":"@benjamin_loison:matrix.org","type":"m.room.message","unsigned":{"age":50685737,"membership":"join"}}
cargo run -- --tail 20 --room '!fOZKtmbCJlBYsrJEag:matrix.org' --output json
Output:
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.28s
     Running `target/debug/matrix-commander-rs --tail 20 --room ''\!'fOZKtmbCJlBYsrJEag:matrix.org' --output json`
{"unsigned":{"age":44067166,"membership":"leave"},"room_id":"!fOZKtmbCJlBYsrJEag:matrix.org","content":{"creator":"@overclock3000:matrix.org","room_version":"10"},"origin_server_ts":1782336142058,"sender":"@overclock3000:matrix.org","state_key":"","type":"m.room.create","event_id":"$Xi58BlRwbZf0tIVO79I-obCPGck2kKNUSJfmVZLhxbA","user_id":"@overclock3000:matrix.org","age":44067166}
{"unsigned":{"age":44066704,"membership":"join"},"room_id":"!fOZKtmbCJlBYsrJEag:matrix.org","content":{"displayname":"Benjamin Loison's bot","membership":"join"},"origin_server_ts":1782336142520,"sender":"@overclock3000:matrix.org","state_key":"@overclock3000:matrix.org","type":"m.room.member","event_id":"$EXsHxXtOJHpaTZMo7MB83wOl_x-Pcjkh3uHBJmDHKR0","user_id":"@overclock3000:matrix.org","age":44066704}
{"unsigned":{"age":44066473,"membership":"join"},"room_id":"!fOZKtmbCJlBYsrJEag:matrix.org","content":{"ban":50,"events":{"m.room.avatar":50,"m.room.canonical_alias":50,"m.room.encryption":100,"m.room.history_visibility":100,"m.room.name":50,"m.room.power_levels":100,"m.room.server_acl":100,"m.room.tombstone":100,"org.matrix.msc3401.call.member":0},"events_default":0,"historical":100,"invite":0,"kick":50,"redact":50,"state_default":50,"users":{"@overclock3000:matrix.org":100},"users_default":0},"origin_server_ts":1782336142751,"sender":"@overclock3000:matrix.org","state_key":"","type":"m.room.power_levels","event_id":"$SizV3qFQ-NO_GhD-rzV5AGMyDAf0lodp1S_7E0ZtfP0","user_id":"@overclock3000:matrix.org","age":44066473}
{"unsigned":{"age":44066453,"membership":"join"},"room_id":"!fOZKtmbCJlBYsrJEag:matrix.org","content":{"join_rule":"invite"},"origin_server_ts":1782336142771,"sender":"@overclock3000:matrix.org","state_key":"","type":"m.room.join_rules","event_id":"$Cq3OhQ92aTWFi7q7fekORLioFvxxp23fRP1UHBQIHNY","user_id":"@overclock3000:matrix.org","age":44066453}
{"unsigned":{"age":44066452,"membership":"join"},"room_id":"!fOZKtmbCJlBYsrJEag:matrix.org","content":{"guest_access":"can_join"},"origin_server_ts":1782336142772,"sender":"@overclock3000:matrix.org","state_key":"","type":"m.room.guest_access","event_id":"$55wCKhedTjcAf3DQe_78FRaw4KZt_vFH83g3zxn233E","user_id":"@overclock3000:matrix.org","age":44066452}
{"unsigned":{"age":44066451,"membership":"join"},"room_id":"!fOZKtmbCJlBYsrJEag:matrix.org","content":{"history_visibility":"invited"},"origin_server_ts":1782336142773,"sender":"@overclock3000:matrix.org","state_key":"","type":"m.room.history_visibility","event_id":"$4WhfiVSgEN3NdBEzEI0quvbNO8JxddKhLXx52ZqwFl4","user_id":"@overclock3000:matrix.org","age":44066451}
{"unsigned":{"age":44066450,"membership":"join"},"room_id":"!fOZKtmbCJlBYsrJEag:matrix.org","content":{"name":"Unencrypted room"},"origin_server_ts":1782336142774,"sender":"@overclock3000:matrix.org","state_key":"","type":"m.room.name","event_id":"$FAqOGb_FVFbw0MYO8jDPvyYgCi03hERO145saEs_huI","user_id":"@overclock3000:matrix.org","age":44066450}
{"unsigned":{"age":44060113,"membership":"join"},"room_id":"!fOZKtmbCJlBYsrJEag:matrix.org","content":{"avatar_url":"mxc://matrix.org/iDFnafuZVpbXvUmYxKDuntuA","displayname":"Benjamin Loison","membership":"invite"},"origin_server_ts":1782336149111,"sender":"@overclock3000:matrix.org","state_key":"@benjamin_loison:matrix.org","type":"m.room.member","event_id":"$jnngtRsnG0LAmnQOO42N1Pc1It_LDcxncAexl8-rFWQ","user_id":"@overclock3000:matrix.org","age":44060113}
{"unsigned":{"replaces_state":"$jnngtRsnG0LAmnQOO42N1Pc1It_LDcxncAexl8-rFWQ","prev_content":{"avatar_url":"mxc://matrix.org/iDFnafuZVpbXvUmYxKDuntuA","displayname":"Benjamin Loison","membership":"invite"},"prev_sender":"@overclock3000:matrix.org","age":44057611,"membership":"join"},"room_id":"!fOZKtmbCJlBYsrJEag:matrix.org","content":{"avatar_url":"mxc://matrix.org/iDFnafuZVpbXvUmYxKDuntuA","displayname":"Benjamin Loison","membership":"join"},"origin_server_ts":1782336151613,"sender":"@benjamin_loison:matrix.org","state_key":"@benjamin_loison:matrix.org","type":"m.room.member","event_id":"$CAKqGylKijM88aRNvI0BtRTsJzDi1Yg6MAc4y570Bps","user_id":"@benjamin_loison:matrix.org","age":44057611,"replaces_state":"$jnngtRsnG0LAmnQOO42N1Pc1It_LDcxncAexl8-rFWQ","prev_content":{"avatar_url":"mxc://matrix.org/iDFnafuZVpbXvUmYxKDuntuA","displayname":"Benjamin Loison","membership":"invite"}}
{"unsigned":{"age":44054078,"membership":"join"},"room_id":"!fOZKtmbCJlBYsrJEag:matrix.org","content":{"body":"A","m.mentions":{},"msgtype":"m.text"},"origin_server_ts":1782336155146,"sender":"@overclock3000:matrix.org","type":"m.room.message","event_id":"$AjIJoUpuIK5W5XrzRw-rgp4OPPUiNwIujibVQc40wrY","user_id":"@overclock3000:matrix.org","age":44054078}
{"unsigned":{"age":44053145,"membership":"join"},"room_id":"!fOZKtmbCJlBYsrJEag:matrix.org","content":{"body":"B","m.mentions":{},"msgtype":"m.text"},"origin_server_ts":1782336156079,"sender":"@benjamin_loison:matrix.org","type":"m.room.message","event_id":"$R9FE3blSYzqxXyMMGUAm7BBRTz6TfXjSA8euCNec9UQ","user_id":"@benjamin_loison:matrix.org","age":44053145}

Nice cast @kcexn, thank you.

@kcexn

kcexn commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

Is there a reason you just closed my PR and then pasted my commits in your own name? It's rude.

@Benjamin-Loison

Benjamin-Loison commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

@kcexn Sorry, I am not accustomed to managing pull requests, I do not have much time to spend doing things perfect and wanted to merge quickly, with the JSON output working as you have broken it. Furthermore, in my opinion linking to this pull request that you were the author was looking good enough, in addition that it is not a very significant code change in terms of quantity.

Next time I will use Co-authored-by.

Personal notes:

DuckDuckGo search git co author commit.

Source: the Stack Overflow answer 7442255

@kcexn

kcexn commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

If it's broken something we can roll back the change and fix it.

GitHub keeps track of contribution statistics even if you don't list me as a contributor on the landing page.

I'm not claiming copyright over the work. I'm asking for credit.

You could have just used GitHubs squash and merge option.

@Benjamin-Loison

Benjamin-Loison commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

I think it is better not to git push --force to rewrite the past (my commit), I apologize and if I can credit you without git push --force, then let me know about it.

@Benjamin-Loison

Benjamin-Loison commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

If you want I can add a commit to revert my commit, then add your commits on top of this revert commit, as your commits are not cryptographically signed.

@kcexn

kcexn commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

Okay. Revert the commit, then I'll reopen a pull request.

@Benjamin-Loison

Copy link
Copy Markdown
Collaborator

No need to reopen a pull request, then no? I can add your commits on top of my revert commit without you opening a new pull request, no?

@kcexn

kcexn commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

You should revert the commit. Then reopen this pull request, then accept and merge this pull request. If you don't want the commit history from my fork, you can squash and merge instead.

Benjamin-Loison pushed a commit that referenced this pull request Jun 25, 2026
@Benjamin-Loison

Benjamin-Loison commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator
Personal notes:

DuckDuckGo search git revert commit.

The Stack Overflow answer 21615059:

git revert
Output:
usage: git revert [--[no-]edit] [-n] [-m <parent-number>] [-s] [-S[<keyid>]] <commit>...
   or: git revert (--continue | --skip | --abort | --quit)

    --quit                end revert or cherry-pick sequence
    --continue            resume revert or cherry-pick sequence
    --abort               cancel revert or cherry-pick sequence
    --skip                skip current commit and continue
    --[no-]cleanup <mode> how to strip spaces and #comments from message
    -n, --no-commit       don't automatically commit
    --commit              opposite of --no-commit
    -e, --[no-]edit       edit the commit message
    -s, --[no-]signoff    add a Signed-off-by trailer
    -m, --[no-]mainline <parent-number>
                          select mainline parent
    --[no-]rerere-autoupdate
                          update the index with reused conflict resolution if possible
    --[no-]strategy <strategy>
                          merge strategy
    -X, --[no-]strategy-option <option>
                          option for merge strategy
    -S, --[no-]gpg-sign[=<key-id>]
                          GPG sign commit
    --[no-]reference      use the 'reference' format to refer to commits
git revert HEAD
Output:
[main 5fef685] Revert "#211: Add support for PlainText events when tailing"
 2 files changed, 36 insertions(+), 54 deletions(-)
git push
Output:
Enumerating objects: 9, done.
Counting objects: 100% (9/9), done.
Delta compression using up to 28 threads
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 1.15 KiB | 1.15 MiB/s, done.
Total 5 (delta 4), reused 0 (delta 0), pack-reused 0 (from 0)
remote: Resolving deltas: 100% (4/4), completed with 4 local objects.
To github.com:8go/matrix-commander-rs.git
   2a77a09..5fef685  main -> main

@Benjamin-Loison
Benjamin-Loison merged commit 34c991c into 8go:main Jun 25, 2026
1 check passed
@Benjamin-Loison

Copy link
Copy Markdown
Collaborator

This looks good to you @kcexn?

@kcexn

kcexn commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

Yes. Thank you! I'll close the issue now if you haven't already.

@kcexn
kcexn deleted the fix-tail-plain-text-event branch June 26, 2026 00:31
@8go

8go commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Thanks to both of you 🚀 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants