Skip to content
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

Accept any string as a key for m.direct account data #4228

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MatMaul
Copy link
Contributor

@MatMaul MatMaul commented Nov 6, 2024

This is the follow up of this Ruma PR for the SDK.

Ruma PR needs to be merged first.

@MatMaul MatMaul requested a review from a team as a code owner November 6, 2024 16:01
@MatMaul MatMaul requested review from bnjbvr and removed request for a team November 6, 2024 16:01
Copy link
Member

@bnjbvr bnjbvr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think losing static typing is an option, instead we should introduce an enum that can be one of all the types we expect (owned user id OR email address, if I understand correctly).

Also, BaseRoomInfo is serialized in the database, so we'd need a test making sure that we don't need a migration there, when the previous content was serialized as a OwneduserId; if the test fails, we need a migration.

@MatMaul MatMaul changed the title Accept any string as a key for m.direct account data Accept any string as a key for m.direct account data Nov 6, 2024
@MatMaul
Copy link
Contributor Author

MatMaul commented Nov 6, 2024

I don't think losing static typing is an option, instead we should introduce an enum that can be one of all the types we expect (owned user id OR email address, if I understand correctly).

Fine for me, but it also needs to support phone numbers I think, basically any identifier types.

Fine for you ?

@MatMaul
Copy link
Contributor Author

MatMaul commented Nov 6, 2024

Beware that it will not solve the trouble for some legacy buggy behavior of Element Web.

@bnjbvr
Copy link
Member

bnjbvr commented Nov 6, 2024

Fine for you ?

Fine if we do have some type checking / upfront validation for all these other id types indeed :)

@MatMaul
Copy link
Contributor Author

MatMaul commented Nov 6, 2024

Is there a way to not fully failed m.direct parsing when only some entries are invalid ?

The entry should just be omitted in this case I believe.

Should I keep implementing FromIterator<(String, Vec<OwnedRoomId>)>, try to .from the string with the UserIdentifier enum we are talking about, and then put that in a BTreeMap<UserIdentifier, Vec<OwnedRoomId>> ?

@MatMaul
Copy link
Contributor Author

MatMaul commented Nov 6, 2024

So I think the question is, will serde uses FromIterator<(String, Vec<OwnedRoomId>)> or not to deserialize the JSON in this case ?

If not, what would be suited to do to still deserialize m.direct account data with invalid entries in it ?

@spaetz
Copy link

spaetz commented Nov 7, 2024

If introducing ENUMS can we have an "UNKNOWN" too please which could catch either nonsense, such as "[object Object]": or other id's that this SDK perhaps does not know about (yet)?

@MatMaul
Copy link
Contributor Author

MatMaul commented Nov 7, 2024

Yes I think I have a way with something like that @spaetz , thanks.

Copy link

codecov bot commented Nov 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.93%. Comparing base (aca83fb) to head (2022ae9).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4228      +/-   ##
==========================================
+ Coverage   84.92%   84.93%   +0.01%     
==========================================
  Files         274      274              
  Lines       29805    29805              
==========================================
+ Hits        25311    25316       +5     
+ Misses       4494     4489       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -45,7 +45,7 @@ once_cell = "1.16.0"
pin-project-lite = "0.2.9"
rand = "0.8.5"
reqwest = { version = "0.12.4", default-features = false }
ruma = { version = "0.11.1", features = [
ruma = { git = "https://github.com/ruma/ruma.git", rev = "35fda7f2f7811156df2e60b223dbf136fc143bc8", features = [
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potentially stating the obvious here, but if you wanna do a crates.io release soon (I think this was planned), make sure to only merge this PR afterwards 😉

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New policy in town, no git deps anymore. That's why cargo-deny makes the CI fail.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh. Well I don't think we'll have the Ruma change blocking this PR out on crates.io anytime soon.

Copy link
Contributor Author

@MatMaul MatMaul Nov 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No rush on my side, it can wait.

Feel free to review in the meantime, so we can merge when we got a ruma release out.

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.

5 participants