ÁSZF: the forum chapter, and the moderation e-mails it promises
A new point 8 (the old 8–11 become 9–12): reading, writing and the nickname, the house rules, posts (they stay as "Törölt tag" after an account is deleted), private messages, ranks and limits, reports and moderation under the DSA (receipt, decision notice, statement of reasons, objection, point of contact; every decision is made by a person), notifications. In force from 2026-11-26 (TERMS_UPDATED, TERMS_VERSION). So that it holds: the member gets an e-mail with the reason when a moderator removes their post or thread or bans them, and every reporter gets the decision on their report, whatever their notification settings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -155,3 +155,65 @@ async fn message_mail(
|
||||
});
|
||||
queue(&state.db, &state.base_url, &to, "forum_message", payload).await
|
||||
}
|
||||
|
||||
#[derive(sqlx::FromRow)]
|
||||
struct Person {
|
||||
email: String,
|
||||
locale: String,
|
||||
nickname: Option<String>,
|
||||
}
|
||||
|
||||
/// A notice that has to reach the user whatever their notification settings
|
||||
/// (a moderation step concerning them, the decision on their report).
|
||||
pub async fn notify_user(state: &AppState, user: Uuid, template: &str, mut payload: Value) {
|
||||
let person: Result<Option<Person>, sqlx::Error> = sqlx::query_as(
|
||||
"SELECT u.email, u.locale, m.nickname FROM users u LEFT JOIN forum.members m ON m.user_id = u.id WHERE u.id = $1",
|
||||
)
|
||||
.bind(user)
|
||||
.fetch_optional(&state.db)
|
||||
.await;
|
||||
let result = match person {
|
||||
Ok(Some(p)) => {
|
||||
payload["nickname"] = json!(p.nickname);
|
||||
sqlx::query(
|
||||
"INSERT INTO email_outbox (id, user_id, to_email, template, locale, payload) \
|
||||
VALUES ($1, $2, $3, $4, $5, $6)",
|
||||
)
|
||||
.bind(Uuid::now_v7())
|
||||
.bind(user)
|
||||
.bind(&p.email)
|
||||
.bind(template)
|
||||
.bind(&p.locale)
|
||||
.bind(payload)
|
||||
.execute(&state.db)
|
||||
.await
|
||||
.map(|_| ())
|
||||
}
|
||||
Ok(None) => Ok(()),
|
||||
Err(e) => Err(e),
|
||||
};
|
||||
if let Err(e) = result {
|
||||
tracing::error!(error = %e, template, "queueing a moderation e-mail");
|
||||
}
|
||||
}
|
||||
|
||||
/// The forum rules, where the moderation e-mails point.
|
||||
pub fn rules_url(state: &AppState) -> String {
|
||||
format!("{}/aszf#forum", state.base_url)
|
||||
}
|
||||
|
||||
/// "3 napos" or "12 órás": a ban's length for the e-mail.
|
||||
pub fn ban_duration(hours: i64) -> String {
|
||||
if hours % 24 == 0 { format!("{} napos", hours / 24) } else { format!("{hours} órás") }
|
||||
}
|
||||
|
||||
/// Tells each reporter (once) how their report was decided.
|
||||
pub async fn notify_reporters(state: &AppState, reporters: &[Option<Uuid>], outcome: &str) {
|
||||
let mut seen: Vec<Uuid> = reporters.iter().flatten().copied().collect();
|
||||
seen.sort_unstable();
|
||||
seen.dedup();
|
||||
for reporter in seen {
|
||||
let payload = json!({ "url": format!("{}/forum", state.base_url), "outcome": outcome });
|
||||
notify_user(state, reporter, "forum_report_result", payload).await;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user