feat: Add support for 3pid management

This commit is contained in:
Ginger
2026-03-23 09:21:33 -04:00
committed by Ellis Git
parent ef7ad6082c
commit 3885e43b5d
11 changed files with 192 additions and 75 deletions
+2 -1
View File
@@ -8,7 +8,8 @@ pub trait MessageTemplate: Template {
#[derive(Template)]
#[template(path = "mail/change_email.txt")]
pub struct ChangeEmail<'a> {
pub user_id: &'a UserId,
pub server_name: &'a str,
pub user_id: Option<&'a UserId>,
pub verification_link: String,
}
+5 -2
View File
@@ -2,9 +2,12 @@
{% block content -%}
Hello!
{% if let Some(user_id) = user_id -%}
Somebody, probably you, tried to associate this email address with the Matrix account {{ user_id }}.
If that's your account, and this is your email address, click this link to proceed:
{%- else -%}
Somebody, probably you, tried to associate this email address with a Matrix account on {{ server_name }}.
{%- endif %}
If that was you, and this is your email address, click this link to proceed:
{{ verification_link }}
Otherwise, you can ignore this email. The above link will expire in one hour.
{%- endblock %}
+5 -5
View File
@@ -227,15 +227,15 @@ impl Service {
///
/// [`Self::get_localpart_for_email`] may be used if only the email is
/// known.
pub async fn disassociate_localpart_email(&self, localpart: &str) {
let email = self
.get_email_for_localpart(localpart)
.await
.expect("localpart has no email associated");
pub async fn disassociate_localpart_email(&self, localpart: &str) -> Option<Address> {
let email = self.get_email_for_localpart(localpart).await?;
self.db.localpart_email.remove(localpart);
self.db
.email_localpart
.remove(<Address as AsRef<str>>::as_ref(&email));
Some(email)
}
/// Get the email associated with a localpart, if one exists.