-
Notifications
You must be signed in to change notification settings - Fork 258
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(room): add methods to customise a Room's privacy settings #4401
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #4401 +/- ##
==========================================
+ Coverage 85.26% 85.29% +0.03%
==========================================
Files 282 283 +1
Lines 31170 31225 +55
==========================================
+ Hits 26576 26633 +57
+ Misses 4594 4592 -2 ☔ View full report in Codecov by Sentry. |
400ce36
to
15d2db1
Compare
These include: - Updating the canonical alias. - Creating and removing a room alias from the room directory. - Enabling encryption in a room. - Updating the join rule of a room. - Updating the room history visiblity.
15d2db1
to
736f2c0
Compare
@@ -1152,17 +1152,6 @@ impl Client { | |||
let alias = RoomAliasId::parse(alias)?; | |||
self.inner.is_room_alias_available(&alias).await.map_err(Into::into) | |||
} | |||
|
|||
/// Creates a new room alias associated with the provided room id. | |||
pub async fn create_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.
This was just moved to a different file, to have the functions grouped.
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.
Looking good, I left a couple of recommendations but nothing major.
@@ -155,6 +155,12 @@ impl From<RoomSendQueueError> for ClientError { | |||
} | |||
} | |||
|
|||
impl From<NotYetImplemented> for ClientError { | |||
fn from(_: NotYetImplemented) -> Self { |
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.
Since we're starting to use that more and more, I wonder if NotYetImplemented
should contain more information, i.e. so we know which exact feature isn't yet implemented. (if you agree, this can be part of a separate PR)
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 good, but as you suggest I'd rather make this change in a new PR.
/// Update the canonical alias of the room. | ||
/// | ||
/// Note that publishing the alias in the room directory is done separately. | ||
pub async fn update_canonical_alias(&self, new_alias: Option<OwnedRoomAliasId>) -> Result<()> { |
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.
We should explain what providing a None
does. An example wouldn't hurt either.
|
||
use crate::{Error, Result, Room}; | ||
|
||
impl Room { |
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.
Since this is already in a separate module and adds a lot of functionality, I think it makes sense to introduce a "fake" struct for this that groups all the privacy settings under its umbrella.
pub struct RoomPrivacySettings<'a> {
room: &'a Room
}
impl RoomPrivacySettings {
...
}
That way you would call:
room.privacy_settings().update_canonical_alias(my_alias).await?
Take a look at the Encryption
struct and module, we do the same thing there to avoid cluttering the Client
object with a lot of E2EE related methods.
Ok(()) | ||
} | ||
|
||
/// Update room history visibility for this room. |
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.
The docs on all these methods are a bit terse, it might be nice to explain briefly what the history visibility is and link to the spec for more info.
This applies to the other methods as well, an example here and there wouldn't hurt either.
/// use matrix_sdk::{ | ||
/// ruma::room_alias_id, test_utils::mocks::MatrixMockServer, | ||
/// }; | ||
/// use ruma::api::client::room::Visibility; | ||
/// | ||
/// let mock_server = MatrixMockServer::new().await; | ||
/// let client = mock_server.client_builder().build().await; | ||
/// | ||
/// mock_server | ||
/// .mock_room_directory_remove_room_alias() | ||
/// .ok() | ||
/// .mock_once() | ||
/// .mount() | ||
/// .await; | ||
/// | ||
/// client | ||
/// .remove_room_alias(room_alias_id!("#a:b.c")) | ||
/// .await | ||
/// .expect("We should be able to remove the room alias"); | ||
/// # anyhow::Ok(()) }); |
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.
Thanks a bunch for adding examples on these.
It turns out this needs further work, so I'll upload some more changes tomorrow with both the needed changes and some logic changed too to take into account the public room visibility and being able to retry the whole 'publish and update alias' flow if the alias was published but the process got interrupted before. |
These include:
Also, expose the room history visibility through the FFI RoomInfo.
Signed-off-by: