Files
bobinoo/supabase/migrations/20261128170000_mfa_reads_and_fixes.sql
T
Claude dbaec8e03e
deploy / deploy (push) Successful in 46s
Corrections issues de la revue de code (agents de test)
- Double authentification : l'écran du code se ferme bien après un code juste (la session « aal2 »
  prévient maintenant l'app) ; plus d'affichage furtif de l'app avant la vérification ; revérification
  au retour du réseau
- Serveur (migration 20261128170000, appliquée) : les lectures par fonction (profil, bibliothèque, fil,
  notifications, listes partagées, avis, recherche, blocages) exigent aussi le code pour un compte protégé ;
  une fiche restaurée ne compte plus comme « a noté » ; une demande d'abonnement refusée disparaît des notifications
- Catalogue : la grille continue de se charger après un passage par Journal / Listes
- Moyenne des notes de saison arrondie à la demi-étoile (et plus à l'étoile entière)
- Double tap sur « +1 » : plus de double message de fin de revisionnage ; « −1 » jamais ignoré
- Bouton « Ouvrir les Réglages » (clé TMDB retirée) supprimé de la recherche
- Pluriels russe, polonais et arabe complétés pour les notifications

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YVo1qxKoBQCaMd7Ue8PGbe
2026-11-28 09:08:01 +00:00

56 lines
3.7 KiB
SQL

-- Bobinoo — 28 nov. 2026, suite de la revue de code. Idempotent.
-- 1) Double authentification : les lectures par fonction (profil, bibliothèque, fil, notifications,
-- listes partagées, avis, recherche…) exigent aussi le code pour un compte protégé.
-- 2) Fil : une fiche restaurée (après suppression / import) ne compte plus comme « a noté ».
-- 3) Notifications : une demande d'abonnement refusée disparaît.
do $$
declare
r record;
def text;
begin
for r in select * from (values
('public.can_view(uuid)', 'select auth.uid() is not null and (', 'select auth.uid() is not null and public.azuu_mfa_ok() and ('),
('public.azuu_sl_member(uuid)', 'select auth.uid() is not null and exists (', 'select auth.uid() is not null and public.azuu_mfa_ok() and exists ('),
('public.get_feed(timestamp with time zone,integer)', 'where (p_before is null or l.created_at < p_before)', 'where public.azuu_mfa_ok() and (p_before is null or l.created_at < p_before)'),
('public.get_notifications()', 'where user_id = auth.uid() and kind in', 'where user_id = auth.uid() and public.azuu_mfa_ok() and kind in'),
('public.unread_notifications()', 'where n.user_id = auth.uid() and n.read_at is null', 'where n.user_id = auth.uid() and public.azuu_mfa_ok() and n.read_at is null'),
('public.mark_notifications_read()', 'where user_id = auth.uid() and read_at is null', 'where user_id = auth.uid() and public.azuu_mfa_ok() and read_at is null'),
('public.get_follow_requests()', 'where f.following_id = auth.uid() and f.status', 'where f.following_id = auth.uid() and public.azuu_mfa_ok() and f.status'),
('public.my_blocks()', 'where b.blocker_id = auth.uid()', 'where b.blocker_id = auth.uid() and public.azuu_mfa_ok()'),
('public.search_profiles(text)', 'if auth.uid() is null or char_length(term) < 2', 'if auth.uid() is null or not public.azuu_mfa_ok() or char_length(term) < 2'),
('public.title_reviews(text,integer)', 'if me is null or p_external_id', 'if me is null or not public.azuu_mfa_ok() or p_external_id'),
('public.get_shared_lists(text)', 'if me is null then', 'if me is null or not public.azuu_mfa_ok() then'),
('public.azuu_item_activity()', 'elsif tg_op = ''UPDATE'' and new.data ? ''rating''', 'elsif tg_op = ''UPDATE'' and old_st is not null and new.data ? ''rating''')
) v(fn, search, repl) loop
def := pg_get_functiondef(to_regprocedure(r.fn));
if position(r.repl in def) > 0 then continue; end if;
if position(r.search in def) = 0 then raise exception 'motif introuvable dans %', r.fn; end if;
execute replace(def, r.search, r.repl);
end loop;
end $$;
-- 3) Demande refusée (« retirer » par le compte suivi) : la notification « demande à te suivre » part avec
do $$
declare def text;
begin
def := pg_get_functiondef('public.azuu_follow_notify()'::regprocedure);
if position('-- Demande refusée ou annulée' in def) = 0 then
def := replace(def,
' if auth.uid() is distinct from old.follower_id then return null; end if;
if old.status = ''pending'' then
-- Demande annulée : elle disparaît simplement
delete from public.notifications where user_id = old.following_id and actor_id = old.follower_id and kind = ''follow_request'';
return null;
end if;',
' if old.status = ''pending'' then
-- Demande refusée ou annulée : elle disparaît simplement
delete from public.notifications where user_id = old.following_id and actor_id = old.follower_id and kind = ''follow_request'';
return null;
end if;
if auth.uid() is distinct from old.follower_id then return null; end if;');
if position('-- Demande refusée ou annulée' in def) = 0 then raise exception 'motif introuvable dans azuu_follow_notify'; end if;
execute def;
end if;
end $$;