-
-
Notifications
You must be signed in to change notification settings - Fork 140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
events: Keep data of unknown relations #1581
Conversation
17814cb
to
761771a
Compare
So it turns out |
de9a5a6
to
38294bd
Compare
Rebased on main to solve CI issue. |
38294bd
to
887ed8d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re. usage of serde_json::Value
, can you explain why it's necessary? Haven't actually found the place it's used yet from skimming. It's quite bad perf-wise so I'd like to avoid it where possible.
I don't know if it is necessary per se, but I can't find another way to deserialize it and keep custom relation data. The |
887ed8d
to
a01c0c7
Compare
Rebased on main |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't reviewed thoroughly, but AFAICT we have new tests, and the JsonObject
deserialization only happens for custom relations, not for known ones. Based on that, I'm happy to merge.
a01c0c7
to
e378ef1
Compare
Alright I finally found a way to do it without My guess is that this doesn't work with the attribute because the |
#[derive(Deserialize)] | ||
#[serde(untagged)] | ||
enum RelationDeHelper { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, this isn't much better than serde_json::Value
I think (does internal buffering). I have a different idea..
#[derive(Deserialize)] | ||
struct EventWithRelatesToDeHelper<C> { | ||
#[serde(rename = "m.relates_to")] | ||
relates_to: Option<RelatesToDeHelper>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make this a boxed RawJsonValue
and try different deserializers on that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you don't feel like it though we can also merge now and I'll try to revisit myself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have been trying to do that in different ways, and for some reason whenever I try to deserialize something into a Box<RawJsonValue>
, it always triggers this error on types that are not RoomMessageEventContent
(so the extensible events types):
Error("invalid type: newtype struct, expected any valid JSON value", line: 1, column: 296)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like we're using internal buffering elsewhere. I guess that makes sense. Let's merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
942d519
to
1ae5062
Compare
So I thought that being able to catch the data of unknown relations would be as simple as adding an
untagged
variant, thanks to the latest release, but it seems like it doesn't work.For some reason the
relation
field ofRelatesToJsonRepr
isNone
with an unknownrel_type
(see tests)… I'm putting the code here to make sure this is a serde issue rather than me not seeing something with our code. Maybe it's an issue with having aflatten
above…Preview: https://pr-1581--ruma-docs.surge.sh