tuwunel_api_client/account_data/
delete_global_account_data.rs1use axum::extract::State;
2use ruma::api::client::config::delete_global_account_data;
3use tuwunel_core::Result;
4
5use super::{assert_account_data_owner, validate_event_type};
6use crate::Ruma;
7
8pub(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 validate_event_type(&body.event_type.to_cow_str())?;
25
26 services
27 .account_data
28 .delete(None, &body.user_id, body.event_type.to_string().into())
29 .await?;
30
31 Ok(delete_global_account_data::unstable::Response {})
32}