-
Notifications
You must be signed in to change notification settings - Fork 289
sdk: share room history when we send an invite #4946
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -158,10 +158,7 @@ use crate::{ | |
BaseRoom, Client, Error, HttpResult, Result, RoomState, TransmissionProgress, | ||
}; | ||
#[cfg(feature = "e2e-encryption")] | ||
use crate::{ | ||
crypto::types::events::CryptoContextInfo, encryption::backups::BackupState, | ||
room::shared_room_history::share_room_history, | ||
}; | ||
use crate::{crypto::types::events::CryptoContextInfo, encryption::backups::BackupState}; | ||
|
||
pub mod edit; | ||
pub mod futures; | ||
|
@@ -1480,6 +1477,11 @@ impl Room { | |
/// * `user_id` - The `UserId` of the user to invite to the room. | ||
#[instrument(skip_all)] | ||
pub async fn invite_user_by_id(&self, user_id: &UserId) -> Result<()> { | ||
#[cfg(all(feature = "experimental-share-history-on-invite", feature = "e2e-encryption"))] | ||
{ | ||
shared_room_history::share_room_history(self, user_id.to_owned()).await?; | ||
} | ||
|
||
Comment on lines
+1480
to
+1484
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. Hmm, are we certain that people won't want to have a way to say "Ok, invite this person, but absolutely don't share the room history with them"? I can see that we might want to do this by default, but I can also see that some people might want to opt out. This might be a nice place to introduce a named future, which would allow us to:
I don't mean that we should do this right now, but perhaps down the line as we stabilize support for this feature. 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. When we've discussed this in the past, we have talked about not wanting different people to have different views of a room, especially because if the person with incomplete history then invites another person, they also have incomplete history, and it gets very confusing. So I think we don't want this option. 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. Hmm, I guess that weakens my argument towards "the SDK shouldn't be as opinionated as the Element clients". But ok, I think we can revisit this and discuss later if the SDK should make this optional. |
||
let recipient = InvitationRecipient::UserId { user_id: user_id.to_owned() }; | ||
let request = invite_user::v3::Request::new(self.room_id().to_owned(), recipient); | ||
self.client.send(request).await?; | ||
|
@@ -1806,21 +1808,6 @@ impl Room { | |
Ok(()) | ||
} | ||
|
||
/// Share any shareable E2EE history in this room with the given recipient, | ||
/// as per [MSC4268]. | ||
/// | ||
/// [MSC4268]: https://github.com/matrix-org/matrix-spec-proposals/pull/4268 | ||
/// | ||
/// This is temporarily exposed for integration testing as part of | ||
/// experimental work on history sharing. In future, it will be combined | ||
/// with sending an invite. | ||
#[cfg(feature = "e2e-encryption")] | ||
#[doc(hidden)] | ||
#[instrument(skip_all, fields(room_id = ?self.room_id(), ?user_id))] | ||
pub async fn share_history<'a>(&'a self, user_id: &UserId) -> Result<()> { | ||
share_room_history(self, user_id.to_owned()).await | ||
} | ||
|
||
/// Wait for the room to be fully synced. | ||
/// | ||
/// This method makes sure the room that was returned when joining a 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.
There are other ways to invite a user, don't we need to take care of them as well?
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.
Like what?
invite_user_by_3pid
? Ideally yes, but this flow isn't going to work there, because we don't have a matrix ID for the target user. We ought to think about it at some point, but I think it's well out of scope for this prototyping effort. I've added a note at element-hq/element-meta#2685 (comment).