-
Notifications
You must be signed in to change notification settings - Fork 454
MSC4426 : support set/clear/fetch own user status #6703
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
Open
ganfra
wants to merge
5
commits into
main
Choose a base branch
from
ganfra/set_user_status
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ba195d2
feat(matrix-sdk): introduce unstable-msc4426 feature flag
ganfra d050bc8
chore(deps): bump ruma
ganfra c4e0023
feat(ffi): set/clear user status
ganfra 888ff57
feat(ffi): expose user status in UserProfile
ganfra 13a78e0
doc: changelog for MSC4426
ganfra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Expose [MSC4426] user-status profile fields through the FFI. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| Added `Account::set_status`, `Account::clear_status`, `Account::set_call`, and | ||
| `Account::clear_call` to write [MSC4426] user-status profile fields (`m.status` | ||
| and `m.call`). All four are gated behind the new `unstable-msc4426` feature. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,8 +28,12 @@ use matrix_sdk_base::{ | |
| store::StateStoreExt, | ||
| }; | ||
| use mime::Mime; | ||
| #[cfg(feature = "unstable-msc4426")] | ||
| use ruma::SecondsSinceUnixEpoch; | ||
| #[cfg(feature = "experimental-element-recent-emojis")] | ||
| use ruma::api::client::config::set_global_account_data::v3::Request as UpdateGlobalAccountDataRequest; | ||
| #[cfg(feature = "unstable-msc4426")] | ||
| use ruma::profile::{CallProfileField, StatusProfileField}; | ||
| use ruma::{ | ||
| ClientSecret, MxcUri, OwnedMxcUri, OwnedRoomId, OwnedUserId, RoomId, SessionId, UInt, UserId, | ||
| api::{ | ||
|
|
@@ -446,6 +450,48 @@ impl Account { | |
| Ok(response.value) | ||
| } | ||
|
|
||
| /// Set the user's status (MSC4426 `m.status` profile field). | ||
| /// | ||
| /// Replaces any existing status. Use [`Self::clear_status`] to remove it. | ||
| /// | ||
| /// # Arguments | ||
| /// | ||
| /// * `emoji` - the status emoji. The MSC limits this to 32 bytes; not | ||
| /// enforced client-side. | ||
| /// * `text` - the status text. The MSC limits this to 256 bytes; not | ||
| /// enforced client-side. | ||
|
Comment on lines
+461
to
+462
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same question: why “not enforced client-side”? Same reason. |
||
| #[cfg(feature = "unstable-msc4426")] | ||
| pub async fn set_status(&self, emoji: String, text: String) -> Result<()> { | ||
| let value = StatusProfileField::new(text, emoji); | ||
| self.set_profile_field(ProfileFieldValue::Status(value)).await | ||
| } | ||
|
|
||
| /// Clear the user's status (deletes the MSC4426 `m.status` profile field). | ||
| #[cfg(feature = "unstable-msc4426")] | ||
| pub async fn clear_status(&self) -> Result<()> { | ||
| self.delete_profile_field(ProfileFieldName::Status).await | ||
| } | ||
|
|
||
| /// Set the user's call indicator (MSC4426 `m.call` profile field). | ||
| /// | ||
| /// # Arguments | ||
| /// | ||
| /// * `call_joined_ts` - when the user joined the current call, in seconds | ||
| /// since the Unix epoch. `None` if the joined time isn't known. | ||
| #[cfg(feature = "unstable-msc4426")] | ||
| pub async fn set_call(&self, call_joined_ts: Option<SecondsSinceUnixEpoch>) -> Result<()> { | ||
| let mut value = CallProfileField::new(); | ||
| value.call_joined_ts = call_joined_ts; | ||
| self.set_profile_field(ProfileFieldValue::Call(value)).await | ||
| } | ||
|
|
||
| /// Clear the user's call indicator (deletes the MSC4426 `m.call` profile | ||
| /// field). | ||
| #[cfg(feature = "unstable-msc4426")] | ||
| pub async fn clear_call(&self) -> Result<()> { | ||
| self.delete_profile_field(ProfileFieldName::Call).await | ||
| } | ||
|
|
||
| /// Set the given field of our own user's profile. | ||
| /// | ||
| /// [`Client::homeserver_capabilities()`] should be called first to check it | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why “not enforced client-side”? It would save one roundtrip to the server.
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 conversation on Ruma for reference ruma/ruma#2498 (comment). (Not saying that answers what we should do in the SDK, just noting that that's why Ruma doesn't do any checks on this)
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 see. However, since the Rust SDK tries to be strict and consistent regarding the specification, I prefer to have a check here.
Uh oh!
There was an error while loading. Please reload this page.
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.
What kind of error should I return then? Can you point me to any parameter validation in the code base, because I fail to see one...
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.
@Hywan this is blocking us, do you think we can move without it?