Privacy policy: the forum, and the export and retention it states

Both languages: rows for the forum profile, posts, last visit, private
conversations, reports and the moderation log (DSA legal obligation);
what is public and what moderators see; forum content never goes to AI;
retention periods; the forum theme cookie; the rights (the export covers
the forum, posts kept as "Törölt tag" can be deleted on request). In
force from 2026-11-26.

So that it holds: the account export includes the forum, and the hourly
cleanup clears text removed by moderators after a year, closed reports
and old ban reasons after a year, the moderation log after two years,
and requests never accepted after 90 days.

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:26:09 +00:00
co-authored by Claude Opus 5.5
parent da42c92e71
commit 88d9a5df3e
8 changed files with 290 additions and 16 deletions
+8
View File
@@ -179,6 +179,14 @@ pub async fn export(State(state): St, auth: AuthUser) -> ApiResult<impl IntoResp
"questions": rows("SELECT json_build_object('id', q.id, 'analysis_id', q.analysis_id, 'question', q.question, 'status', q.status, 'answer', q.answer, 'created_at', q.created_at) FROM questions q WHERE q.asked_by = $1").await?,
"credit_ledger": rows("SELECT json_build_object('unit', unit, 'delta', delta, 'reason', reason, 'note', note, 'created_at', created_at) FROM credit_ledger WHERE user_id = $1 ORDER BY created_at").await?,
"shares": rows("SELECT json_build_object('slug', slug, 'kind', kind, 'title', title, 'show_birth_data', show_birth_data, 'view_count', view_count, 'created_at', created_at, 'revoked_at', revoked_at) FROM shares WHERE owner_id = $1").await?,
// The forum (services/forum): what the user wrote and set there.
"forum_profile": rows("SELECT json_build_object('nickname', nickname, 'avatar', avatar, 'bio', bio, 'chart_share', chart_share, 'invisible', invisible, 'points', points, 'post_count', post_count, 'created_at', created_at, 'email_replies', email_replies, 'email_followed', email_followed, 'email_messages', email_messages, 'banned_until', banned_until, 'ban_reason', ban_reason) FROM forum.members WHERE user_id = $1").await?,
"forum_posts": rows("SELECT json_build_object('id', p.id, 'thread_id', p.thread_id, 'thread_title', th.title, 'opening', p.is_opening, 'body', p.body, 'created_at', p.created_at, 'edited_at', p.edited_at, 'removed_at', p.deleted_at, 'removal_reason', p.delete_reason) FROM forum.posts p JOIN forum.threads th ON th.id = p.thread_id WHERE p.author_id = $1 ORDER BY p.id").await?,
"forum_reactions": rows("SELECT json_build_object('post_id', post_id, 'kind', kind, 'created_at', created_at) FROM forum.reactions WHERE user_id = $1 ORDER BY created_at").await?,
"forum_followed_threads": rows("SELECT json_build_object('thread_id', thread_id, 'since', created_at) FROM forum.follows WHERE user_id = $1").await?,
"forum_conversations": rows("SELECT json_build_object('id', c.id, 'with', m.nickname, 'requested_by_me', c.requested_by = $1, 'intro', c.intro, 'status', c.status, 'created_at', c.created_at) FROM forum.conversations c LEFT JOIN forum.members m ON m.user_id = CASE WHEN c.user_a = $1 THEN c.user_b ELSE c.user_a END WHERE $1 IN (c.user_a, c.user_b)").await?,
"forum_messages_sent": rows("SELECT json_build_object('conversation_id', conversation_id, 'body', body, 'created_at', created_at) FROM forum.messages WHERE sender_id = $1 ORDER BY id").await?,
"forum_reports_sent": rows("SELECT json_build_object('post_id', post_id, 'message_id', message_id, 'kind', kind, 'note', note, 'status', status, 'created_at', created_at) FROM forum.reports WHERE reporter_id = $1").await?,
});
Ok(([("content-disposition", "attachment; filename=\"sorsfonalak-export.json\"")], Json(document)))
}
+36
View File
@@ -1024,12 +1024,39 @@ async fn export_and_delete_account(pool: PgPool) {
assert_eq!(r.status, StatusCode::CREATED, "{}", r.body);
let r = app.post("/v1/synastries", Some(&anna), json!({"chart1_id": b["id"], "chart2_id": a["id"]})).await;
assert_eq!(r.status, StatusCode::OK); // already exists
// Anna also wrote in the forum (services/forum keeps it in the same database).
let (anna_id,): (uuid::Uuid,) =
sqlx::query_as("SELECT id FROM users WHERE email = 'anna@example.com'").fetch_one(&app.pool).await.unwrap();
sqlx::query(
"INSERT INTO forum.members (user_id, nickname, nickname_key, avatar) \
VALUES ($1, 'Holdfény', 'holdfeny', 'hold-ejkek')",
)
.bind(anna_id)
.execute(&app.pool)
.await
.unwrap();
let thread: i64 = sqlx::query_scalar(
"INSERT INTO forum.threads (topic_id, author_id, title) VALUES (4, $1, 'Téli levesek') RETURNING id",
)
.bind(anna_id)
.fetch_one(&app.pool)
.await
.unwrap();
sqlx::query("INSERT INTO forum.posts (thread_id, author_id, is_opening, body) VALUES ($1, $2, true, 'Sütőtök')")
.bind(thread)
.bind(anna_id)
.execute(&app.pool)
.await
.unwrap();
let r = app.get("/v1/me/export", Some(&anna)).await;
assert_eq!(r.status, StatusCode::OK);
assert_eq!(r.body["charts"].as_array().unwrap().len(), 2);
assert_eq!(r.body["synastries"].as_array().unwrap().len(), 1);
assert!(r.body["login_methods"][0].get("password_hash").is_none());
assert_eq!(r.body["forum_profile"][0]["nickname"], "Holdfény");
assert_eq!(r.body["forum_posts"][0]["body"], "Sütőtök");
assert_eq!(r.body["forum_posts"][0]["thread_title"], "Téli levesek");
let r = app.call("DELETE", "/v1/me", Some(&anna), Some(json!({"confirm": "yes"}))).await;
assert_eq!(r.status, StatusCode::BAD_REQUEST);
@@ -1041,6 +1068,15 @@ async fn export_and_delete_account(pool: PgPool) {
assert_eq!(r.status, StatusCode::UNAUTHORIZED);
let (left,): (i64,) = sqlx::query_as("SELECT count(*) FROM charts").fetch_one(&app.pool).await.unwrap();
assert_eq!(left, 0);
// Her forum profile is gone; her thread stays, by "Törölt tag" (no author).
let (members, author): (i64, Option<uuid::Uuid>) = sqlx::query_as(
"SELECT (SELECT count(*) FROM forum.members), (SELECT author_id FROM forum.threads WHERE id = $1)",
)
.bind(thread)
.fetch_one(&app.pool)
.await
.unwrap();
assert_eq!((members, author), (0, None));
assert_eq!(app.get("/v1/me", Some(&bela)).await.status, StatusCode::OK);
}