Skip to main content

tuwunel_api/client/account_data/
delete_global_account_data.rs

1use axum::extract::State;
2use ruma::api::client::config::delete_global_account_data;
3use tuwunel_core::Result;
4
5use super::assert_account_data_owner;
6use crate::Ruma;
7
8/// # `DELETE /_matrix/client/unstable/org.matrix.msc3391/user/{userId}/account_data/{type}`
9///
10/// MSC3391: erase the named global account data type for the user.
11pub(crate) async fn delete_global_account_data_route(
12	State(services): State<crate::State>,
13	body: Ruma<delete_global_account_data::unstable::Request>,
14) -> Result<delete_global_account_data::unstable::Response> {
15	let sender_user = body.sender_user();
16
17	assert_account_data_owner(
18		sender_user,
19		&body.user_id,
20		body.appservice_info.as_ref(),
21		"You cannot delete account data for other users.",
22	)?;
23
24	services
25		.account_data
26		.delete(None, &body.user_id, body.event_type.to_string().into())
27		.await?;
28
29	Ok(delete_global_account_data::unstable::Response {})
30}