Skip to main content

tuwunel_api/client/account_data/
delete_room_account_data.rs

1use axum::extract::State;
2use ruma::api::client::config::delete_room_account_data;
3use tuwunel_core::{Err, Result};
4
5use crate::Ruma;
6
7/// # `DELETE /_matrix/client/unstable/org.matrix.msc3391/user/{userId}/rooms/{roomId}/account_data/{type}`
8///
9/// MSC3391: erase the named room account data type for the user.
10pub(crate) async fn delete_room_account_data_route(
11	State(services): State<crate::State>,
12	body: Ruma<delete_room_account_data::unstable::Request>,
13) -> Result<delete_room_account_data::unstable::Response> {
14	let sender_user = body.sender_user();
15
16	if sender_user != body.user_id && body.appservice_info.is_none() {
17		return Err!(Request(Forbidden("You cannot delete account data for other users.")));
18	}
19
20	services
21		.account_data
22		.delete(Some(&body.room_id), &body.user_id, body.event_type.clone())
23		.await?;
24
25	Ok(delete_room_account_data::unstable::Response {})
26}