Skip to main content

tuwunel_api/client/account/3pid/
delete_3pid.rs

1use axum::extract::State;
2use ruma::api::client::account::{
3	ThirdPartyIdRemovalStatus,
4	delete_3pid::{self, v3::Response},
5};
6use tuwunel_core::Result;
7use tuwunel_service::threepid::canonicalize_email;
8
9use crate::Ruma;
10
11/// # `POST /_matrix/client/v3/account/3pid/delete`
12///
13/// Remove a third party identifier from this account.
14///
15/// We never bound the address to an identity server, so the unbind result is
16/// always `no-support`; any supplied `id_server` is ignored rather than
17/// rejected.
18#[tracing::instrument(skip_all, name = "delete_3pid")]
19pub(crate) async fn delete_3pid_route(
20	State(services): State<crate::State>,
21	body: Ruma<delete_3pid::v3::Request>,
22) -> Result<Response> {
23	let sender_user = body.sender_user();
24
25	if let Ok(email_canon) = canonicalize_email(&body.address) {
26		services
27			.threepid
28			.del_binding(sender_user, &email_canon)
29			.await;
30	}
31
32	Ok(Response::new(ThirdPartyIdRemovalStatus::NoSupport))
33}