deploy / deploy (push) Successful in 46s
- Écran d'administration supprimé (page, onglets de modération, alertes, appels admin). - « Signaler » (avis, commentaire, profil, liste) et « Signaler un bug » ouvrent un e-mail pré-rempli vers contact@bobinoo.org (motifs en rappel, références du contenu ; version et appareil pour un bug). - Remontée automatique des erreurs supprimée. À la place : une ancienne version ouverte qui ne trouve plus un fichier après une mise à jour se recharge d'elle-même (« Importing a module script failed »). - Base (20261130120000_remove_admin, appliquée) : 20 fonctions et 5 tables d'administration supprimées (admins, reports, bug_reports, client_errors, moderation_log) ; get_profile, get_review_comments, delete_review_comment, delete_shared_list et la garde de suspension réécrites sans « admin ». Suspension d'un compte : à la main dans Supabase. - 116 textes inutilisés retirés dans chacune des 18 langues. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YVo1qxKoBQCaMd7Ue8PGbe
181 lines
8.1 KiB
PL/PgSQL
181 lines
8.1 KiB
PL/PgSQL
-- Suppression de l'administration (30/11/2026) : plus d'écran admin, plus de signalements / bugs / erreurs
|
|
-- enregistrés en base. « Signaler » et « Signaler un bug » ouvrent désormais un e-mail vers contact@bobinoo.org.
|
|
-- La suspension d'un compte reste possible à la main dans Supabase (Table Editor → profiles → suspended).
|
|
-- Idempotent.
|
|
|
|
-- 1. ─── Fonctions gardées, sans la vérification « admin » ───
|
|
create or replace function public.azuu_suspended_guard()
|
|
returns trigger language plpgsql security definer set search_path = '' as $$
|
|
begin
|
|
-- Un membre ne peut pas changer « suspended » ; seul le tableau de bord Supabase (pas de compte connecté) le peut
|
|
if new.suspended is distinct from old.suspended and auth.uid() is not null then
|
|
raise exception 'forbidden';
|
|
end if;
|
|
return new;
|
|
end;
|
|
$$;
|
|
|
|
create or replace function public.delete_review_comment(p_id bigint)
|
|
returns jsonb language plpgsql security definer set search_path = '' as $$
|
|
declare
|
|
me uuid := auth.uid();
|
|
n integer;
|
|
begin
|
|
if me is null then raise exception 'auth'; end if;
|
|
delete from public.review_comments c
|
|
where c.id = p_id and (c.user_id = me or c.author_id = me);
|
|
get diagnostics n = row_count;
|
|
return jsonb_build_object('ok', n > 0);
|
|
end;
|
|
$$;
|
|
|
|
create or replace function public.delete_shared_list(p_list uuid)
|
|
returns jsonb language plpgsql security definer set search_path = '' as $$
|
|
begin
|
|
if not public.azuu_sl_owner(p_list) then raise exception 'forbidden'; end if;
|
|
delete from public.shared_lists where id = p_list; -- membres et titres : en cascade
|
|
return jsonb_build_object('ok', true);
|
|
end;
|
|
$$;
|
|
|
|
create or replace function public.get_review_comments(p_author uuid, p_item text)
|
|
returns jsonb language plpgsql stable security definer set search_path = '' as $$
|
|
declare
|
|
me uuid := auth.uid();
|
|
moderator boolean;
|
|
begin
|
|
if not public.azuu_review_visible(p_author, p_item) then
|
|
return jsonb_build_object('visible', false, 'can_moderate', false, 'comments', '[]'::jsonb);
|
|
end if;
|
|
-- L'auteur de l'avis peut supprimer les commentaires sous son avis
|
|
moderator := p_author = me;
|
|
return jsonb_build_object(
|
|
'visible', true,
|
|
'can_moderate', moderator,
|
|
'comments', coalesce((
|
|
select jsonb_agg(jsonb_build_object(
|
|
'id', c.id, 'body', c.body, 'created_at', c.created_at,
|
|
'user', jsonb_build_object('id', p.id, 'username', p.username, 'display_name', p.display_name, 'avatar_url', p.avatar_url),
|
|
'mine', c.user_id = me,
|
|
'can_delete', moderator or c.user_id = me
|
|
) order by c.created_at, c.id)
|
|
from (
|
|
select * from public.review_comments rc
|
|
where rc.author_id = p_author and rc.item_id = p_item
|
|
order by rc.created_at desc, rc.id desc
|
|
limit 200
|
|
) c
|
|
join public.profiles p on p.id = c.user_id
|
|
where not p.suspended or c.user_id = me
|
|
), '[]'::jsonb)
|
|
);
|
|
end;
|
|
$$;
|
|
|
|
create or replace function public.get_profile(p_username text)
|
|
returns jsonb language plpgsql stable security definer set search_path = '' as $$
|
|
declare
|
|
p public.profiles;
|
|
me uuid := auth.uid();
|
|
res jsonb;
|
|
begin
|
|
if me is null then
|
|
return null;
|
|
end if;
|
|
select * into p from public.profiles where username = lower(trim(p_username));
|
|
if not found then
|
|
return null;
|
|
end if;
|
|
if p.suspended and p.id <> me then
|
|
return null;
|
|
end if;
|
|
if p.id <> me and exists (select 1 from public.blocks b where b.blocker_id = p.id and b.blocked_id = me) then
|
|
return null;
|
|
end if;
|
|
res := public.profile_card(p) || jsonb_build_object(
|
|
'bio', p.bio,
|
|
'banner_url', p.banner_url,
|
|
'is_me', p.id = me,
|
|
'follows_me', exists (select 1 from public.follows where follower_id = p.id and following_id = me and status = 'accepted'),
|
|
'followers', (select count(*) from public.follows where following_id = p.id and status = 'accepted'),
|
|
'following', (select count(*) from public.follows where follower_id = p.id and status = 'accepted'),
|
|
'visible', public.can_view(p.id)
|
|
);
|
|
if public.can_view(p.id) then
|
|
res := res || jsonb_build_object(
|
|
'stats', jsonb_build_object(
|
|
'finished', (select count(*) from public.items where user_id = p.id and not deleted and data->>'status' = 'termine')
|
|
),
|
|
'top', (
|
|
select coalesce(jsonb_agg(public.public_item(data) order by data->'top'->>'category', (data->'top'->>'rank')), '[]'::jsonb)
|
|
from public.items i
|
|
where i.user_id = p.id and not i.deleted and jsonb_typeof(i.data->'top') = 'object'
|
|
and coalesce(
|
|
(select s.data->'topCategories' ? (i.data->'top'->>'category')
|
|
from public.settings s where s.user_id = p.id and jsonb_typeof(s.data->'topCategories') = 'array'),
|
|
true)
|
|
),
|
|
'recent', (
|
|
select coalesce(jsonb_agg(public.public_item(s.data) order by s.k desc nulls last), '[]'::jsonb)
|
|
from (
|
|
select data, coalesce(data->>'endDate', data->>'startDate') as k
|
|
from public.items
|
|
where user_id = p.id and not deleted and data->>'status' = 'termine'
|
|
order by k desc nulls last limit 5
|
|
) s
|
|
),
|
|
'watching', (
|
|
select coalesce(jsonb_agg(public.public_item(s.data) order by s.k desc nulls last), '[]'::jsonb)
|
|
from (
|
|
select data, coalesce(data->>'startDate', left(data->>'updatedAt', 10)) as k
|
|
from public.items
|
|
where user_id = p.id and not deleted and data->>'status' = 'en_cours'
|
|
order by k desc nulls last limit 8
|
|
) s
|
|
)
|
|
);
|
|
end if;
|
|
return res;
|
|
end;
|
|
$$;
|
|
|
|
-- 2. ─── Journal de modération : plus de trigger ───
|
|
drop trigger if exists profiles_suspended_log on public.profiles;
|
|
drop function if exists public.azuu_suspended_log();
|
|
|
|
-- 3. ─── Fonctions d'administration, de signalement et de remontée d'erreurs ───
|
|
drop function if exists public.admin_alerts();
|
|
drop function if exists public.admin_bug_reports(text, integer);
|
|
drop function if exists public.admin_clear_review(uuid, text);
|
|
drop function if exists public.admin_client_errors(text, integer);
|
|
drop function if exists public.admin_overview();
|
|
drop function if exists public.admin_recent_reviews(integer);
|
|
drop function if exists public.admin_report_action(text, text, uuid, text);
|
|
drop function if exists public.admin_reports(text, integer);
|
|
drop function if exists public.admin_set_bug_status(bigint, text);
|
|
drop function if exists public.admin_set_error_status(text, text);
|
|
drop function if exists public.admin_set_suspended(uuid, boolean);
|
|
drop function if exists public.admin_suspended_users(integer);
|
|
drop function if exists public.admin_users(text, integer);
|
|
drop function if exists public.azuu_admin_card(uuid);
|
|
drop function if exists public.report_content(text, text, uuid, text, text);
|
|
drop function if exists public.submit_bug_report(text, jsonb);
|
|
drop function if exists public.log_client_error(text, text, text, text, text, text);
|
|
drop function if exists public.azuu_scrub(text, integer);
|
|
drop function if exists public.is_admin();
|
|
|
|
-- 4. ─── Tables ───
|
|
drop table if exists public.reports;
|
|
drop table if exists public.bug_reports;
|
|
drop table if exists public.client_errors;
|
|
drop table if exists public.moderation_log;
|
|
drop table if exists public.admins;
|
|
|
|
-- 5. ─── Descriptions mises à jour ───
|
|
comment on table public.profiles is 'Profil public : pseudo, nom affiché, photo, bannière, bio, compte privé, compte suspendu (suspended : à cocher à la main dans Supabase, invisible pour les autres). Créé à l''inscription (azuu_new_user).';
|
|
comment on function public.azuu_suspended_guard() is 'Trigger (profiles) : un membre ne peut pas changer « suspended » (seulement depuis le tableau de bord Supabase).';
|
|
comment on function public.delete_review_comment(bigint) is 'App : supprimer mon commentaire (ou un commentaire sous mon avis).';
|
|
comment on function public.delete_shared_list(uuid) is 'App : supprimer une liste partagée (créateur).';
|
|
comment on function public.get_review_comments(uuid, text) is 'App : commentaires d''un avis.';
|
|
comment on function public.get_profile(text) is 'App : profil d''un pseudo (infos, compteurs, relation avec moi).';
|