Nheko-Reborn / mtxclient

Client API library for Matrix, built on top of libcurl
MIT License
40 stars 25 forks source link

Add support for unknown messages #92

Closed LorenDB closed 1 year ago

LorenDB commented 1 year ago

According to the spec, all m.room.message events must have a fallback body property that can be displayed. This PR aims to implement this behavior by creating a specialized Unknown type for messages instead of turning m.room.message events into events that are completely unknown.

I literally couldn't be bothered to figure out how to use a custom mtxclient build with nheko, so I haven't put this in nheko yet, but it should pass all the tests.

deepbluev7 commented 1 year ago

This again has the problem as your original PR. You are yeeting the original content into the ether and no future update will be able to read the message until it was cleared from the cache. I would really prefer to not do that :3

LorenDB commented 1 year ago

Oh, you want the original JSON to be stored in the unknown event?

deepbluev7 commented 1 year ago

That's what we do for the other unknown event, because it enables us to persist it properly and then in an update show the message appropriately :3

LorenDB commented 1 year ago

Mhm, that didn't cross my mind when I wrote this. I think that is a good idea though. I'll get it worked up shortly.

deepbluev7 commented 1 year ago

I said that multiple times, lol. Also the reason why I said to just do the duck typing in Nheko, but I guess this is fine. :3

LorenDB commented 1 year ago

Well, I would have done this in nheko, but I felt like it might be a good idea to make mtxclient follow the spec in this case.

deepbluev7 commented 1 year ago

Well, tests are failing now :)

codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 78.26% and project coverage change: +0.13 :tada:

Comparison is base (31f2af6) 72.33% compared to head (4c1a366) 72.47%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #92 +/- ## ========================================== + Coverage 72.33% 72.47% +0.13% ========================================== Files 90 91 +1 Lines 5563 5583 +20 ========================================== + Hits 4024 4046 +22 + Misses 1539 1537 -2 ``` | [Impacted Files](https://codecov.io/gh/Nheko-Reborn/mtxclient/pull/92?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nheko-Reborn) | Coverage Δ | | |---|---|---| | [lib/http/client.cpp](https://codecov.io/gh/Nheko-Reborn/mtxclient/pull/92?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nheko-Reborn#diff-bGliL2h0dHAvY2xpZW50LmNwcA==) | `68.65% <ø> (ø)` | | | [lib/structs/events/collections.cpp](https://codecov.io/gh/Nheko-Reborn/mtxclient/pull/92?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nheko-Reborn#diff-bGliL3N0cnVjdHMvZXZlbnRzL2NvbGxlY3Rpb25zLmNwcA==) | `14.36% <0.00%> (-0.41%)` | :arrow_down: | | [lib/structs/events.cpp](https://codecov.io/gh/Nheko-Reborn/mtxclient/pull/92?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nheko-Reborn#diff-bGliL3N0cnVjdHMvZXZlbnRzLmNwcA==) | `87.54% <100.00%> (+2.56%)` | :arrow_up: | | [lib/structs/events/messages/unknown.cpp](https://codecov.io/gh/Nheko-Reborn/mtxclient/pull/92?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nheko-Reborn#diff-bGliL3N0cnVjdHMvZXZlbnRzL21lc3NhZ2VzL3Vua25vd24uY3Bw) | `100.00% <100.00%> (ø)` | | | [lib/structs/responses/common.cpp](https://codecov.io/gh/Nheko-Reborn/mtxclient/pull/92?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nheko-Reborn#diff-bGliL3N0cnVjdHMvcmVzcG9uc2VzL2NvbW1vbi5jcHA=) | `45.00% <100.00%> (+0.57%)` | :arrow_up: | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nheko-Reborn). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Nheko-Reborn)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

LorenDB commented 1 year ago

Tests are now passing :tada:

deepbluev7 commented 1 year ago

Hm, I guess the Invalid is fine, since it is a msgtype, although I still need to check, if this is added to all paths correctly. Could you add some test cases for Invalid?

LorenDB commented 1 year ago

There, I added a test. I have no idea if that qualifies as enough testing, but it's a start :D

deepbluev7 commented 1 year ago

@labhub new-pipeline

LorenDB commented 1 year ago

ty!