mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-16 15:21:24 +01:00
Merge branch 'leave-room-reason' into 'main'
Draft: do not ignore reason for leaving remote rooms Closes #107 See merge request matrix/grapevine!182
This commit is contained in:
commit
c2bd5b0200
1 changed files with 17 additions and 2 deletions
|
|
@ -1559,7 +1559,7 @@ pub(crate) async fn leave_room(
|
|||
)
|
||||
.await?;
|
||||
} else {
|
||||
if let Err(error) = remote_leave_room(user_id, room_id).await {
|
||||
if let Err(error) = remote_leave_room(user_id, room_id, reason).await {
|
||||
warn!(%error, "Failed to leave room remotely");
|
||||
// Don't tell the client about this error
|
||||
}
|
||||
|
|
@ -1588,7 +1588,11 @@ pub(crate) async fn leave_room(
|
|||
}
|
||||
|
||||
#[allow(clippy::too_many_lines)]
|
||||
async fn remote_leave_room(user_id: &UserId, room_id: &RoomId) -> Result<()> {
|
||||
async fn remote_leave_room(
|
||||
user_id: &UserId,
|
||||
room_id: &RoomId,
|
||||
reason: Option<String>,
|
||||
) -> Result<()> {
|
||||
let mut make_leave_response_and_server = Err(Error::BadServerResponse(
|
||||
"No server available to assist in leaving.",
|
||||
));
|
||||
|
|
@ -1657,6 +1661,17 @@ async fn remote_leave_room(user_id: &UserId, room_id: &RoomId) -> Result<()> {
|
|||
)
|
||||
})?;
|
||||
|
||||
if let Some(reason) = reason {
|
||||
if let Some(CanonicalJsonValue::Object(content)) =
|
||||
leave_event_stub.get_mut("content")
|
||||
{
|
||||
content.insert(
|
||||
"reason".to_owned(),
|
||||
CanonicalJsonValue::String(reason),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Is origin needed?
|
||||
leave_event_stub.insert(
|
||||
"origin".to_owned(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue