Forum: daily sky thread, listeners, mentions, own avatars, restricted topics
- The worker opens a "Mai égbolt" thread every morning from the day's sky (no AI), pinned for the day. - Volunteer listeners (from the Kereső rank) get a badge, a count of the threads asking to be heard that still wait for a reply, and, if they ask, an e-mail after two hours of waiting. - "@Holdfény" names a member (nicknames with spaces too): they follow the thread, hear of it live and, if they asked, by e-mail; a search helps typing it. - From the Kereső rank a member may upload an own avatar: a small square JPEG without metadata in the object storage (now a shared crate with the backend), served by the forum; moderators can put the starter back. - The "Támogató" badge for buyers who switch it on. - The admin creates and edits topics; restricted ones are read by their approved members, who ask to join and moderators decide. - "Most itt vannak" on the front page; the weekly summary e-mail on Sunday evening for those who ask (off by default). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -217,3 +217,48 @@ pub async fn notify_reporters(state: &AppState, reporters: &[Option<Uuid>], outc
|
||||
notify_user(state, reporter, "forum_report_result", payload).await;
|
||||
}
|
||||
}
|
||||
|
||||
/// Members named in a post ("@Holdfény") who asked for an e-mail about it
|
||||
/// (not while online, one per thread an hour).
|
||||
pub async fn after_mention(state: &AppState, thread_id: i64, post_id: i64, author: Uuid, users: &[Uuid], body: &str) {
|
||||
let result: Result<(), sqlx::Error> = async {
|
||||
let recipients: Vec<Recipient> = sqlx::query_as(&format!(
|
||||
"SELECT m.user_id, u.email, u.locale, m.nickname, m.email_token \
|
||||
FROM forum.members m JOIN users u ON u.id = m.user_id \
|
||||
WHERE m.user_id = ANY($1) AND m.email_mentions = 'instant' AND {OFFLINE} \
|
||||
AND NOT EXISTS (SELECT 1 FROM email_outbox e WHERE e.user_id = m.user_id \
|
||||
AND e.template IN ('forum_mention', 'forum_reply') \
|
||||
AND e.payload->>'thread_id' = $2::text AND e.created_at > now() - interval '1 hour')"
|
||||
))
|
||||
.bind(users)
|
||||
.bind(thread_id)
|
||||
.fetch_all(&state.db)
|
||||
.await?;
|
||||
if recipients.is_empty() {
|
||||
return Ok(());
|
||||
}
|
||||
let (title, who): (String, Option<String>) = sqlx::query_as(
|
||||
"SELECT th.title, (SELECT nickname FROM forum.members WHERE user_id = $2) FROM forum.threads th WHERE th.id = $1",
|
||||
)
|
||||
.bind(thread_id)
|
||||
.bind(author)
|
||||
.fetch_one(&state.db)
|
||||
.await?;
|
||||
let url = format!("{}/forum/szal/{thread_id}-{}#h{post_id}", state.base_url, text::slug(&title));
|
||||
for to in &recipients {
|
||||
let payload = json!({
|
||||
"url": url,
|
||||
"author": who,
|
||||
"thread_title": title,
|
||||
"thread_id": thread_id.to_string(),
|
||||
"excerpt": body.chars().take(300).collect::<String>(),
|
||||
});
|
||||
queue(&state.db, &state.base_url, to, "forum_mention", payload).await?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
.await;
|
||||
if let Err(e) = result {
|
||||
tracing::error!(error = %e, thread = thread_id, "queueing the mention e-mails");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user