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:
@@ -99,10 +99,12 @@ pub struct PostRow {
|
||||
pub system: bool,
|
||||
/// The post this one answered (which may sit on the same level).
|
||||
pub reply_to_id: Option<i64>,
|
||||
/// A chart, forecast or synastry shared with the question.
|
||||
pub share_id: Option<Uuid>,
|
||||
}
|
||||
|
||||
pub const POST_COLUMNS: &str = "id, thread_id, parent_id, is_opening, author_id, body, created_at, edited_at, helped_at, deleted_at, deleted_by, \
|
||||
delete_reason, system, reply_to_id";
|
||||
delete_reason, system, reply_to_id, share_id";
|
||||
|
||||
/// Posts as the thread page shows them: authors, reactions, the viewer's own
|
||||
/// reaction. A removed post keeps its place with the reason; only
|
||||
@@ -110,6 +112,8 @@ pub const POST_COLUMNS: &str = "id, thread_id, parent_id, is_opening, author_id,
|
||||
pub async fn posts_json(db: &PgPool, viewer: &Viewer, posts: &[PostRow]) -> ApiResult<Vec<Value>> {
|
||||
let ids: Vec<i64> = posts.iter().map(|p| p.id).collect();
|
||||
let people = authors(db, posts.iter().filter_map(|p| p.author_id)).await?;
|
||||
let shares: Vec<Uuid> = posts.iter().filter(|p| p.deleted_at.is_none()).filter_map(|p| p.share_id).collect();
|
||||
let cards = super::attachments::cards(db, viewer, &shares).await?;
|
||||
let counts: Vec<(i64, String, i64)> =
|
||||
sqlx::query_as("SELECT post_id, kind, count(*) FROM forum.reactions WHERE post_id = ANY($1) GROUP BY 1, 2")
|
||||
.bind(&ids)
|
||||
@@ -187,6 +191,7 @@ pub async fn posts_json(db: &PgPool, viewer: &Viewer, posts: &[PostRow]) -> ApiR
|
||||
"reply_to": reply_to,
|
||||
// The viewer muted the author: the page folds it up.
|
||||
"muted": p.author_id.is_some_and(|a| viewer.mutes.contains(&a)),
|
||||
"share": p.share_id.and_then(|id| cards.get(&id).cloned()),
|
||||
});
|
||||
if moderator {
|
||||
post["down"] = json!(down);
|
||||
@@ -315,6 +320,9 @@ pub struct CreateThread {
|
||||
body: String,
|
||||
#[serde(default)]
|
||||
intent: Option<String>,
|
||||
/// A share made for the forum on the main site (`/s/<slug>`).
|
||||
#[serde(default)]
|
||||
share: Option<String>,
|
||||
}
|
||||
|
||||
/// Starts a thread with its opening post; the author follows it.
|
||||
@@ -338,6 +346,10 @@ pub async fn create(
|
||||
}
|
||||
let title = text::title(&req.title)?;
|
||||
let body = text::body(&req.body)?;
|
||||
let share = match req.share.as_deref().filter(|s| !s.trim().is_empty()) {
|
||||
Some(slug) => Some(super::attachments::attachable(&state.db, member, slug).await?),
|
||||
None => None,
|
||||
};
|
||||
let intent = match req.intent.as_deref() {
|
||||
Some(i @ ("listen" | "advice")) => Some(i.to_string()),
|
||||
None | Some("") => listening.then(|| "listen".to_string()),
|
||||
@@ -356,11 +368,13 @@ pub async fn create(
|
||||
.fetch_one(&mut *tx)
|
||||
.await?;
|
||||
let post_id: i64 = sqlx::query_scalar(
|
||||
"INSERT INTO forum.posts (thread_id, author_id, is_opening, body) VALUES ($1, $2, true, $3) RETURNING id",
|
||||
"INSERT INTO forum.posts (thread_id, author_id, is_opening, body, share_id) \
|
||||
VALUES ($1, $2, true, $3, $4) RETURNING id",
|
||||
)
|
||||
.bind(thread_id)
|
||||
.bind(member.user_id)
|
||||
.bind(&body)
|
||||
.bind(share)
|
||||
.fetch_one(&mut *tx)
|
||||
.await?;
|
||||
after_post(&mut tx, member.user_id, thread_id, post_id).await?;
|
||||
|
||||
Reference in New Issue
Block a user