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 3 weeks ago

mxandreas commented 3 weeks ago

Description

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.
- [ ] If we can check availability of the room address "live" on EX - Ganfra to confirm.
- [ ] If we should have a "green confirmation" when the room is available on EX (it is currently the case on EW)- Gaelle to confirm.

Subtasks

### Android
### iOS
### Rust
### Other
mxandreas commented 2 weeks 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 2 weeks 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 2 weeks 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 20 hours 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