1-- Denormalized threadgate upsert: Update posts table directly
2-- Threadgates control reply permissions - now stored in posts table
3-- Parameters: $1=actor_id, $2=post_rkey, $3=allow[], $4=hidden_actor_ids[], $5=hidden_rkeys[]
4-- $6=allowed_list_actor_ids[], $7=allowed_list_rkeys[]
5-- Note: We update the post record ($1, $2) with threadgate data
6-- The threadgate's own (actor_id, rkey, cid) are no longer stored separately
7
8UPDATE posts
9SET
10 threadgate_allow = $3::text[]::threadgate_rule[],
11 threadgate_hidden_actor_ids = $4::integer[],
12 threadgate_hidden_rkeys = $5::bigint[],
13 threadgate_allowed_list_actor_ids = $6::integer[],
14 threadgate_allowed_list_rkeys = $7::text[]
15WHERE actor_id = $1
16 AND rkey = $2