Sharing a chart with its short summary, with link previews
The summary card gets a share button: a public link (/s/<slug>) with the wheel and the newest short summary, no name or birth data. The page carries og:/twitter: tags, and /s/<slug>/kep/<version>.png renders a 1200x630 preview (wheel, title, text, big three) with next/og and bundled fonts. The version changes with the summary, so Facebook fetches a rewritten one again. Backend: a shared chart comes with its newest finished summary, and sharing the same thing again returns the open link. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -628,6 +628,30 @@ async fn public_shares(pool: PgPool) {
|
||||
for hidden in ["input", "location", "time", "astronomy", "birth"] {
|
||||
assert!(shown.get(hidden).is_none(), "{hidden} must not be public");
|
||||
}
|
||||
assert!(r.body["summary"].is_null(), "no finished summary yet");
|
||||
|
||||
// the newest finished summary comes with the chart
|
||||
sqlx::query(
|
||||
"INSERT INTO analyses (id, kind, chart_id, requested_by, language, model, prompt_version, cache_key, \
|
||||
credits_charged, status, content, completed_at) \
|
||||
VALUES ($1, 'summary', $2::uuid, (SELECT id FROM users WHERE email = 'anna@example.com'), 'hu', 'm', 'v', \
|
||||
'k', 0, 'done', $3, now())",
|
||||
)
|
||||
.bind(uuid::Uuid::now_v7())
|
||||
.bind(chart_id)
|
||||
.bind(json!({"title": "Csendes erő", "summary": "Rövid **összefoglaló**."}))
|
||||
.execute(&app.pool)
|
||||
.await
|
||||
.unwrap();
|
||||
let r = app.get(&format!("/v1/public/shares/{slug}"), None).await;
|
||||
assert_eq!(r.body["summary"]["title"], "Csendes erő");
|
||||
assert_eq!(r.body["summary"]["summary"], "Rövid **összefoglaló**.");
|
||||
|
||||
// sharing the same again gives the open link
|
||||
let r = app
|
||||
.post("/v1/shares", Some(&anna), json!({"kind": "chart", "target_id": chart_id, "title": "A radixom"}))
|
||||
.await;
|
||||
assert_eq!((r.status, r.body["slug"].as_str()), (StatusCode::OK, Some(slug.as_str())));
|
||||
|
||||
let r = app
|
||||
.post("/v1/shares", Some(&anna), json!({"kind": "chart", "target_id": chart_id, "show_birth_data": true}))
|
||||
|
||||
Reference in New Issue
Block a user