Weekly horoscope landing page, link previews for the forum, and fixes from the review
- /heti-horoszkop for visitors: what it is, a real example written for the example chart, login and sign-up buttons; its own link preview image. - Forum: link previews (image, title; a public thread's opening words) for every forum page; none of a members-only thread's content. - Review fixes: a removed thread's photos are no longer served; public photos are cached for an hour, not a year (removals take effect); photos of threads removed a year ago are cleaned up; deleting one forum question no longer revokes the chart link another question still shows; the daily digest leaves out closed topics the member is no longer in; typing notices at most one a second per connection; the weekly page asks for the text once and then only reads it (no repeated paid runs after a failure); turning the Monday e-mail back on from the e-mail page waits for next Monday, like the site's switch; the week's last day is right in the week the clocks go back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -65,7 +65,12 @@ pub async fn run_once(db: &PgPool, base_url: &str, any_time: bool) -> Result<usi
|
||||
for m in due {
|
||||
let threads: Vec<(String, i64)> = sqlx::query_as(
|
||||
"SELECT th.title, count(*) FROM forum.posts p JOIN forum.threads th ON th.id = p.thread_id \
|
||||
JOIN forum.topics tp ON tp.id = th.topic_id \
|
||||
WHERE p.deleted_at IS NULL AND th.deleted_at IS NULL AND p.author_id IS DISTINCT FROM $1 \
|
||||
AND (tp.visibility <> 'restricted' \
|
||||
OR EXISTS (SELECT 1 FROM forum.topic_members tm \
|
||||
WHERE tm.topic_id = tp.id AND tm.user_id = $1 AND tm.status = 'approved') \
|
||||
OR EXISTS (SELECT 1 FROM users mu WHERE mu.id = $1 AND mu.roles && ARRAY['moderator', 'admin'])) \
|
||||
AND p.created_at > $2 \
|
||||
AND p.id > COALESCE((SELECT r.last_post_id FROM forum.reads r \
|
||||
WHERE r.user_id = $1 AND r.thread_id = th.id), 0) \
|
||||
@@ -382,6 +387,50 @@ mod tests {
|
||||
.unwrap();
|
||||
assert_eq!(run_once(&pool, "https://sorsfonalak.hu", true).await.unwrap(), 0);
|
||||
}
|
||||
|
||||
#[sqlx::test(migrator = "db::MIGRATOR")]
|
||||
async fn a_closed_topic_only_for_its_members(pool: PgPool) {
|
||||
let anna = member(&pool, "anna@example.com", "Anna", "off", "daily").await;
|
||||
let bea = member(&pool, "bea@example.com", "Bea", "off", "daily").await;
|
||||
let cili = member(&pool, "cili@example.com", "Cili", "off", "off").await;
|
||||
let topic: i16 = sqlx::query_scalar(
|
||||
"INSERT INTO forum.topics (id, slug, name, description, visibility, position) \
|
||||
VALUES (90, 'zart-kor', 'Zárt kör', 'Próba', 'restricted', 90) RETURNING id",
|
||||
)
|
||||
.fetch_one(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
// Anna is still in; Bea followed the thread while she was, and has left since.
|
||||
sqlx::query("INSERT INTO forum.topic_members (topic_id, user_id, status) VALUES ($1, $2, 'approved')")
|
||||
.bind(topic)
|
||||
.bind(anna)
|
||||
.execute(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
let thread: i64 = sqlx::query_scalar(
|
||||
"INSERT INTO forum.threads (topic_id, author_id, title) VALUES ($1, $2, 'Titkos cím') RETURNING id",
|
||||
)
|
||||
.bind(topic)
|
||||
.bind(cili)
|
||||
.fetch_one(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
sqlx::query("INSERT INTO forum.follows (user_id, thread_id) VALUES ($1, $2), ($3, $2)")
|
||||
.bind(anna)
|
||||
.bind(thread)
|
||||
.bind(bea)
|
||||
.execute(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
post(&pool, thread, cili, None).await;
|
||||
|
||||
assert_eq!(run_once(&pool, "https://sorsfonalak.hu", true).await.unwrap(), 1);
|
||||
let to: Vec<String> = sqlx::query_scalar("SELECT to_email FROM email_outbox WHERE template = 'forum_digest'")
|
||||
.fetch_all(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(to, ["anna@example.com"], "the title stays inside the closed topic");
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user