Forum: asking about one's own chart, forecast or comparison
- "Kérdezek róla a fórumon" on the chart, yearly forecast and comparison pages: after a window that says what goes out, a share link made for the forum (never birth data, names or a title) and a new thread in "Égbolt és képletek" with it attached. - The question shows a card (Sun, Moon, Ascendant with sign, degree and house, the summary's title, a link to the shared page) to logged-in members only; visitors and search engines see only that there is one. The author can take it off, and deleting the question ends the link. - The shared page (/s/...) now shows comparisons (one wheel, the aspects, no names) and yearly forecasts (keys, timeline, transits, the detailed text; without the birthday's place); the backend shares forecasts. - The privacy notice (HU, EN) covers attached charts and muted members. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -1209,3 +1209,108 @@ async fn search_mutes_and_archived_topics(pool: PgPool) {
|
||||
app.call("PATCH", "/v1/forum/topics/torzsasztal", Some(&admin), json!({ "archived": false })).await;
|
||||
app.reply(&bea, sleep, "Még egy szó.", None).await;
|
||||
}
|
||||
|
||||
#[sqlx::test(migrator = "db::MIGRATOR")]
|
||||
async fn a_question_about_ones_chart(pool: PgPool) {
|
||||
let app = TestApp::new(pool);
|
||||
let anna = app.member("anna@example.com", "Csendesvíz", &["user"]).await;
|
||||
let bea = app.member("bea@example.com", "Holdfény", &["user"]).await;
|
||||
// Anna's chart (made-up data) and a share of it made for the forum; Bea's own share.
|
||||
let chart = Uuid::now_v7();
|
||||
let result = json!({
|
||||
"time": {"time_known": true},
|
||||
"points": [
|
||||
{"id": "sun", "sign": "leo", "degree_in_sign": 12.7, "house": 10},
|
||||
{"id": "moon", "sign": "pisces", "degree_in_sign": 3.2, "house": 5}
|
||||
],
|
||||
"angles": {"ascendant": {"sign": "scorpio", "degree_in_sign": 21.9}}
|
||||
});
|
||||
sqlx::query(
|
||||
"INSERT INTO charts (id, owner_id, label, birth_data, result, chart_hash, kind) \
|
||||
VALUES ($1, $2, 'Kovács Anna', '{}', $3, 'h', 'own')",
|
||||
)
|
||||
.bind(chart)
|
||||
.bind(anna.id)
|
||||
.bind(&result)
|
||||
.execute(&app.pool)
|
||||
.await
|
||||
.unwrap();
|
||||
for (slug, owner, for_forum) in [("annaforum000001", anna.id, true), ("annaplain000001", anna.id, false)] {
|
||||
sqlx::query(
|
||||
"INSERT INTO shares (id, owner_id, slug, kind, chart_id, for_forum) VALUES ($1, $2, $3, 'chart', $4, $5)",
|
||||
)
|
||||
.bind(Uuid::now_v7())
|
||||
.bind(owner)
|
||||
.bind(slug)
|
||||
.bind(chart)
|
||||
.bind(for_forum)
|
||||
.execute(&app.pool)
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
// Only one's own forum share can go with a question.
|
||||
let preview = app.get("/v1/forum/share-card/annaforum000001", Some(&anna)).await;
|
||||
assert_eq!(preview["title"], "Születési képlet");
|
||||
assert_eq!(preview["points"][0], json!({"id": "sun", "sign": "leo", "degree": 12, "house": 10}));
|
||||
assert_eq!(preview["points"][2]["id"], "ascendant");
|
||||
assert!(!preview.to_string().contains("Kovács"), "no names");
|
||||
for (slug, who) in [("annaplain000001", &anna), ("annaforum000001", &bea), ("nincsilyen", &anna)] {
|
||||
let (status, _) = app.call("GET", &format!("/v1/forum/share-card/{slug}"), Some(who), Value::Null).await;
|
||||
assert_eq!(status, StatusCode::BAD_REQUEST, "{slug}");
|
||||
}
|
||||
let (status, _) = app
|
||||
.call(
|
||||
"POST",
|
||||
"/v1/forum/threads",
|
||||
Some(&bea),
|
||||
json!({ "topic": "egbolt-es-kepletek", "title": "Az övé", "body": "Kérdés", "share": "annaforum000001" }),
|
||||
)
|
||||
.await;
|
||||
assert_eq!(status, StatusCode::BAD_REQUEST);
|
||||
let (status, created) = app
|
||||
.call(
|
||||
"POST",
|
||||
"/v1/forum/threads",
|
||||
Some(&anna),
|
||||
json!({
|
||||
"topic": "egbolt-es-kepletek",
|
||||
"title": "Mit jelent a Hold az ötödik házban?",
|
||||
"body": "Sokat gondolkodom rajta.",
|
||||
"share": "annaforum000001"
|
||||
}),
|
||||
)
|
||||
.await;
|
||||
assert_eq!(status, StatusCode::CREATED, "{created}");
|
||||
let id = created["id"].as_i64().unwrap();
|
||||
|
||||
// Members see the card; a visitor only that there is one.
|
||||
let shown = app.get(&format!("/v1/forum/threads/{id}"), Some(&bea)).await;
|
||||
assert_eq!(shown["posts"][0]["share"]["slug"], "annaforum000001");
|
||||
assert_eq!(shown["posts"][0]["share"]["points"][1]["sign"], "pisces");
|
||||
let public = app.get(&format!("/v1/forum/threads/{id}"), None).await;
|
||||
assert_eq!(public["posts"][0]["share"], json!({ "kind": "chart", "locked": true }));
|
||||
assert!(!public.to_string().contains("annaforum000001"));
|
||||
|
||||
// Revoked on the main site: the card says so.
|
||||
sqlx::query("UPDATE shares SET revoked_at = now() WHERE slug = 'annaforum000001'")
|
||||
.execute(&app.pool)
|
||||
.await
|
||||
.unwrap();
|
||||
let shown = app.get(&format!("/v1/forum/threads/{id}"), Some(&bea)).await;
|
||||
assert_eq!(shown["posts"][0]["share"]["revoked"], true);
|
||||
assert!(shown["posts"][0]["share"].get("points").is_none());
|
||||
|
||||
// The author takes it off (only she may): the card goes, the link stops working.
|
||||
sqlx::query("UPDATE shares SET revoked_at = NULL WHERE slug = 'annaforum000001'").execute(&app.pool).await.unwrap();
|
||||
let opening = shown["posts"][0]["id"].as_i64().unwrap();
|
||||
let uri = format!("/v1/forum/posts/{opening}/share");
|
||||
assert_eq!(app.call("DELETE", &uri, Some(&bea), Value::Null).await.0, StatusCode::FORBIDDEN);
|
||||
assert_eq!(app.call("DELETE", &uri, Some(&anna), Value::Null).await.0, StatusCode::NO_CONTENT);
|
||||
assert!(app.get(&format!("/v1/forum/threads/{id}"), Some(&bea)).await["posts"][0]["share"].is_null());
|
||||
let revoked: bool = sqlx::query_scalar("SELECT revoked_at IS NOT NULL FROM shares WHERE slug = 'annaforum000001'")
|
||||
.fetch_one(&app.pool)
|
||||
.await
|
||||
.unwrap();
|
||||
assert!(revoked);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user