code wiki / _hdl_build / nx_cms_forum.nx
nx_cms_forum.nx source
↩ module page · 43 lines · 2435 B
1// nx_cms_forum.nx -- CMS COMMUNITY FORUMS (sovereign threaded discussions). The bbPress/BuddyPress class,
2// made Nishi-native and DRY: a forum reply is moderated by the EXISTING nx_cms_comments engine (rule 15 --
3// the forum does NOT re-implement spam scoring or visibility, it COMPOSES the proven module), so the same
4// privacy-native on-box moderation that protects comments protects forum posts. The forum adds only what is
5// genuinely its own: per-thread STATE (open/locked) gating new replies, and a DETERMINISTIC ordering rank
6// where pinned/sticky threads sort above the rest. license_tier: ORIGINAL
7import "nx_cms_comments.nx"
8import "nx_syscalls.nx"
9
10// thread states
11const NX_FORUM_OPEN: i64 = 0
12const NX_FORUM_LOCKED: i64 = 1
13
14const NX_FORUM_REFUSED: i64 = 0 - 1 // a reply rejected because the thread is locked
15
16// ordering bands / recency horizon (the data-driven seam; prod = svc-config, rule 11)
17const NX_FORUM_BAND: i64 = 1000000000
18const NX_FORUM_HORIZON: i64 = 1000000000
19
20// can a new reply be posted to a thread in this state?
21func forum_can_reply(state: i64) -> i64 { if state == NX_FORUM_OPEN { return 1 } return 0 }
22
23// post a reply to a thread: REFUSED (-1) if the thread is locked; otherwise returns the moderation
24// status the reply lands in by COMPOSING nx_cms_comments (clean -> PENDING, link/banned -> SPAM). The
25// forum never auto-publishes -- a reply is queued/withheld exactly like a comment until approved.
26func forum_post_reply(state: i64, body: *u8, n: i64) -> i64 {
27 if forum_can_reply(state) == 0 { return NX_FORUM_REFUSED }
28 let score: i64 = cmt_score(body, n)
29 return cmt_classify(score) // NX_CMT_PENDING | NX_CMT_SPAM
30}
31
32// is a forum reply publicly visible? DELEGATES to the moderation engine: only APPROVED renders
33// (pending/spam/trash withheld) -- identical policy to comments, by reuse not by copy.
34func forum_reply_visible(status: i64) -> i64 { return cmt_visible_public(status) }
35
36// deterministic thread ordering rank (SMALLER = higher in the list): pinned threads occupy the top band
37// regardless of recency; within a band, more-recent activity ranks higher. Pure function of its inputs,
38// so the thread list is reproducible with no stored sort state.
39func forum_thread_rank(pinned: i64, last_activity: i64) -> i64 {
40 var band: i64 = 1
41 if pinned == 1 { band = 0 }
42 return band * NX_FORUM_BAND + (NX_FORUM_HORIZON - last_activity)
43}