create or replace function public.hub_hide_reported_game(p_report bigint,p_reason text) returns void language plpgsql security definer set search_path='' as $$ declare game_id uuid; begin if auth.uid() is null or private.staff_rank()<1 then raise exception 'Staff permission denied' using errcode='42501'; end if; if p_reason is null or char_length(btrim(p_reason)) not between 10 and 2000 then raise exception 'Explain the moderation action'; end if; select content_id into game_id from private.community_reports where id=p_report and content_kind='game'; if game_id is null then raise exception 'Game report not found'; end if; update private.hub_games set published=false,updated_at=now() where id=game_id; insert into private.community_audit(actor,action,subject,detail) values(auth.uid(),'hide_reported_game',game_id::text,jsonb_build_object('report',p_report,'reason',btrim(p_reason))::text); end $$;