diff --git a/CLAUDE.md b/CLAUDE.md index f422d61..0ecd9b9 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -65,7 +65,7 @@ npm run build # build de prod - **Appels aux données publiques** (proxy TMDB, notes Trakt) : `publicFetch` dans `cloud/api.ts`, sans aucun en-tête → pas de pré-requête CORS (un aller-retour au lieu de deux). Limite côté serveur par adresse IP (tmdb 1000, ratings 400 / 10 min). Les données perso restent sur `cloudFetch` (jeton). ## État (au 28 nov. 2026) -- **Toutes les migrations de `supabase/migrations/` sont appliquées en ligne**, jusqu'à `20261130170000_admin_set_admin.sql` incluse (pg_net supprimée, index des notifications revus, réserve des notes Trakt ; notifications aux abonnés en une requête, quota vérifié une fois par envoi (trigger `*_quota_stmt`), fiche renvoyée à l'identique non réécrite). +- **Toutes les migrations de `supabase/migrations/` sont appliquées en ligne**, jusqu'à `20261201110000_notification_prefs.sql` incluse (pg_net supprimée, index des notifications revus, réserve des notes Trakt ; notifications aux abonnés en une requête, quota vérifié une fois par envoi (trigger `*_quota_stmt`), fiche renvoyée à l'identique non réécrite). - **29 nov. 2026** : 123 avis du compte de Romain contenaient « Réalisation : … » (ancien import, `legacyImport.ts`, corrigé). Lignes retirées en base (la copie de sauvegarde a été supprimée le même jour, correction validée). - **Affiches** : une fiche garde l'**adresse** de l'affiche (TMDB w342 / AniList), jamais l'image copiée en base64 (≈ 50 Ko par fiche, renvoyés à chaque modification et chez les amis). Seule une image choisie dans la galerie (EditDetails, 360 px) est intégrée. Le 29 nov. 2026, 109 affiches intégrées (342 px, copies automatiques) ont été remplacées par leur adresse TMDB : base des fiches 5,95 Mo → 267 Ko. - **Cache (service worker, `vite.config.ts`)** : pré-téléchargement ~1 Mo (app + français). Les 17 autres langues (`assets/locale-*`) et les variantes de police sont mises en cache à la demande (`app-files`). Caches d'exécution : `posters` (petites images TMDB/AniList, 1500), `backdrops` (grandes images, 80) — réponses opaques acceptées (`posters-v2` / `backdrops-v2`, d'un essai abandonné, sont supprimés au lancement par `main.tsx`), `catalog` (fiches TMDB avec `append_to_response`, saisons, personnes, notes Trakt : StaleWhileRevalidate 14 j ; jamais `/tv/123` seul, recherche, sorties ni données perso). React est dans son propre fichier (`react-*.js`), gardé d'une version à l'autre. @@ -78,7 +78,7 @@ npm run build # build de prod - **Écrans à la demande** : toujours `lazyPreload` (`src/lib/lazyPreload.tsx`) et non `React.lazy` seul — avec `lazy`, la première ouverture d'un écran déjà téléchargé est retardée d'environ 300 ms par React. Ajouter l'écran à `preloadScreens` / `preloadSocial` / `preloadCatalogViews` (sauf l'admin). - **Compression** : `deploy/nginx/site.conf` active gzip (JS, CSS, JSON, SVG), avec `gzip_http_version 1.0` car le proxy en façade parle HTTP/1.0. Sans ça les fichiers partaient bruts. Mesure Lighthouse mobile (1re visite, 29 nov. 2026) : score 67 → 97, premier affichage 3,9 → 1,8 s, poids 789 → 248 Ko. - **Anciennes icônes installées depuis kino.rdacet.fr / azuucine.rdacet.fr** : ces adresses n'existent plus, l'app installée tourne sur sa copie (plus de mises à jour) et les fonctions serveur la refusent (CORS) → « Impossible de joindre le serveur ». Solution : supprimer l'icône et réinstaller depuis https://bobinoo.org. La date de la version est affichée en bas des Réglages. -- **Notifications** (dans l'app, pas de push) : abonnements (`new_follower`, `follow_request`, `unfollow`, `follow_accepted`, trigger `follows_notify`), réaction / commentaire sur mon avis (`reaction`, `review_comment`, triggers sur `review_reactions` / `review_comments`), activité des comptes suivis (`friend_review`, `friend_started`, `friend_added`, trigger `items_notify` → `azuu_notify_followers`, rafales regroupées sur 3 h). Pas de notification pour les listes perso (privées). RPC `get_notifications` (avec le titre lié) / `unread_notifications` / `mark_notifications_read`. La fonction Edge `send-push` répond 410 : à supprimer depuis le tableau de bord Supabase. +- **Notifications** (dans l'app, pas de push) : abonnements (`new_follower`, `follow_request`, `unfollow`, `follow_accepted`, trigger `follows_notify`), réaction / commentaire sur mon avis (`reaction`, `review_comment`, triggers sur `review_reactions` / `review_comments`), activité des comptes suivis (`friend_review`, `friend_started`, `friend_added`, trigger `items_notify` → `azuu_notify_followers`, rafales regroupées sur 3 h). Pas de notification pour les listes perso (privées). RPC `get_notifications` (avec le titre lié) / `unread_notifications` / `mark_notifications_read`. **Choix par type** (Réglages → Notifications, `NotificationSettings.tsx`) : `settings.notifOff` (synchronisé) ; le trigger `notifications_wanted` ne crée pas un type désactivé, et `get_notifications` / `unread_notifications` masquent ceux déjà reçus. La fonction Edge `send-push` répond 410 : à supprimer depuis le tableau de bord Supabase. - **Administration = console séparée** (`docs/admin.md`) : site `admin/` (build `npm run build:admin` → `dist-admin/`), jamais dans l'app publique. Servi par nginx sur https://admin.bobinoo.org (`deploy/nginx/admin.conf`, limite d'appels, CSP stricte). Appels → fonction Edge `admin` (secret `X-Admin-Gate` ajouté par nginx + jeton aal2 obligatoire + `admin.admins`) → schéma `admin` (non exposé par l'API) par connexion directe. Journal `admin.journal` en ajout seulement. Dans l'app : « Signaler » et « Signaler un bug » ouvrent un e-mail vers contact@bobinoo.org (`components/moderation/BugReport.tsx`). Après une mise à jour, une ancienne version qui ne trouve plus un fichier se recharge d'elle-même (`ErrorBoundary`). - **E-mails du compte** (inscription, mot de passe oublié, changement d'adresse) : envoyés par `contact@bobinoo.org` (OVH Zimbra Starter, SMTP `ssl0.ovh.net:465`, DKIM actif), modèles dans `docs/emails/`. Testé le 30 nov. 2026 : reçu en boîte de réception, lien de confirmation OK. Limite Supabase : 30 e-mails / heure. Webmail : https://mail.bobinoo.org (redirection vers le webmail OVH, `deploy/nginx/mail.conf`). `contact@bobinoo.org` est aussi l'adresse de contact des pages légales, de « Signaler un bug » et du Play Store. - **Retirés (27-28 nov. 2026)** : défis, couleur d'accent au choix, apparences Nuit/Étoilé, notation sur 10 (les notes restent stockées sur 10 en interne, affichées sur 5 étoiles). diff --git a/admin/src/screens.tsx b/admin/src/screens.tsx index a66e748..b0a9528 100644 --- a/admin/src/screens.tsx +++ b/admin/src/screens.tsx @@ -353,6 +353,13 @@ export function Comments({ token, onAuthError }: ScreenProps) { // ─── Journal ─── +/** « Mozilla/5.0 (iPhone; …) … Safari/… » → « Safari · iPhone » */ +function deviceLabel(ua: string): string { + const os = /iPhone/.test(ua) ? 'iPhone' : /iPad/.test(ua) ? 'iPad' : /Android/.test(ua) ? 'Android' : /Windows/.test(ua) ? 'Windows' : /Mac OS X/.test(ua) ? 'Mac' : /Linux/.test(ua) ? 'Linux' : '' + const browser = /Edg\//.test(ua) ? 'Edge' : /Firefox\//.test(ua) ? 'Firefox' : /OPR\//.test(ua) ? 'Opera' : /Chrome\//.test(ua) ? 'Chrome' : /Safari\//.test(ua) ? 'Safari' : '' + return [browser, os].filter(Boolean).join(' · ') || ua.slice(0, 80) +} + export function Journal({ token, onAuthError }: ScreenProps) { const { rows, more, error, loadMore } = usePaged(token, 'journal', onAuthError) return ( @@ -370,9 +377,9 @@ export function Journal({ token, onAuthError }: ScreenProps) { {fmt(j.at)} {j.admin && ` · par @${j.admin}`}

- {Object.entries(j.details).map(([k, v]) => ( + {Object.entries(j.details && typeof j.details === 'object' ? j.details : {}).map(([k, v]) => (

- {k} : {String(v)} + {k} : {k === 'appareil' && typeof v === 'string' ? deviceLabel(v) : String(v)}

))} diff --git a/src/components/NotificationSettings.tsx b/src/components/NotificationSettings.tsx new file mode 100644 index 0000000..109d429 --- /dev/null +++ b/src/components/NotificationSettings.tsx @@ -0,0 +1,73 @@ +import { t, type TKey } from '../i18n' +import { cx } from '../lib/utils' +import { useMedia } from '../store' +import { NOTIF_KINDS, type NotifKind } from '../types' +import { SectionTitle } from './ui' + +const GROUPS: { title: TKey; kinds: [NotifKind, TKey][] }[] = [ + { + title: 'notifPrefs.follows', + kinds: [ + ['new_follower', 'notifPrefs.new_follower'], + ['follow_request', 'notifPrefs.follow_request'], + ['follow_accepted', 'notifPrefs.follow_accepted'], + ['unfollow', 'notifPrefs.unfollow'], + ], + }, + { + title: 'notifPrefs.reviews', + kinds: [ + ['reaction', 'notifPrefs.reaction'], + ['review_comment', 'notifPrefs.review_comment'], + ], + }, + { + title: 'notifPrefs.friends', + kinds: [ + ['friend_review', 'notifPrefs.friend_review'], + ['friend_started', 'notifPrefs.friend_started'], + ['friend_added', 'notifPrefs.friend_added'], + ], + }, +] + +/** + * Réglages → Notifications : ce qu'on veut recevoir dans la cloche. + * Les types désactivés sont dans les réglages synchronisés (notifOff) : le serveur ne les crée plus + * et masque ceux déjà reçus (migration 20261201110000_notification_prefs). + */ +export default function NotificationSettings() { + const { settings, updateSettings } = useMedia() + const off = new Set(settings.notifOff ?? []) + const toggle = (kind: NotifKind) => { + const next = new Set(off) + if (next.has(kind)) next.delete(kind) + else next.add(kind) + updateSettings({ notifOff: NOTIF_KINDS.filter((k) => next.has(k)) }) + } + + return ( + <> + {t('notif.title')} +

{t('notifPrefs.hint')}

+
+ {GROUPS.map((g) => ( +
+

{t(g.title)}

+ {g.kinds.map(([kind, label]) => { + const on = !off.has(kind) + return ( + + ) + })} +
+ ))} +
+ + ) +} diff --git a/src/i18n/locales/ar.ts b/src/i18n/locales/ar.ts index 3056341..e216c6d 100644 --- a/src/i18n/locales/ar.ts +++ b/src/i18n/locales/ar.ts @@ -1169,6 +1169,19 @@ const dict: Translations = { "translate.showTranslation": "عرض الترجمة", "translate.translate": "ترجمة ({lang})", "translate.translating": "جارٍ الترجمة…", + "notifPrefs.hint": "اختر ما يظهر تحت الجرس. ما توقفه لن يُرسل بعد الآن.", + "notifPrefs.follows": "المتابعات", + "notifPrefs.reviews": "مراجعاتي", + "notifPrefs.friends": "نشاط من أتابعهم", + "notifPrefs.new_follower": "متابع جديد", + "notifPrefs.follow_request": "طلب متابعة", + "notifPrefs.follow_accepted": "تم قبول الطلب", + "notifPrefs.unfollow": "إلغاء المتابعة", + "notifPrefs.reaction": "تفاعلات على مراجعاتي", + "notifPrefs.review_comment": "تعليقات على مراجعاتي", + "notifPrefs.friend_review": "مراجعة جديدة", + "notifPrefs.friend_started": "بدء مسلسل", + "notifPrefs.friend_added": "إضافة إلى «للمشاهدة»", } export default dict diff --git a/src/i18n/locales/de.ts b/src/i18n/locales/de.ts index aa6e1c8..ddd48f5 100644 --- a/src/i18n/locales/de.ts +++ b/src/i18n/locales/de.ts @@ -1020,6 +1020,19 @@ const dict: Translations = { "translate.showTranslation": "Übersetzung anzeigen", "translate.translate": "Übersetzen ({lang})", "translate.translating": "Wird übersetzt…", + "notifPrefs.hint": "Wähle aus, was unter der Glocke erscheint. Was du ausschaltest, wird nicht mehr gesendet.", + "notifPrefs.follows": "Folgen", + "notifPrefs.reviews": "Meine Kritiken", + "notifPrefs.friends": "Aktivität von Leuten, denen ich folge", + "notifPrefs.new_follower": "Neuer Follower", + "notifPrefs.follow_request": "Folgeanfrage", + "notifPrefs.follow_accepted": "Anfrage angenommen", + "notifPrefs.unfollow": "Entfolgt", + "notifPrefs.reaction": "Reaktionen auf meine Kritiken", + "notifPrefs.review_comment": "Kommentare zu meinen Kritiken", + "notifPrefs.friend_review": "Neue Kritik", + "notifPrefs.friend_started": "Serie angefangen", + "notifPrefs.friend_added": "Zu „Geplant“ hinzugefügt", } export default dict diff --git a/src/i18n/locales/en.ts b/src/i18n/locales/en.ts index 2a47a0f..d924fcb 100644 --- a/src/i18n/locales/en.ts +++ b/src/i18n/locales/en.ts @@ -1020,6 +1020,19 @@ const dict: Translations = { "translate.showTranslation": "See translation", "translate.translate": "Translate ({lang})", "translate.translating": "Translating…", + "notifPrefs.hint": "Choose what shows up under the bell. Anything you turn off is no longer sent.", + "notifPrefs.follows": "Follows", + "notifPrefs.reviews": "My reviews", + "notifPrefs.friends": "Activity from people I follow", + "notifPrefs.new_follower": "New follower", + "notifPrefs.follow_request": "Follow request", + "notifPrefs.follow_accepted": "Request accepted", + "notifPrefs.unfollow": "Unfollow", + "notifPrefs.reaction": "Reactions to my reviews", + "notifPrefs.review_comment": "Comments on my reviews", + "notifPrefs.friend_review": "New review", + "notifPrefs.friend_started": "Started a series", + "notifPrefs.friend_added": "Added to “To watch”", } export default dict diff --git a/src/i18n/locales/es.ts b/src/i18n/locales/es.ts index 3fe64f4..287e867 100644 --- a/src/i18n/locales/es.ts +++ b/src/i18n/locales/es.ts @@ -1020,6 +1020,19 @@ const dict: Translations = { "translate.showTranslation": "Ver traducción", "translate.translate": "Traducir ({lang})", "translate.translating": "Traduciendo…", + "notifPrefs.hint": "Elige lo que aparece en la campana. Lo que desactives ya no se envía.", + "notifPrefs.follows": "Seguimientos", + "notifPrefs.reviews": "Mis reseñas", + "notifPrefs.friends": "Actividad de las personas que sigo", + "notifPrefs.new_follower": "Nuevo seguidor", + "notifPrefs.follow_request": "Solicitud de seguimiento", + "notifPrefs.follow_accepted": "Solicitud aceptada", + "notifPrefs.unfollow": "Dejar de seguir", + "notifPrefs.reaction": "Reacciones a mis reseñas", + "notifPrefs.review_comment": "Comentarios en mis reseñas", + "notifPrefs.friend_review": "Nueva reseña", + "notifPrefs.friend_started": "Serie empezada", + "notifPrefs.friend_added": "Añadido a «Por ver»", } export default dict diff --git a/src/i18n/locales/fr.ts b/src/i18n/locales/fr.ts index 37e5dbb..9ebef4f 100644 --- a/src/i18n/locales/fr.ts +++ b/src/i18n/locales/fr.ts @@ -1022,6 +1022,19 @@ const dict = { "translate.showTranslation": "Voir la traduction", "translate.translate": "Traduire ({lang})", "translate.translating": "Traduction…", + "notifPrefs.hint": "Choisis ce qui apparaît dans la cloche. Ce que tu désactives n'est plus envoyé.", + "notifPrefs.follows": "Abonnements", + "notifPrefs.reviews": "Mes avis", + "notifPrefs.friends": "Activité des comptes que je suis", + "notifPrefs.new_follower": "Nouvel abonné", + "notifPrefs.follow_request": "Demande d'abonnement", + "notifPrefs.follow_accepted": "Demande acceptée", + "notifPrefs.unfollow": "Désabonnement", + "notifPrefs.reaction": "Réactions à mes avis", + "notifPrefs.review_comment": "Commentaires sur mes avis", + "notifPrefs.friend_review": "Nouvel avis", + "notifPrefs.friend_started": "Série commencée", + "notifPrefs.friend_added": "Ajout à « À voir »", } export default dict diff --git a/src/i18n/locales/hi.ts b/src/i18n/locales/hi.ts index 8e78961..9886f91 100644 --- a/src/i18n/locales/hi.ts +++ b/src/i18n/locales/hi.ts @@ -1020,6 +1020,19 @@ const dict: Translations = { "translate.showTranslation": "अनुवाद देखें", "translate.translate": "अनुवाद करें ({lang})", "translate.translating": "अनुवाद हो रहा है…", + "notifPrefs.hint": "चुनें कि घंटी में क्या दिखे। जो आप बंद करेंगे, वह अब नहीं भेजा जाएगा।", + "notifPrefs.follows": "फ़ॉलो", + "notifPrefs.reviews": "मेरी समीक्षाएँ", + "notifPrefs.friends": "जिन्हें मैं फ़ॉलो करता/करती हूँ उनकी गतिविधि", + "notifPrefs.new_follower": "नया फ़ॉलोअर", + "notifPrefs.follow_request": "फ़ॉलो अनुरोध", + "notifPrefs.follow_accepted": "अनुरोध स्वीकार हुआ", + "notifPrefs.unfollow": "अनफ़ॉलो", + "notifPrefs.reaction": "मेरी समीक्षाओं पर प्रतिक्रियाएँ", + "notifPrefs.review_comment": "मेरी समीक्षाओं पर टिप्पणियाँ", + "notifPrefs.friend_review": "नई समीक्षा", + "notifPrefs.friend_started": "सीरीज़ शुरू की", + "notifPrefs.friend_added": "“देखना है” में जोड़ा", } export default dict diff --git a/src/i18n/locales/id.ts b/src/i18n/locales/id.ts index 400f6a2..2c9c0f5 100644 --- a/src/i18n/locales/id.ts +++ b/src/i18n/locales/id.ts @@ -1020,6 +1020,19 @@ const dict: Translations = { "translate.showTranslation": "Lihat terjemahan", "translate.translate": "Terjemahkan ({lang})", "translate.translating": "Menerjemahkan…", + "notifPrefs.hint": "Pilih apa yang muncul di lonceng. Yang kamu matikan tidak akan dikirim lagi.", + "notifPrefs.follows": "Mengikuti", + "notifPrefs.reviews": "Ulasanku", + "notifPrefs.friends": "Aktivitas orang yang kuikuti", + "notifPrefs.new_follower": "Pengikut baru", + "notifPrefs.follow_request": "Permintaan mengikuti", + "notifPrefs.follow_accepted": "Permintaan diterima", + "notifPrefs.unfollow": "Berhenti mengikuti", + "notifPrefs.reaction": "Reaksi pada ulasanku", + "notifPrefs.review_comment": "Komentar pada ulasanku", + "notifPrefs.friend_review": "Ulasan baru", + "notifPrefs.friend_started": "Mulai menonton serial", + "notifPrefs.friend_added": "Ditambahkan ke “Mau ditonton”", } export default dict diff --git a/src/i18n/locales/it.ts b/src/i18n/locales/it.ts index ac41e24..5391c11 100644 --- a/src/i18n/locales/it.ts +++ b/src/i18n/locales/it.ts @@ -1020,6 +1020,19 @@ const dict: Translations = { "translate.showTranslation": "Vedi traduzione", "translate.translate": "Traduci ({lang})", "translate.translating": "Traduzione…", + "notifPrefs.hint": "Scegli cosa appare sotto la campanella. Ciò che disattivi non viene più inviato.", + "notifPrefs.follows": "Follow", + "notifPrefs.reviews": "Le mie recensioni", + "notifPrefs.friends": "Attività delle persone che seguo", + "notifPrefs.new_follower": "Nuovo follower", + "notifPrefs.follow_request": "Richiesta di follow", + "notifPrefs.follow_accepted": "Richiesta accettata", + "notifPrefs.unfollow": "Smesso di seguire", + "notifPrefs.reaction": "Reazioni alle mie recensioni", + "notifPrefs.review_comment": "Commenti alle mie recensioni", + "notifPrefs.friend_review": "Nuova recensione", + "notifPrefs.friend_started": "Serie iniziata", + "notifPrefs.friend_added": "Aggiunto a «Da vedere»", } export default dict diff --git a/src/i18n/locales/ja.ts b/src/i18n/locales/ja.ts index 5b7d7de..b52f360 100644 --- a/src/i18n/locales/ja.ts +++ b/src/i18n/locales/ja.ts @@ -1020,6 +1020,19 @@ const dict: Translations = { "translate.showTranslation": "翻訳を見る", "translate.translate": "翻訳する({lang})", "translate.translating": "翻訳中…", + "notifPrefs.hint": "ベルに表示する通知を選べます。オフにした通知は届かなくなります。", + "notifPrefs.follows": "フォロー", + "notifPrefs.reviews": "自分のレビュー", + "notifPrefs.friends": "フォロー中の人のアクティビティ", + "notifPrefs.new_follower": "新しいフォロワー", + "notifPrefs.follow_request": "フォローリクエスト", + "notifPrefs.follow_accepted": "リクエストの承認", + "notifPrefs.unfollow": "フォロー解除", + "notifPrefs.reaction": "レビューへのリアクション", + "notifPrefs.review_comment": "レビューへのコメント", + "notifPrefs.friend_review": "新しいレビュー", + "notifPrefs.friend_started": "シリーズを見始めた", + "notifPrefs.friend_added": "「見たい」に追加", } export default dict diff --git a/src/i18n/locales/ko.ts b/src/i18n/locales/ko.ts index fd062cd..68c87fc 100644 --- a/src/i18n/locales/ko.ts +++ b/src/i18n/locales/ko.ts @@ -1020,6 +1020,19 @@ const dict: Translations = { "translate.showTranslation": "번역 보기", "translate.translate": "번역하기 ({lang})", "translate.translating": "번역 중…", + "notifPrefs.hint": "종 아이콘에 표시할 알림을 선택하세요. 끈 알림은 더 이상 보내지 않아요.", + "notifPrefs.follows": "팔로우", + "notifPrefs.reviews": "내 리뷰", + "notifPrefs.friends": "내가 팔로우하는 사람들의 활동", + "notifPrefs.new_follower": "새 팔로워", + "notifPrefs.follow_request": "팔로우 요청", + "notifPrefs.follow_accepted": "요청 수락", + "notifPrefs.unfollow": "팔로우 취소", + "notifPrefs.reaction": "내 리뷰에 대한 반응", + "notifPrefs.review_comment": "내 리뷰에 달린 댓글", + "notifPrefs.friend_review": "새 리뷰", + "notifPrefs.friend_started": "시리즈 시청 시작", + "notifPrefs.friend_added": "'볼 예정'에 추가", } export default dict diff --git a/src/i18n/locales/nl.ts b/src/i18n/locales/nl.ts index 635a8d9..1848413 100644 --- a/src/i18n/locales/nl.ts +++ b/src/i18n/locales/nl.ts @@ -1020,6 +1020,19 @@ const dict: Translations = { "translate.showTranslation": "Vertaling bekijken", "translate.translate": "Vertalen ({lang})", "translate.translating": "Bezig met vertalen…", + "notifPrefs.hint": "Kies wat er onder het belletje verschijnt. Wat je uitzet, wordt niet meer verstuurd.", + "notifPrefs.follows": "Volgen", + "notifPrefs.reviews": "Mijn recensies", + "notifPrefs.friends": "Activiteit van mensen die ik volg", + "notifPrefs.new_follower": "Nieuwe volger", + "notifPrefs.follow_request": "Volgverzoek", + "notifPrefs.follow_accepted": "Verzoek geaccepteerd", + "notifPrefs.unfollow": "Ontvolgd", + "notifPrefs.reaction": "Reacties op mijn recensies", + "notifPrefs.review_comment": "Opmerkingen bij mijn recensies", + "notifPrefs.friend_review": "Nieuwe recensie", + "notifPrefs.friend_started": "Serie begonnen", + "notifPrefs.friend_added": "Toegevoegd aan ‘Nog kijken’", } export default dict diff --git a/src/i18n/locales/pl.ts b/src/i18n/locales/pl.ts index 90a1da7..2b54e3c 100644 --- a/src/i18n/locales/pl.ts +++ b/src/i18n/locales/pl.ts @@ -1118,6 +1118,19 @@ const dict: Translations = { "translate.showTranslation": "Pokaż tłumaczenie", "translate.translate": "Przetłumacz ({lang})", "translate.translating": "Tłumaczenie…", + "notifPrefs.hint": "Wybierz, co pojawia się pod dzwonkiem. To, co wyłączysz, nie będzie już wysyłane.", + "notifPrefs.follows": "Obserwowanie", + "notifPrefs.reviews": "Moje recenzje", + "notifPrefs.friends": "Aktywność obserwowanych osób", + "notifPrefs.new_follower": "Nowy obserwujący", + "notifPrefs.follow_request": "Prośba o obserwowanie", + "notifPrefs.follow_accepted": "Prośba zaakceptowana", + "notifPrefs.unfollow": "Koniec obserwowania", + "notifPrefs.reaction": "Reakcje na moje recenzje", + "notifPrefs.review_comment": "Komentarze do moich recenzji", + "notifPrefs.friend_review": "Nowa recenzja", + "notifPrefs.friend_started": "Rozpoczęty serial", + "notifPrefs.friend_added": "Dodano do „Do obejrzenia”", } export default dict diff --git a/src/i18n/locales/pt.ts b/src/i18n/locales/pt.ts index 2679c5b..70b2fa0 100644 --- a/src/i18n/locales/pt.ts +++ b/src/i18n/locales/pt.ts @@ -1020,6 +1020,19 @@ const dict: Translations = { "translate.showTranslation": "Ver tradução", "translate.translate": "Traduzir ({lang})", "translate.translating": "Traduzindo…", + "notifPrefs.hint": "Escolhe o que aparece no sino. O que desativares deixa de ser enviado.", + "notifPrefs.follows": "Seguidores", + "notifPrefs.reviews": "As minhas críticas", + "notifPrefs.friends": "Atividade de quem sigo", + "notifPrefs.new_follower": "Novo seguidor", + "notifPrefs.follow_request": "Pedido para seguir", + "notifPrefs.follow_accepted": "Pedido aceite", + "notifPrefs.unfollow": "Deixou de seguir", + "notifPrefs.reaction": "Reações às minhas críticas", + "notifPrefs.review_comment": "Comentários nas minhas críticas", + "notifPrefs.friend_review": "Nova crítica", + "notifPrefs.friend_started": "Série começada", + "notifPrefs.friend_added": "Adicionado a «Quero ver»", } export default dict diff --git a/src/i18n/locales/ru.ts b/src/i18n/locales/ru.ts index 9297f54..e1391d0 100644 --- a/src/i18n/locales/ru.ts +++ b/src/i18n/locales/ru.ts @@ -1118,6 +1118,19 @@ const dict: Translations = { "translate.showTranslation": "Показать перевод", "translate.translate": "Перевести ({lang})", "translate.translating": "Перевод…", + "notifPrefs.hint": "Выбери, что показывать под колокольчиком. Отключённое больше не отправляется.", + "notifPrefs.follows": "Подписки", + "notifPrefs.reviews": "Мои отзывы", + "notifPrefs.friends": "Активность тех, на кого я подписан(а)", + "notifPrefs.new_follower": "Новый подписчик", + "notifPrefs.follow_request": "Запрос на подписку", + "notifPrefs.follow_accepted": "Запрос принят", + "notifPrefs.unfollow": "Отписка", + "notifPrefs.reaction": "Реакции на мои отзывы", + "notifPrefs.review_comment": "Комментарии к моим отзывам", + "notifPrefs.friend_review": "Новый отзыв", + "notifPrefs.friend_started": "Начатый сериал", + "notifPrefs.friend_added": "Добавлено в «В планах»", } export default dict diff --git a/src/i18n/locales/th.ts b/src/i18n/locales/th.ts index 6258f5d..3e41f69 100644 --- a/src/i18n/locales/th.ts +++ b/src/i18n/locales/th.ts @@ -1020,6 +1020,19 @@ const dict: Translations = { "translate.showTranslation": "ดูคำแปล", "translate.translate": "แปล ({lang})", "translate.translating": "กำลังแปล…", + "notifPrefs.hint": "เลือกสิ่งที่จะแสดงในกระดิ่ง สิ่งที่ปิดไว้จะไม่ถูกส่งอีก", + "notifPrefs.follows": "การติดตาม", + "notifPrefs.reviews": "รีวิวของฉัน", + "notifPrefs.friends": "กิจกรรมของคนที่ฉันติดตาม", + "notifPrefs.new_follower": "ผู้ติดตามใหม่", + "notifPrefs.follow_request": "คำขอติดตาม", + "notifPrefs.follow_accepted": "คำขอได้รับการยอมรับ", + "notifPrefs.unfollow": "เลิกติดตาม", + "notifPrefs.reaction": "รีแอคชันต่อรีวิวของฉัน", + "notifPrefs.review_comment": "ความคิดเห็นในรีวิวของฉัน", + "notifPrefs.friend_review": "รีวิวใหม่", + "notifPrefs.friend_started": "เริ่มดูซีรีส์", + "notifPrefs.friend_added": "เพิ่มใน “อยากดู”", } export default dict diff --git a/src/i18n/locales/tr.ts b/src/i18n/locales/tr.ts index 68b4464..f61baee 100644 --- a/src/i18n/locales/tr.ts +++ b/src/i18n/locales/tr.ts @@ -1020,6 +1020,19 @@ const dict: Translations = { "translate.showTranslation": "Çeviriyi gör", "translate.translate": "Çevir ({lang})", "translate.translating": "Çevriliyor…", + "notifPrefs.hint": "Zilin altında nelerin görüneceğini seç. Kapattıkların artık gönderilmez.", + "notifPrefs.follows": "Takip", + "notifPrefs.reviews": "Yorumlarım", + "notifPrefs.friends": "Takip ettiklerimin etkinliği", + "notifPrefs.new_follower": "Yeni takipçi", + "notifPrefs.follow_request": "Takip isteği", + "notifPrefs.follow_accepted": "İstek kabul edildi", + "notifPrefs.unfollow": "Takipten çıkma", + "notifPrefs.reaction": "Yorumlarıma tepkiler", + "notifPrefs.review_comment": "Yorumlarıma gelen yanıtlar", + "notifPrefs.friend_review": "Yeni yorum", + "notifPrefs.friend_started": "Başlanan dizi", + "notifPrefs.friend_added": "“İzlenecek” listesine ekleme", } export default dict diff --git a/src/i18n/locales/vi.ts b/src/i18n/locales/vi.ts index 75e9da2..bbc1504 100644 --- a/src/i18n/locales/vi.ts +++ b/src/i18n/locales/vi.ts @@ -1020,6 +1020,19 @@ const dict: Translations = { "translate.showTranslation": "Xem bản dịch", "translate.translate": "Dịch ({lang})", "translate.translating": "Đang dịch…", + "notifPrefs.hint": "Chọn những gì hiển thị dưới chuông. Mục bạn tắt sẽ không được gửi nữa.", + "notifPrefs.follows": "Theo dõi", + "notifPrefs.reviews": "Đánh giá của tôi", + "notifPrefs.friends": "Hoạt động của người tôi theo dõi", + "notifPrefs.new_follower": "Người theo dõi mới", + "notifPrefs.follow_request": "Yêu cầu theo dõi", + "notifPrefs.follow_accepted": "Yêu cầu được chấp nhận", + "notifPrefs.unfollow": "Hủy theo dõi", + "notifPrefs.reaction": "Cảm xúc về đánh giá của tôi", + "notifPrefs.review_comment": "Bình luận về đánh giá của tôi", + "notifPrefs.friend_review": "Đánh giá mới", + "notifPrefs.friend_started": "Bắt đầu xem phim bộ", + "notifPrefs.friend_added": "Thêm vào “Sẽ xem”", } export default dict diff --git a/src/i18n/locales/zh.ts b/src/i18n/locales/zh.ts index 0e508ae..2b10725 100644 --- a/src/i18n/locales/zh.ts +++ b/src/i18n/locales/zh.ts @@ -1020,6 +1020,19 @@ const dict: Translations = { "translate.showTranslation": "查看译文", "translate.translate": "翻译({lang})", "translate.translating": "正在翻译…", + "notifPrefs.hint": "选择铃铛中显示的内容。关闭的通知将不再发送。", + "notifPrefs.follows": "关注", + "notifPrefs.reviews": "我的评价", + "notifPrefs.friends": "我关注的人的动态", + "notifPrefs.new_follower": "新关注者", + "notifPrefs.follow_request": "关注请求", + "notifPrefs.follow_accepted": "请求已接受", + "notifPrefs.unfollow": "取消关注", + "notifPrefs.reaction": "对我评价的回应", + "notifPrefs.review_comment": "对我评价的评论", + "notifPrefs.friend_review": "新评价", + "notifPrefs.friend_started": "开始看剧", + "notifPrefs.friend_added": "加入“想看”", } export default dict diff --git a/src/lib/backup.ts b/src/lib/backup.ts index a6c077d..f9ba5b2 100644 --- a/src/lib/backup.ts +++ b/src/lib/backup.ts @@ -1,5 +1,5 @@ import { t } from '../i18n' -import type { BackupFile, Criteria, CustomList, MediaItem, MediaType, Settings, TopCategory, TopEntry, WatchStatus } from '../types' +import { NOTIF_KINDS, type BackupFile, type Criteria, type CustomList, type MediaItem, type MediaType, type Settings, type TopCategory, type TopEntry, type WatchStatus } from '../types' import { ALL_TOP_CATEGORIES, MEDIA_TYPES, STATUSES } from './constants' import { episodeCap } from './franchise' import { cleanThemeMode } from './theme' @@ -161,6 +161,7 @@ export function normalizeSettings(raw: unknown): Partial | undefined { if (Array.isArray(raw.statsHiddenMonths)) { out.statsHiddenMonths = [...new Set(raw.statsHiddenMonths.filter((m): m is string => typeof m === 'string' && /^\d{4}-(0[1-9]|1[0-2])$/.test(m)))].sort().slice(-600) } + if (Array.isArray(raw.notifOff)) out.notifOff = NOTIF_KINDS.filter((k) => (raw.notifOff as unknown[]).includes(k)) return out } diff --git a/src/pages/SettingsPage.tsx b/src/pages/SettingsPage.tsx index da3f35f..aea76e2 100644 --- a/src/pages/SettingsPage.tsx +++ b/src/pages/SettingsPage.tsx @@ -4,6 +4,7 @@ import { Check, Download, ExternalLink, HardDrive, Import, Trash2, Upload, UserX import { lazy, Suspense, useEffect, useRef, useState, type ReactNode } from 'react' import AccountSection from '../components/AccountSection' import ConfirmDialog from '../components/ConfirmDialog' +import NotificationSettings from '../components/NotificationSettings' import { PageHeader, SectionTitle } from '../components/ui' import { exportBackup, parseBackupFile, type ParsedBackup } from '../lib/backup' import { ALL_TOP_CATEGORIES, TOP_CATEGORIES } from '../lib/constants' @@ -133,6 +134,7 @@ export default function SettingsPage() { )} {account && setMessage({ kind, text })} />} + {account && } {guest && ( <> {t('account.title')} diff --git a/src/store.tsx b/src/store.tsx index 7c71184..6723e6c 100644 --- a/src/store.tsx +++ b/src/store.tsx @@ -268,9 +268,10 @@ export function MediaProvider({ getLists: () => listsRef.current, applyLists: (next) => setLists(() => next, true), getSettings: () => { - const { topCategories, themeMode, statsHiddenMonths } = settingsRef.current - // Mois masqués : liste vide plutôt qu'absente, sinon « tout réafficher » ne partirait jamais au serveur - return { topCategories, themeMode, statsHiddenMonths: statsHiddenMonths ?? [] } + const { topCategories, themeMode, statsHiddenMonths, notifOff } = settingsRef.current + // Listes vides plutôt qu'absentes, sinon « tout réafficher / tout réactiver » ne partirait jamais au serveur. + // notifOff est aussi lu par le serveur : les notifications désactivées ne sont pas créées. + return { topCategories, themeMode, statsHiddenMonths: statsHiddenMonths ?? [], notifOff: notifOff ?? [] } }, applySettings: (patch) => updateSettingsRef.current(patch, true), itemsChanged: () => void reloadItems().catch(() => {}), @@ -311,7 +312,7 @@ export function MediaProvider({ }, [settings.themeMode]) const updateSettings = useCallback((patch: Partial, silent = false) => { - if (!silent && syncRef.current && ('topCategories' in patch || 'themeMode' in patch || 'statsHiddenMonths' in patch)) syncRef.current.markSettings() + if (!silent && syncRef.current && ('topCategories' in patch || 'themeMode' in patch || 'statsHiddenMonths' in patch || 'notifOff' in patch)) syncRef.current.markSettings() setSettings((prev) => { const next = { ...prev, ...patch } try { diff --git a/src/types.ts b/src/types.ts index db41b06..4821f6c 100644 --- a/src/types.ts +++ b/src/types.ts @@ -109,8 +109,14 @@ export interface Settings { themeMode: ThemeMode /** Mois masqués dans la courbe des stats (AAAA-MM), ex. le mois où j'ai tout ajouté d'un coup. */ statsHiddenMonths?: string[] + /** Types de notifications désactivés (Réglages → Notifications). Lu aussi par le serveur, qui ne les crée pas. */ + notifOff?: NotifKind[] } +/** Types de notifications (mêmes noms que la colonne notifications.kind). */ +export const NOTIF_KINDS = ['new_follower', 'follow_request', 'follow_accepted', 'unfollow', 'reaction', 'review_comment', 'friend_review', 'friend_started', 'friend_added'] as const +export type NotifKind = (typeof NOTIF_KINDS)[number] + export interface CustomList { id: string name: string diff --git a/supabase/functions/admin/index.ts b/supabase/functions/admin/index.ts index 5d5be6f..79c1ff3 100644 --- a/supabase/functions/admin/index.ts +++ b/supabase/functions/admin/index.ts @@ -78,7 +78,8 @@ function limited(key: string): boolean { } async function log(adminId: string | null, action: string, targetUser: string | null, target: string | null, details: Record) { - await sql!`select admin.log(${adminId}::uuid, ${action}::text, ${targetUser}::uuid, ${target}::text, ${JSON.stringify(details)}::jsonb)` + // sql.json : un objet JSON (et non un texte JSON, que la console affichait lettre par lettre) + await sql!`select admin.log(${adminId}::uuid, ${action}::text, ${targetUser}::uuid, ${target}::text, ${sql!.json(details as never)}::jsonb)` } /** E-mail d'alerte (action sensible ou connexion). Sans mot de passe SMTP configuré : rien. */ diff --git a/supabase/migrations/20261201100000_admin_journal_details.sql b/supabase/migrations/20261201100000_admin_journal_details.sql new file mode 100644 index 0000000..db6187c --- /dev/null +++ b/supabase/migrations/20261201100000_admin_journal_details.sql @@ -0,0 +1,25 @@ +-- Journal de la console : les détails des connexions avaient été enregistrés comme texte JSON (et non objet), +-- affichés lettre par lettre. Le journal ne peut pas être modifié : la lecture les remet en forme. Idempotent. +create or replace function admin.as_object(d jsonb) +returns jsonb language plpgsql immutable set search_path = '' as $$ +begin + if jsonb_typeof(d) = 'string' then + d := (d #>> '{}')::jsonb; + end if; + return case when jsonb_typeof(d) = 'object' then d else '{}'::jsonb end; +exception when others then + return '{}'::jsonb; +end; +$$; +comment on function admin.as_object(jsonb) is 'Détails du journal toujours sous forme d''objet (anciennes lignes enregistrées en texte).'; + +create or replace function admin.journal_list(p_offset integer) +returns jsonb language sql stable set search_path = '' as $$ + select coalesce(jsonb_agg(j.row order by j.id desc), '[]'::jsonb) from ( + select j.id, jsonb_build_object('id', j.id, 'at', j.at, 'action', j.action, 'target', j.target, 'details', admin.as_object(j.details), + 'admin', (select username from public.profiles where id = j.admin_id)) as row + from admin.journal j order by j.id desc + limit 50 offset greatest(coalesce(p_offset, 0), 0) + ) j; +$$; +revoke all on function admin.as_object(jsonb) from public, anon, authenticated, service_role; diff --git a/supabase/migrations/20261201110000_notification_prefs.sql b/supabase/migrations/20261201110000_notification_prefs.sql new file mode 100644 index 0000000..9f35c23 --- /dev/null +++ b/supabase/migrations/20261201110000_notification_prefs.sql @@ -0,0 +1,72 @@ +-- Choix des notifications (Réglages → Notifications, 01/12/2026). Idempotent. +-- Les types désactivés sont dans les réglages synchronisés du compte : settings.data->'notifOff' (liste de types). +-- Une notification d'un type désactivé n'est jamais créée (trigger), et celles déjà reçues sont masquées +-- de la liste et du compteur. + +create or replace function public.azuu_notif_wanted(p_user uuid, p_kind text) +returns boolean language sql stable security definer set search_path = '' as $$ + select not coalesce(( + select jsonb_typeof(s.data->'notifOff') = 'array' and (s.data->'notifOff') ? p_kind + from public.settings s where s.user_id = p_user + ), false); +$$; +revoke all on function public.azuu_notif_wanted(uuid, text) from public, anon, authenticated; +comment on function public.azuu_notif_wanted(uuid, text) is 'Règle : ce compte veut-il ce type de notification (Réglages → Notifications) ?'; + +create or replace function public.azuu_notif_filter() +returns trigger language plpgsql security definer set search_path = '' as $$ +begin + if not public.azuu_notif_wanted(new.user_id, new.kind) then + return null; + end if; + return new; +end; +$$; +revoke all on function public.azuu_notif_filter() from public, anon, authenticated; +comment on function public.azuu_notif_filter() is 'Trigger (notifications) : une notification d''un type désactivé par son destinataire n''est pas créée.'; + +drop trigger if exists notifications_wanted on public.notifications; +create trigger notifications_wanted before insert on public.notifications + for each row execute function public.azuu_notif_filter(); + +create or replace function public.get_notifications() +returns jsonb language sql stable security definer set search_path = '' as $$ + with off as ( + select coalesce(case when jsonb_typeof(s.data->'notifOff') = 'array' then s.data->'notifOff' end, '[]'::jsonb) as kinds + from public.settings s where s.user_id = auth.uid() + ) + select coalesce(jsonb_agg(jsonb_build_object( + 'id', n.id, 'kind', n.kind, 'created_at', n.created_at, 'read', n.read_at is not null, + 'emoji', n.emoji, 'actor', public.profile_card(p), 'item', it.item) order by n.id desc), '[]'::jsonb) + from ( + select * from public.notifications nn + where nn.user_id = auth.uid() and public.azuu_mfa_ok() + and not exists (select 1 from off where off.kinds ? nn.kind) + order by nn.id desc limit 100 + ) n + join public.profiles p on p.id = n.actor_id and not p.suspended + left join lateral ( + select public.public_item(i.data) as item + from public.items i + where n.item_id is not null and not i.deleted and i.id = n.item_id + and i.user_id = case when n.kind in ('reaction', 'review_comment') then n.user_id else n.actor_id end + and (n.kind in ('reaction', 'review_comment') or public.can_view(n.actor_id)) + ) it on true + where not exists (select 1 from public.blocks b + where (b.blocker_id = auth.uid() and b.blocked_id = n.actor_id) + or (b.blocker_id = n.actor_id and b.blocked_id = auth.uid())) + and (n.item_id is null or it.item is not null) +$$; +comment on function public.get_notifications() is 'App : mes notifications, avec le titre lié (sans les types que j''ai désactivés).'; + +create or replace function public.unread_notifications() +returns integer language sql stable security definer set search_path = '' as $$ + select count(*)::int from public.notifications n + join public.profiles p on p.id = n.actor_id and not p.suspended + where n.user_id = auth.uid() and public.azuu_mfa_ok() and n.read_at is null + and public.azuu_notif_wanted(auth.uid(), n.kind) + and not exists (select 1 from public.blocks b + where (b.blocker_id = auth.uid() and b.blocked_id = n.actor_id) + or (b.blocker_id = n.actor_id and b.blocked_id = auth.uid())) +$$; +comment on function public.unread_notifications() is 'App : nombre de notifications non lues (sans les types que j''ai désactivés).';