element-hq / element-meta

Shared/meta documentation and project artefacts for Element clients
75 stars 12 forks source link

[Story] Check room's address for invalid symbols and availability #2585

Open mxandreas opened 1 month ago

mxandreas commented 1 month ago

Description

Checking the address for both invalid symbols and availability is done "in live" as the user is editing the address.

Since this a functionality that already exists in EW, the algorithm for checking for invalid symbols and other constraints is borrowed from EW which currently prevents using the following symbols:

(Note that Matrix spec on identifiers unfortunately does not specify any specific rules for the local part of room alias.)

Same goes for checking if the room address is available - the approach for this can be borrowed from EW and adjusted as necessary.

Note that these checks would need to be applied both at room creation and when changing room settings later.

Designs:

Acceptance criteria

Size estimate

None

Dependencies

Out of scope

Open questions

### Questions
- [x] The Matrix spec. does not specify much for the room alias (its local part), thus what is currently on EW is expected to be its own "best practice". We should use this as a reference.
- [x] If we can check availability of the room address "live" on EX - Ganfra to confirm.
- [ ] If to keep a "green confirmation" when the room is available on EW (decided not introduce on EX) - Gaelle to confirm.

Subtasks

### Android
- [ ] https://github.com/element-hq/element-x-android/issues/3866
### iOS
### Rust
### Other
mxandreas commented 1 month ago

It seems the Matrix spec does not define a clear grammar for the local part (#local_part:homeserver.com) of the room alias, and thus what's implemented on EW, seems to be its own best practice. As there is no good reason to change it, and we want the clients to be in sync - @florianduros could you please point out the code in EW which validates the room alias, so we can use this as a reference when implementing in EX and also use to describe to user on UI what is allowed and what is not.

mxandreas commented 1 month ago

@jmartinesp Has found the corresponding code in EW, this prevents using:

We will stick to this implementation as a change is currently not justified, and not directly related to the scope. The tips on the UI for the end user may be slightly more restrictive for the purpose of keeping it understandable for them.

jmartinesp commented 1 month ago

FWIW this is already handled in Rust in the Ruma crate. Maybe instead of adding custom logic per-client we should create a shared fn is_valid_room_alias(raw: String) -> bool in Rust that tries to create an alias from a raw string, and returns true if it can be created?

mxandreas commented 2 weeks ago

A note that for checking the availability of the address, EW is using this API, e.g. making a GET request to:

https://beta.ems.host/_matrix/client/v3/directory/room/%23xy%3Abeta.matrix.org
mxandreas commented 2 weeks ago

Updated the description to confirm that we check the availability as well as invalid symbols "live" as user is editing the address.

mxandreas commented 2 weeks ago

Agreed that we do not introduce the "green confirmation" that address is available on EX. To be decided if we keep it on EW where it already exists.