-
Notifications
You must be signed in to change notification settings - Fork 256
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
feat(ffi): add room alias format validation & room name to alias #4219
Conversation
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.
Left some nits, looks sane.
/// Transforms a Room's display name into a valid room alias. | ||
#[matrix_sdk_ffi_macros::export] | ||
fn room_alias_from_room_display_name(room_name: String) -> String { | ||
let whitespace_regex = Regex::new(r"\s+").unwrap(); |
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.
Let's put those strings into a const at the top of the function and let's then document what each of those do.
Additionally, let's replace the unwrap()
with an expect()
.
|
||
/// Transforms a Room's display name into a valid room alias. | ||
#[matrix_sdk_ffi_macros::export] | ||
fn room_alias_from_room_display_name(room_name: String) -> String { |
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.
Some simple smoke tests for this function would be nice.
RoomAliasId::parse(alias).is_ok() | ||
} | ||
|
||
/// Transforms a Room's display name into a valid room alias. |
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 wonder if we should implement this on the DisplayName
type, seem like it might be generally useful.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4219 +/- ##
==========================================
- Coverage 84.85% 84.84% -0.01%
==========================================
Files 272 272
Lines 29172 29185 +13
==========================================
+ Hits 24753 24762 +9
- Misses 4419 4423 +4 ☔ View full report in Codecov by Sentry. |
06df59f
to
c19a12a
Compare
I implemented all those suggestions and some changes to how the room name -> room alias transform works in the last commit. |
Add two FFI functions:
is_room_alias_format_valid
: to check if a passed string has a valid room alias format in Ruma.room_alias_from_room_display_name
: to get a suggestion of a room alias to use given a room name.Signed-off-by: