Á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:
feco
2026-11-26 11:08:13 +00:00
co-authored by Claude Opus 5.5
parent 7c768fccff
commit da42c92e71
13 changed files with 385 additions and 26 deletions
+7
View File
@@ -160,6 +160,13 @@ pub async fn ban(
record(&mut *tx, moderator.id, Action::Ban, Some(user), None, None, Some(&reason), Some(until)).await?;
tx.commit().await?;
tracing::info!(moderator = %moderator.id, member = %user, hours = ?req.hours, "member banned");
let payload = json!({
"url": crate::mail::rules_url(&state),
"action": "banned",
"reason": reason,
"duration": req.hours.map(crate::mail::ban_duration),
});
crate::mail::notify_user(&state, user, "forum_moderation", payload).await;
Ok(Json(json!({ "banned_until": if req.hours.is_none() { "infinity".to_string() } else { rfc3339(until) } })))
}
+15 -2
View File
@@ -67,7 +67,7 @@ pub async fn remove(
WithRejection(Json(req), _): Body<Reason>,
) -> ApiResult<StatusCode> {
let user = viewer.require_user()?;
let (post, _) = load(&state.db, &viewer, id).await?;
let (post, thread) = load(&state.db, &viewer, id).await?;
if post.deleted_at.is_some() {
return Ok(StatusCode::NO_CONTENT);
}
@@ -92,8 +92,9 @@ pub async fn remove(
.execute(&mut *tx)
.await?;
}
let mut reporters = Vec::new();
if !own {
super::reports::resolve_for_post(&mut tx, id, user.id).await?;
reporters = super::reports::resolve_for_post(&mut tx, id, user.id).await?;
moderation::record(
&mut *tx,
user.id,
@@ -107,6 +108,18 @@ pub async fn remove(
.await?;
}
tx.commit().await?;
if !own {
if let Some(author) = post.author_id {
let payload = serde_json::json!({
"url": crate::mail::rules_url(&state),
"action": "post_removed",
"reason": reason,
"thread_title": thread.title,
});
crate::mail::notify_user(&state, author, "forum_moderation", payload).await;
}
crate::mail::notify_reporters(&state, &reporters, "removed").await;
}
Ok(StatusCode::NO_CONTENT)
}
+16 -9
View File
@@ -305,34 +305,41 @@ pub async fn handle(
.await?;
let (post_id, message_id) = report.ok_or(ApiError::NotFound("report"))?;
let mut tx = state.db.begin().await?;
sqlx::query(
let reporters: Vec<Option<Uuid>> = sqlx::query_scalar(
"UPDATE forum.reports SET status = $2, handled_by = $3, handled_at = now() \
WHERE status = 'open' AND (id = $1 OR ($4::bigint IS NOT NULL AND post_id = $4) \
OR ($5::bigint IS NOT NULL AND message_id = $5))",
OR ($5::bigint IS NOT NULL AND message_id = $5)) \
RETURNING reporter_id",
)
.bind(id)
.bind(status)
.bind(moderator.id)
.bind(post_id)
.bind(message_id)
.execute(&mut *tx)
.fetch_all(&mut *tx)
.await?;
moderation::record_report(&mut *tx, moderator.id, action, id, post_id).await?;
tx.commit().await?;
let outcome = if status == "resolved" { "handled" } else { "no_violation" };
crate::mail::notify_reporters(&state, &reporters, outcome).await;
Ok(StatusCode::NO_CONTENT)
}
/// When a moderator removes a post, its open reports are resolved with it.
pub async fn resolve_for_post(tx: &mut sqlx::PgConnection, post_id: i64, moderator: Uuid) -> Result<(), sqlx::Error> {
sqlx::query(
/// Returns the reporters, to tell them.
pub async fn resolve_for_post(
tx: &mut sqlx::PgConnection,
post_id: i64,
moderator: Uuid,
) -> Result<Vec<Option<Uuid>>, sqlx::Error> {
sqlx::query_scalar(
"UPDATE forum.reports SET status = 'resolved', handled_by = $2, handled_at = now() \
WHERE post_id = $1 AND status = 'open'",
WHERE post_id = $1 AND status = 'open' RETURNING reporter_id",
)
.bind(post_id)
.bind(moderator)
.execute(&mut *tx)
.await?;
Ok(())
.fetch_all(&mut *tx)
.await
}
/// Open reports, for the moderators' badge.
+9
View File
@@ -548,6 +548,15 @@ pub async fn remove(
.await?;
tx.commit().await?;
tracing::info!(thread = id, moderator = %moderator.id, "thread removed");
if let Some(author) = thread.author_id {
let payload = json!({
"url": crate::mail::rules_url(&state),
"action": "thread_removed",
"reason": reason,
"thread_title": thread.title,
});
crate::mail::notify_user(&state, author, "forum_moderation", payload).await;
}
Ok(StatusCode::NO_CONTENT)
}