X-Git-Url: http://these/git/?a=blobdiff_plain;f=crates%2Fapi_common%2Fsrc%2Futils.rs;h=88908bccdf3112e4b220ff52598fbfe842548430;hb=ddb62681648cec473a19dce29861d48882e71943;hp=689488feba61abd64f9db0fe424c9aa6a411dbdc;hpb=166854b37e0929bbbaf076b44470a132b539f50b;p=lemmy.git diff --git a/crates/api_common/src/utils.rs b/crates/api_common/src/utils.rs index 689488fe..88908bcc 100644 --- a/crates/api_common/src/utils.rs +++ b/crates/api_common/src/utils.rs @@ -483,6 +483,28 @@ pub async fn send_new_applicant_email_to_admins( Ok(()) } +/// Send a report to all admins +pub async fn send_new_report_email_to_admins( + reporter_username: &str, + reported_username: &str, + pool: &DbPool, + settings: &Settings, +) -> Result<(), LemmyError> { + // Collect the admins with emails + let admins = LocalUserSettingsView::list_admins_with_emails(pool).await?; + + let reports_link = &format!("{}/reports", settings.get_protocol_and_hostname(),); + + for admin in &admins { + let email = &admin.local_user.email.clone().expect("email"); + let lang = get_interface_language_from_settings(admin); + let subject = lang.new_report_subject(&settings.hostname, reporter_username, reported_username); + let body = lang.new_report_body(reports_link); + send_email(&subject, email, &admin.person.name, &body, settings)?; + } + Ok(()) +} + pub async fn check_registration_application( local_user_view: &LocalUserView, local_site: &LocalSite,