Notifications : réactions et commentaires sur mes avis, activité des comptes suivis
deploy / deploy (push) Successful in 39s

- Quelqu'un réagit (emoji) ou commente mon avis → notification avec le titre ; la toucher ouvre ma fiche
- Un compte que je suis donne son avis, commence une série / un anime / un drama, ou ajoute un titre
  à « À voir » → notification avec l'affiche ; la toucher ouvre sa fiche
- Serveur (migration 20261128180000, appliquée) : déclencheurs sur réactions, commentaires et fiches ;
  rafales (import, ajouts en série) regroupées en une seule notification par personne et par type sur 3 h ;
  jamais entre comptes bloqués ni d'un compte suspendu ; une réaction retirée retire sa notification
- Pas de notification pour les listes perso : elles sont privées
- Textes dans les 18 langues

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YVo1qxKoBQCaMd7Ue8PGbe
This commit is contained in:
Claude committed 2026-11-28 09:39:28 +00:00
1 parent 2a4261219c
commit 3487e8c305
22 files changed
+322 -27

No files matched your search

+2 -2
View File
@@ -61,8 +61,8 @@ npm run build # build de prod
- RTL géré (arabe) : préférer les classes logiques (`ps-`/`pe-`, `ms-`/`me-`, `start-`/`end-`, `border-e`).
## État (au 28 nov. 2026)
- **Toutes les migrations de `supabase/migrations/` sont appliquées en ligne**, jusqu'à `20261128170000_mfa_reads_and_fixes.sql` incluse.
- **Notifications : abonnements uniquement** (27 nov. 2026) — cloche sur l'accueil, dans l'app, pas de push. Types : `new_follower`, `follow_request`, `unfollow`, `follow_accepted` (trigger `follows_notify`, RPC `get_notifications` / `unread_notifications` / `mark_notifications_read`). Les anciennes notifications (push, commentaires, épisodes, invitations) et `azuu_notify` ont été supprimées. La fonction Edge `send-push` répond 410 : à supprimer depuis le tableau de bord Supabase.
- **Toutes les migrations de `supabase/migrations/` sont appliquées en ligne**, jusqu'à `20261128180000_social_notifications.sql` incluse.
- **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.
- **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).
- **Double authentification (TOTP)** : optionnelle, Réglages → Mon compte (`src/components/TwoFactor.tsx`, fonctions dans `src/lib/cloud/auth.ts`). À la connexion, `Root.tsx` demande le code (`MfaScreen`) si le compte a un facteur vérifié. Côté serveur, `azuu_mfa_ok()` : règles RLS restrictives « mfa required » (items, lists, settings, follows, profiles, activity), `is_admin()` et `azuu_me_active()` ; les fonctions Edge (`_shared/auth.ts`) refusent un jeton « aal1 » d'un compte protégé.
- **Dépendances figées** : versions exactes dans `package.json` + `.npmrc` (`save-exact=true`), CI en `npm ci`.
+25 -4
View File
@@ -1,7 +1,8 @@
import { Loader2 } from 'lucide-react'
import { useEffect, useState } from 'react'
import { t, type TKey } from '../../i18n'
import { acceptFollower, getNotifications, markNotificationsRead, removeFollower, type FollowNotification } from '../../lib/cloud/social'
import { acceptFollower, getNotifications, markNotificationsRead, MINE_ITEM_KINDS, removeFollower, type FollowNotification } from '../../lib/cloud/social'
import Poster from '../Poster'
import { timeAgo } from '../../lib/timeAgo'
import { cx } from '../../lib/utils'
import Avatar from './Avatar'
@@ -13,9 +14,17 @@ const TEXT: Record<FollowNotification['kind'], TKey> = {
follow_request: 'notif.followRequest',
unfollow: 'notif.unfollow',
follow_accepted: 'notif.followAccepted',
reaction: 'notif.reaction',
review_comment: 'notif.reviewComment',
friend_review: 'notif.friendReview',
friend_started: 'notif.friendStarted',
friend_added: 'notif.friendAdded',
}
/** Qui s'est abonné, désabonné, a demandé à s'abonner ou a accepté ma demande. Ouvrir la liste la marque comme lue. */
/**
* Abonnements (qui s'abonne, se désabonne, demande, accepte), réactions et commentaires sur mes avis,
* et activité des comptes que je suis (avis, série commencée, titre ajouté). Ouvrir la liste la marque comme lue.
*/
export default function NotificationsSheet({ onClose, onSeen }: { onClose: () => void; onSeen: () => void }) {
const social = useSocial()
const [list, setList] = useState<FollowNotification[]>()
@@ -38,6 +47,13 @@ export default function NotificationsSheet({ onClose, onSeen }: { onClose: () =>
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])
// Toucher une notification : le titre concerné s'il y en a un (le mien ou celui de la personne), sinon son profil
const open = (n: FollowNotification) => {
if (!n.item) return social.openProfile(n.actor.username)
if (MINE_ITEM_KINDS.includes(n.kind)) social.openItem(n.item)
else social.openItem(n.item, { username: n.actor.username, displayName: n.actor.displayName, avatarUrl: n.actor.avatarUrl })
}
const pending = new Set(social.requests.map((r) => r.id))
const answer = async (id: string, accept: boolean) => {
setBusy(id)
@@ -68,20 +84,25 @@ export default function NotificationsSheet({ onClose, onSeen }: { onClose: () =>
<ul className="divide-y divide-line">
{list.map((n) => (
<li key={n.id} className="flex items-center gap-3 py-3">
<button onClick={() => social.openProfile(n.actor.username)} className="flex min-w-0 flex-1 items-center gap-3 text-start">
<button onClick={() => open(n)} className="flex min-w-0 flex-1 items-center gap-3 text-start">
<span className="relative shrink-0">
<Avatar url={n.actor.avatarUrl} name={n.actor.displayName} size={44} />
{!n.read && <span className="absolute -end-0.5 -top-0.5 size-3 rounded-full border-2 border-bg bg-accent-fill" aria-hidden="true" />}
</span>
<span className="min-w-0 flex-1">
<span className={cx('block text-sm leading-snug', n.kind === 'unfollow' ? 'text-ink-2' : 'text-ink')}>
{t(TEXT[n.kind], { name: n.actor.displayName })}
{t(TEXT[n.kind], { name: n.actor.displayName, title: n.item?.title ?? '', emoji: n.emoji ?? '' })}
</span>
<span className="mt-0.5 flex gap-2 text-xs text-ink-3">
<span className="truncate">@{n.actor.username}</span>
<span className="shrink-0">{timeAgo(n.createdAt)}</span>
</span>
</span>
{n.item && (
<span className="w-10 shrink-0">
<Poster src={n.item.poster} title={n.item.title} />
</span>
)}
</button>
{n.kind === 'follow_request' && pending.has(n.actor.id) && (
<span className="flex shrink-0 gap-1.5">
+6 -1
View File
@@ -715,12 +715,17 @@ const dict: Translations = {
'social.noFollowing': 'لا تتابع أحدًا بعد.',
'social.noFollowers': 'لا متابعين بعد.',
'notif.title': 'الإشعارات',
'notif.empty': 'عندما يتابعك أحد أو يلغي متابعتك، ستراه هنا.',
'notif.empty': "ستظهر هنا المتابعات والتفاعلات مع مراجعاتك ونشاط من تتابعهم.",
'notif.error': 'تعذّر تحميل الإشعارات.',
'notif.newFollower': '{name} يتابعك',
'notif.followRequest': '{name} يطلب متابعتك',
'notif.unfollow': '{name} ألغى متابعتك',
'notif.followAccepted': '{name} قبل طلبك',
'notif.reaction': "تفاعل {name} بـ {emoji} مع مراجعتك لـ {title}",
'notif.reviewComment': "علّق {name} على مراجعتك لـ {title}",
'notif.friendReview': "كتب {name} مراجعة عن {title}",
'notif.friendStarted': "بدأ {name} مشاهدة {title}",
'notif.friendAdded': "يريد {name} مشاهدة {title}",
'notif.unread_one': '{count} إشعار جديد',
'notif.unread_other': '{count} إشعارات جديدة',
'notif.unread_two': 'إشعاران جديدان',
+6 -1
View File
@@ -631,12 +631,17 @@ const dict: Translations = {
'social.noFollowing': 'Du folgst noch niemandem.',
'social.noFollowers': 'Noch keine Follower.',
'notif.title': 'Benachrichtigungen',
'notif.empty': 'Wenn dir jemand folgt oder entfolgt, siehst du es hier.',
'notif.empty': "Hier erscheinen Follows, Reaktionen auf deine Kritiken und Aktivitäten der Leute, denen du folgst.",
'notif.error': 'Benachrichtigungen konnten nicht geladen werden.',
'notif.newFollower': '{name} folgt dir',
'notif.followRequest': '{name} möchte dir folgen',
'notif.unfollow': '{name} folgt dir nicht mehr',
'notif.followAccepted': '{name} hat deine Anfrage angenommen',
'notif.reaction': "{name} hat mit {emoji} auf deine Kritik zu {title} reagiert",
'notif.reviewComment': "{name} hat deine Kritik zu {title} kommentiert",
'notif.friendReview': "{name} hat {title} rezensiert",
'notif.friendStarted': "{name} hat mit {title} angefangen",
'notif.friendAdded': "{name} will {title} sehen",
'notif.unread_one': '{count} neue Benachrichtigung',
'notif.unread_other': '{count} neue Benachrichtigungen',
'social.accept': 'Annehmen',
+6 -1
View File
@@ -631,12 +631,17 @@ const dict: Translations = {
'social.noFollowing': 'Not following anyone yet.',
'social.noFollowers': 'No followers yet.',
'notif.title': 'Notifications',
'notif.empty': 'When someone follows or unfollows you, you\'ll see it here.',
'notif.empty': "Follows, reactions to your reviews and activity from people you follow will show up here.",
'notif.error': 'Couldn\'t load notifications.',
'notif.newFollower': '{name} followed you',
'notif.followRequest': '{name} asked to follow you',
'notif.unfollow': '{name} unfollowed you',
'notif.followAccepted': '{name} accepted your request',
'notif.reaction': "{name} reacted {emoji} to your review of {title}",
'notif.reviewComment': "{name} commented on your review of {title}",
'notif.friendReview': "{name} reviewed {title}",
'notif.friendStarted': "{name} started {title}",
'notif.friendAdded': "{name} wants to watch {title}",
'notif.unread_one': '{count} new notification',
'notif.unread_other': '{count} new notifications',
'social.accept': 'Accept',
+6 -1
View File
@@ -631,12 +631,17 @@ const dict: Translations = {
'social.noFollowing': 'Todavía no sigues a nadie.',
'social.noFollowers': 'Todavía no tienes seguidores.',
'notif.title': 'Notificaciones',
'notif.empty': 'Cuando alguien te siga o deje de seguirte, lo verás aquí.',
'notif.empty': "Aquí verás seguidores, reacciones a tus reseñas y la actividad de quienes sigues.",
'notif.error': 'No se pudieron cargar las notificaciones.',
'notif.newFollower': '{name} te sigue',
'notif.followRequest': '{name} quiere seguirte',
'notif.unfollow': '{name} ya no te sigue',
'notif.followAccepted': '{name} aceptó tu solicitud',
'notif.reaction': "{name} reaccionó {emoji} a tu reseña de {title}",
'notif.reviewComment': "{name} comentó tu reseña de {title}",
'notif.friendReview': "{name} reseñó {title}",
'notif.friendStarted': "{name} empezó {title}",
'notif.friendAdded': "{name} quiere ver {title}",
'notif.unread_one': '{count} notificación nueva',
'notif.unread_other': '{count} notificaciones nuevas',
'social.accept': 'Aceptar',
+6 -1
View File
@@ -633,12 +633,17 @@ const dict = {
'social.noFollowing': 'Aucun abonnement pour l\'instant.',
'social.noFollowers': 'Aucun abonné pour l\'instant.',
'notif.title': 'Notifications',
'notif.empty': 'Quand quelqu\'un s\'abonne ou se désabonne, tu le verras ici.',
'notif.empty': "Les abonnements, les réactions à tes avis et l'activité des comptes que tu suis apparaîtront ici.",
'notif.error': 'Impossible de charger les notifications.',
'notif.newFollower': '{name} te suit',
'notif.followRequest': '{name} demande à te suivre',
'notif.unfollow': '{name} ne te suit plus',
'notif.followAccepted': '{name} a accepté ta demande',
'notif.reaction': "{name} a réagi {emoji} à ton avis sur {title}",
'notif.reviewComment': "{name} a commenté ton avis sur {title}",
'notif.friendReview': "{name} a donné son avis sur {title}",
'notif.friendStarted': "{name} a commencé {title}",
'notif.friendAdded': "{name} veut voir {title}",
'notif.unread_one': '{count} nouvelle notification',
'notif.unread_other': '{count} nouvelles notifications',
'social.accept': 'Accepter',
+6 -1
View File
@@ -631,12 +631,17 @@ const dict: Translations = {
'social.noFollowing': 'अभी आप किसी को फ़ॉलो नहीं कर रहे।',
'social.noFollowers': 'अभी कोई फ़ॉलोअर नहीं।',
'notif.title': 'सूचनाएँ',
'notif.empty': 'जब कोई आपको फ़ॉलो या अनफ़ॉलो करेगा, आप उसे यहाँ देखेंगे।',
'notif.empty': "फ़ॉलो, आपकी समीक्षाओं पर प्रतिक्रियाएँ और आप जिन्हें फ़ॉलो करते हैं उनकी गतिविधि यहाँ दिखेगी।",
'notif.error': 'सूचनाएँ लोड नहीं हो सकीं।',
'notif.newFollower': '{name} आपको फ़ॉलो करते हैं',
'notif.followRequest': '{name} आपको फ़ॉलो करना चाहते हैं',
'notif.unfollow': '{name} ने आपको अनफ़ॉलो किया',
'notif.followAccepted': '{name} ने आपका अनुरोध स्वीकार किया',
'notif.reaction': "{name} ने {title} पर आपकी समीक्षा पर {emoji} प्रतिक्रिया दी",
'notif.reviewComment': "{name} ने {title} पर आपकी समीक्षा पर टिप्पणी की",
'notif.friendReview': "{name} ने {title} की समीक्षा की",
'notif.friendStarted': "{name} ने {title} देखना शुरू किया",
'notif.friendAdded': "{name} {title} देखना चाहते हैं",
'notif.unread_one': '{count} नई सूचना',
'notif.unread_other': '{count} नई सूचनाएँ',
'social.accept': 'स्वीकार करें',
+6 -1
View File
@@ -631,12 +631,17 @@ const dict: Translations = {
'social.noFollowing': 'Belum mengikuti siapa pun.',
'social.noFollowers': 'Belum ada pengikut.',
'notif.title': 'Notifikasi',
'notif.empty': 'Saat seseorang mengikuti atau berhenti mengikutimu, kamu akan melihatnya di sini.',
'notif.empty': "Pengikut, reaksi pada ulasanmu, dan aktivitas orang yang kamu ikuti akan muncul di sini.",
'notif.error': 'Notifikasi tidak dapat dimuat.',
'notif.newFollower': '{name} mengikutimu',
'notif.followRequest': '{name} ingin mengikutimu',
'notif.unfollow': '{name} berhenti mengikutimu',
'notif.followAccepted': '{name} menerima permintaanmu',
'notif.reaction': "{name} memberi reaksi {emoji} pada ulasanmu tentang {title}",
'notif.reviewComment': "{name} mengomentari ulasanmu tentang {title}",
'notif.friendReview': "{name} mengulas {title}",
'notif.friendStarted': "{name} mulai menonton {title}",
'notif.friendAdded': "{name} ingin menonton {title}",
'notif.unread_one': '{count} notifikasi baru',
'notif.unread_other': '{count} notifikasi baru',
'social.accept': 'Terima',
+6 -1
View File
@@ -631,12 +631,17 @@ const dict: Translations = {
'social.noFollowing': 'Non segui ancora nessuno.',
'social.noFollowers': 'Ancora nessun follower.',
'notif.title': 'Notifiche',
'notif.empty': 'Quando qualcuno inizia o smette di seguirti, lo vedrai qui.',
'notif.empty': "Qui vedrai i follower, le reazioni alle tue recensioni e l'attività di chi segui.",
'notif.error': 'Impossibile caricare le notifiche.',
'notif.newFollower': '{name} ti segue',
'notif.followRequest': '{name} chiede di seguirti',
'notif.unfollow': '{name} non ti segue più',
'notif.followAccepted': '{name} ha accettato la tua richiesta',
'notif.reaction': "{name} ha reagito {emoji} alla tua recensione di {title}",
'notif.reviewComment': "{name} ha commentato la tua recensione di {title}",
'notif.friendReview': "{name} ha recensito {title}",
'notif.friendStarted': "{name} ha iniziato {title}",
'notif.friendAdded': "{name} vuole vedere {title}",
'notif.unread_one': '{count} nuova notifica',
'notif.unread_other': '{count} nuove notifiche',
'social.accept': 'Accetta',
+6 -1
View File
@@ -631,12 +631,17 @@ const dict: Translations = {
'social.noFollowing': 'まだ誰もフォローしていません。',
'social.noFollowers': 'まだフォロワーはいません。',
'notif.title': '通知',
'notif.empty': '誰かにフォローまたはフォロー解除されると、ここに表示されます。',
'notif.empty': "フォロー、レビューへのリアクション、フォロー中の人のアクティビティがここに表示されます。",
'notif.error': '通知を読み込めませんでした。',
'notif.newFollower': '{name}さんがあなたをフォローしました',
'notif.followRequest': '{name}さんがフォローをリクエストしました',
'notif.unfollow': '{name}さんがフォローを解除しました',
'notif.followAccepted': '{name}さんがリクエストを承認しました',
'notif.reaction': "{name}さんが「{title}」のあなたのレビューに{emoji}でリアクションしました",
'notif.reviewComment': "{name}さんが「{title}」のあなたのレビューにコメントしました",
'notif.friendReview': "{name}さんが「{title}」をレビューしました",
'notif.friendStarted': "{name}さんが「{title}」を見始めました",
'notif.friendAdded': "{name}さんが「{title}」を見たいリストに追加しました",
'notif.unread_one': '新しい通知 {count} 件',
'notif.unread_other': '新しい通知 {count} 件',
'social.accept': '承認',
+6 -1
View File
@@ -631,12 +631,17 @@ const dict: Translations = {
'social.noFollowing': '아직 팔로우한 사람이 없어요.',
'social.noFollowers': '아직 팔로워가 없어요.',
'notif.title': '알림',
'notif.empty': '누군가 나를 팔로우하거나 언팔로우하면 여기에 표시돼요.',
'notif.empty': "팔로우, 리뷰 반응, 팔로우한 사람들의 활동이 여기에 표시돼요.",
'notif.error': '알림을 불러오지 못했어요.',
'notif.newFollower': '{name}님이 나를 팔로우해요',
'notif.followRequest': '{name}님이 팔로우를 요청했어요',
'notif.unfollow': '{name}님이 언팔로우했어요',
'notif.followAccepted': '{name}님이 요청을 수락했어요',
'notif.reaction': "{name}님이 {title} 리뷰에 {emoji} 반응을 남겼어요",
'notif.reviewComment': "{name}님이 {title} 리뷰에 댓글을 달았어요",
'notif.friendReview': "{name}님이 {title} 리뷰를 남겼어요",
'notif.friendStarted': "{name}님이 {title} 시청을 시작했어요",
'notif.friendAdded': "{name}님이 {title}을(를) 보고 싶어 해요",
'notif.unread_one': '새 알림 {count}개',
'notif.unread_other': '새 알림 {count}개',
'social.accept': '수락',
+6 -1
View File
@@ -631,12 +631,17 @@ const dict: Translations = {
'social.noFollowing': 'Je volgt nog niemand.',
'social.noFollowers': 'Nog geen volgers.',
'notif.title': 'Meldingen',
'notif.empty': 'Als iemand je volgt of ontvolgt, zie je het hier.',
'notif.empty': "Volgers, reacties op je recensies en activiteit van wie je volgt verschijnen hier.",
'notif.error': 'Meldingen konden niet worden geladen.',
'notif.newFollower': '{name} volgt je',
'notif.followRequest': '{name} wil je volgen',
'notif.unfollow': '{name} volgt je niet meer',
'notif.followAccepted': '{name} heeft je verzoek geaccepteerd',
'notif.reaction': "{name} reageerde {emoji} op je recensie van {title}",
'notif.reviewComment': "{name} reageerde op je recensie van {title}",
'notif.friendReview': "{name} recenseerde {title}",
'notif.friendStarted': "{name} is begonnen aan {title}",
'notif.friendAdded': "{name} wil {title} zien",
'notif.unread_one': '{count} nieuwe melding',
'notif.unread_other': '{count} nieuwe meldingen',
'social.accept': 'Accepteren',
+6 -1
View File
@@ -687,12 +687,17 @@ const dict: Translations = {
'social.noFollowing': 'Na razie nikogo nie obserwujesz.',
'social.noFollowers': 'Na razie brak obserwujących.',
'notif.title': 'Powiadomienia',
'notif.empty': 'Gdy ktoś zacznie lub przestanie cię obserwować, zobaczysz to tutaj.',
'notif.empty': "Tu pojawią się obserwacje, reakcje na twoje recenzje i aktywność osób, które obserwujesz.",
'notif.error': 'Nie udało się wczytać powiadomień.',
'notif.newFollower': '{name} obserwuje cię',
'notif.followRequest': '{name} prosi o możliwość obserwowania',
'notif.unfollow': '{name} już cię nie obserwuje',
'notif.followAccepted': '{name} zaakceptował(a) twoją prośbę',
'notif.reaction': "{name} zareagował(a) {emoji} na twoją recenzję {title}",
'notif.reviewComment': "{name} skomentował(a) twoją recenzję {title}",
'notif.friendReview': "{name} zrecenzował(a) {title}",
'notif.friendStarted': "{name} zaczął/zaczęła {title}",
'notif.friendAdded': "{name} chce obejrzeć {title}",
'notif.unread_one': '{count} nowe powiadomienie',
'notif.unread_other': '{count} nowych powiadomień',
'notif.unread_few': '{count} nowe powiadomienia',
+6 -1
View File
@@ -631,12 +631,17 @@ const dict: Translations = {
'social.noFollowing': 'Você ainda não segue ninguém.',
'social.noFollowers': 'Nenhum seguidor por enquanto.',
'notif.title': 'Notificações',
'notif.empty': 'Quando alguém te seguir ou deixar de seguir, verás aqui.',
'notif.empty': "Aqui vais ver seguidores, reações às tuas críticas e a atividade de quem segues.",
'notif.error': 'Não foi possível carregar as notificações.',
'notif.newFollower': '{name} segue-te',
'notif.followRequest': '{name} pediu para te seguir',
'notif.unfollow': '{name} deixou de te seguir',
'notif.followAccepted': '{name} aceitou o teu pedido',
'notif.reaction': "{name} reagiu {emoji} à tua crítica de {title}",
'notif.reviewComment': "{name} comentou a tua crítica de {title}",
'notif.friendReview': "{name} deu a sua opinião sobre {title}",
'notif.friendStarted': "{name} começou {title}",
'notif.friendAdded': "{name} quer ver {title}",
'notif.unread_one': '{count} nova notificação',
'notif.unread_other': '{count} novas notificações',
'social.accept': 'Aceitar',
+6 -1
View File
@@ -687,12 +687,17 @@ const dict: Translations = {
'social.noFollowing': 'Ты пока ни на кого не подписан.',
'social.noFollowers': 'Подписчиков пока нет.',
'notif.title': 'Уведомления',
'notif.empty': 'Когда кто-то подпишется или отпишется, ты увидишь это здесь.',
'notif.empty': "Здесь появятся подписки, реакции на твои отзывы и активность тех, на кого ты подписан(а).",
'notif.error': 'Не удалось загрузить уведомления.',
'notif.newFollower': '{name} подписался(-ась) на тебя',
'notif.followRequest': '{name} хочет подписаться на тебя',
'notif.unfollow': '{name} отписался(-ась) от тебя',
'notif.followAccepted': '{name} принял(а) твой запрос',
'notif.reaction': "{name} отреагировал(а) {emoji} на твой отзыв о {title}",
'notif.reviewComment': "{name} прокомментировал(а) твой отзыв о {title}",
'notif.friendReview': "{name} оставил(а) отзыв о {title}",
'notif.friendStarted': "{name} начал(а) смотреть {title}",
'notif.friendAdded': "{name} хочет посмотреть {title}",
'notif.unread_one': '{count} новое уведомление',
'notif.unread_other': 'Новых уведомлений: {count}',
'notif.unread_few': '{count} новых уведомления',
+6 -1
View File
@@ -631,12 +631,17 @@ const dict: Translations = {
'social.noFollowing': 'ยังไม่ได้ติดตามใคร',
'social.noFollowers': 'ยังไม่มีผู้ติดตาม',
'notif.title': 'การแจ้งเตือน',
'notif.empty': 'เมื่อมีคนติดตามหรือเลิกติดตามคุณ คุณจะเห็นที่นี่',
'notif.empty': "การติดตาม ความรู้สึกต่อรีวิวของคุณ และกิจกรรมของคนที่คุณติดตามจะแสดงที่นี่",
'notif.error': 'โหลดการแจ้งเตือนไม่ได้',
'notif.newFollower': '{name} ติดตามคุณ',
'notif.followRequest': '{name} ขอติดตามคุณ',
'notif.unfollow': '{name} เลิกติดตามคุณ',
'notif.followAccepted': '{name} ยอมรับคำขอของคุณ',
'notif.reaction': "{name} แสดงความรู้สึก {emoji} ต่อรีวิว {title} ของคุณ",
'notif.reviewComment': "{name} แสดงความคิดเห็นในรีวิว {title} ของคุณ",
'notif.friendReview': "{name} รีวิว {title}",
'notif.friendStarted': "{name} เริ่มดู {title}",
'notif.friendAdded': "{name} อยากดู {title}",
'notif.unread_one': 'การแจ้งเตือนใหม่ {count} รายการ',
'notif.unread_other': 'การแจ้งเตือนใหม่ {count} รายการ',
'social.accept': 'ยอมรับ',
+6 -1
View File
@@ -631,12 +631,17 @@ const dict: Translations = {
'social.noFollowing': 'Henüz kimseyi takip etmiyorsun.',
'social.noFollowers': 'Henüz takipçi yok.',
'notif.title': 'Bildirimler',
'notif.empty': 'Biri seni takip ettiğinde veya takibi bıraktığında burada göreceksin.',
'notif.empty': "Takipler, yorumlarına gelen tepkiler ve takip ettiklerinin etkinlikleri burada görünecek.",
'notif.error': 'Bildirimler yüklenemedi.',
'notif.newFollower': '{name} seni takip ediyor',
'notif.followRequest': '{name} seni takip etmek istiyor',
'notif.unfollow': '{name} seni takip etmeyi bıraktı',
'notif.followAccepted': '{name} isteğini kabul etti',
'notif.reaction': "{name}, {title} yorumuna {emoji} tepkisi verdi",
'notif.reviewComment': "{name}, {title} yorumuna yorum yaptı",
'notif.friendReview': "{name}, {title} hakkında yorum yazdı",
'notif.friendStarted': "{name}, {title} izlemeye başladı",
'notif.friendAdded': "{name}, {title} izlemek istiyor",
'notif.unread_one': '{count} yeni bildirim',
'notif.unread_other': '{count} yeni bildirim',
'social.accept': 'Kabul et',
+6 -1
View File
@@ -631,12 +631,17 @@ const dict: Translations = {
'social.noFollowing': 'Bạn chưa theo dõi ai.',
'social.noFollowers': 'Chưa có người theo dõi.',
'notif.title': 'Thông báo',
'notif.empty': 'Khi ai đó theo dõi hoặc bỏ theo dõi bạn, bạn sẽ thấy ở đây.',
'notif.empty': "Lượt theo dõi, phản hồi đánh giá của bạn và hoạt động của người bạn theo dõi sẽ hiện ở đây.",
'notif.error': 'Không tải được thông báo.',
'notif.newFollower': '{name} đã theo dõi bạn',
'notif.followRequest': '{name} muốn theo dõi bạn',
'notif.unfollow': '{name} đã bỏ theo dõi bạn',
'notif.followAccepted': '{name} đã chấp nhận yêu cầu của bạn',
'notif.reaction': "{name} đã bày tỏ {emoji} với đánh giá {title} của bạn",
'notif.reviewComment': "{name} đã bình luận đánh giá {title} của bạn",
'notif.friendReview': "{name} đã đánh giá {title}",
'notif.friendStarted': "{name} đã bắt đầu xem {title}",
'notif.friendAdded': "{name} muốn xem {title}",
'notif.unread_one': '{count} thông báo mới',
'notif.unread_other': '{count} thông báo mới',
'social.accept': 'Chấp nhận',
+6 -1
View File
@@ -631,12 +631,17 @@ const dict: Translations = {
'social.noFollowing': '还没有关注任何人。',
'social.noFollowers': '还没有粉丝。',
'notif.title': '通知',
'notif.empty': '有人关注或取消关注你时,会显示在这里。',
'notif.empty': "关注、对你评价的回应以及你关注的人的动态都会显示在这里。",
'notif.error': '无法加载通知。',
'notif.newFollower': '{name} 关注了你',
'notif.followRequest': '{name} 请求关注你',
'notif.unfollow': '{name} 取消关注了你',
'notif.followAccepted': '{name} 接受了你的请求',
'notif.reaction': "{name} 用 {emoji} 回应了你对《{title}》的评价",
'notif.reviewComment': "{name} 评论了你对《{title}》的评价",
'notif.friendReview': "{name} 评价了《{title}》",
'notif.friendStarted': "{name} 开始看《{title}》",
'notif.friendAdded': "{name} 想看《{title}》",
'notif.unread_one': '{count} 条新通知',
'notif.unread_other': '{count} 条新通知',
'social.accept': '同意',
+22 -3
View File
@@ -199,8 +199,19 @@ export const getFollowRequests = async () => toCards(await rpc('get_follow_reque
// ─── Notifications (abonnements uniquement) ───
export type NotificationKind = 'new_follower' | 'follow_request' | 'unfollow' | 'follow_accepted'
const NOTIFICATION_KINDS: NotificationKind[] = ['new_follower', 'follow_request', 'unfollow', 'follow_accepted']
export type NotificationKind =
| 'new_follower'
| 'follow_request'
| 'unfollow'
| 'follow_accepted'
| 'reaction'
| 'review_comment'
| 'friend_review'
| 'friend_started'
| 'friend_added'
const NOTIFICATION_KINDS: NotificationKind[] = ['new_follower', 'follow_request', 'unfollow', 'follow_accepted', 'reaction', 'review_comment', 'friend_review', 'friend_started', 'friend_added']
/** Notifications liées à un titre : celui de la personne, ou le mien (réaction / commentaire sur mon avis) */
export const MINE_ITEM_KINDS: NotificationKind[] = ['reaction', 'review_comment']
export interface FollowNotification {
id: number
@@ -208,6 +219,10 @@ export interface FollowNotification {
createdAt: string
read: boolean
actor: ProfileCard
/** Titre concerné (fiche publique) */
item?: MediaItem
/** Réaction choisie */
emoji?: string
}
export async function getNotifications(): Promise<FollowNotification[]> {
@@ -217,7 +232,11 @@ export async function getNotifications(): Promise<FollowNotification[]> {
if (!isPlainObject(n) || typeof n.id !== 'number' || !NOTIFICATION_KINDS.includes(n.kind as NotificationKind)) return []
const actor = toCard(n.actor)
const createdAt = safeIso(n.created_at)
return actor && createdAt ? [{ id: n.id, kind: n.kind as NotificationKind, createdAt, read: n.read === true, actor }] : []
const item = n.item == null ? undefined : (othersItem(n.item) ?? undefined)
// Notification liée à un titre devenu invisible : on ne l'affiche pas
if (n.item != null && !item) return []
const emoji = typeof n.emoji === 'string' && n.emoji.length <= 16 ? n.emoji : undefined
return actor && createdAt ? [{ id: n.id, kind: n.kind as NotificationKind, createdAt, read: n.read === true, actor, item, emoji }] : []
})
}
@@ -0,0 +1,165 @@
-- Bobinoo — notifications sociales de base (28 nov. 2026). Idempotent.
-- En plus des abonnements : réaction / commentaire sur mon avis, et activité des comptes que je suis
-- (avis donné, série commencée, titre ajouté à « À voir »). Toujours dans l'app, pas de push.
-- Les listes perso restent privées : pas de notification quand quelqu'un en crée une.
alter table public.notifications add column if not exists item_id text;
alter table public.notifications add column if not exists emoji text;
alter table public.notifications drop constraint if exists notifications_kind_check;
alter table public.notifications add constraint notifications_kind_check
check (kind in ('new_follower', 'follow_request', 'unfollow', 'follow_accepted',
'reaction', 'review_comment', 'friend_review', 'friend_started', 'friend_added'));
create index if not exists notifications_user_actor_kind_idx on public.notifications (user_id, actor_id, kind);
-- Garde commune : jamais entre comptes bloqués, ni d'un compte suspendu, ni à soi-même
create or replace function public.azuu_can_notify(p_target uuid, p_actor uuid)
returns boolean language sql stable security definer set search_path = '' as $$
select p_target is not null and p_actor is not null and p_target <> p_actor
and not exists (select 1 from public.blocks b
where (b.blocker_id = p_target and b.blocked_id = p_actor) or (b.blocker_id = p_actor and b.blocked_id = p_target))
and not exists (select 1 from public.profiles p where p.id = p_actor and p.suspended)
and exists (select 1 from auth.users u where u.id = p_target)
and exists (select 1 from auth.users u where u.id = p_actor)
$$;
revoke execute on function public.azuu_can_notify(uuid, uuid) from public, anon, authenticated;
-- On garde les 200 notifications les plus récentes par compte
create or replace function public.azuu_notif_prune(p_user uuid)
returns void language sql security definer set search_path = '' as $$
delete from public.notifications n
where n.user_id = p_user
and n.id < (select n2.id from public.notifications n2 where n2.user_id = p_user order by n2.id desc offset 199 limit 1)
$$;
revoke execute on function public.azuu_notif_prune(uuid) from public, anon, authenticated;
-- ─── Réactions à mon avis ───
create or replace function public.azuu_reaction_notify()
returns trigger language plpgsql security definer set search_path = '' as $$
begin
if tg_op = 'DELETE' then
delete from public.notifications where user_id = old.author_id and actor_id = old.user_id and kind = 'reaction' and item_id = old.item_id;
return null;
end if;
if not public.azuu_can_notify(new.author_id, new.user_id) then return null; end if;
-- Une seule ligne par personne et par avis (un changement d'emoji remplace l'ancienne)
delete from public.notifications where user_id = new.author_id and actor_id = new.user_id and kind = 'reaction' and item_id = new.item_id;
insert into public.notifications (user_id, kind, actor_id, item_id, emoji) values (new.author_id, 'reaction', new.user_id, new.item_id, left(new.emoji, 16));
perform public.azuu_notif_prune(new.author_id);
return null;
end $$;
revoke execute on function public.azuu_reaction_notify() from public, anon, authenticated;
drop trigger if exists review_reactions_notify on public.review_reactions;
create trigger review_reactions_notify after insert or update or delete on public.review_reactions
for each row execute function public.azuu_reaction_notify();
-- ─── Commentaires sur mon avis ───
create or replace function public.azuu_comment_notify()
returns trigger language plpgsql security definer set search_path = '' as $$
begin
if not public.azuu_can_notify(new.author_id, new.user_id) then return null; end if;
-- Plusieurs commentaires de la même personne sur le même avis : une seule ligne (la plus récente)
delete from public.notifications where user_id = new.author_id and actor_id = new.user_id and kind = 'review_comment' and item_id = new.item_id and read_at is null;
insert into public.notifications (user_id, kind, actor_id, item_id) values (new.author_id, 'review_comment', new.user_id, new.item_id);
perform public.azuu_notif_prune(new.author_id);
return null;
end $$;
revoke execute on function public.azuu_comment_notify() from public, anon, authenticated;
drop trigger if exists review_comments_notify on public.review_comments;
create trigger review_comments_notify after insert on public.review_comments
for each row execute function public.azuu_comment_notify();
-- ─── Activité des comptes que je suis ───
-- Envoi à tous les abonnés acceptés. Rafales (import, ajout en série) : une seule ligne non lue
-- par abonné, par personne et par type sur 3 heures, qui montre le titre le plus récent.
create or replace function public.azuu_notify_followers(p_actor uuid, p_kind text, p_item text)
returns void language plpgsql security definer set search_path = '' as $$
declare f record;
begin
if exists (select 1 from public.profiles p where p.id = p_actor and p.suspended) then return; end if;
for f in select follower_id from public.follows where following_id = p_actor and status = 'accepted' limit 2000 loop
if not public.azuu_can_notify(f.follower_id, p_actor) then continue; end if;
delete from public.notifications
where user_id = f.follower_id and actor_id = p_actor and kind = p_kind
and (item_id = p_item or (read_at is null and created_at > now() - interval '3 hours'));
insert into public.notifications (user_id, kind, actor_id, item_id) values (f.follower_id, p_kind, p_actor, p_item);
perform public.azuu_notif_prune(f.follower_id);
end loop;
end $$;
revoke execute on function public.azuu_notify_followers(uuid, text, text) from public, anon, authenticated;
create or replace function public.azuu_item_notify()
returns trigger language plpgsql security definer set search_path = '' as $$
declare
st text;
old_st text;
old_notes text := '';
recent date := current_date - 7;
begin
if new.deleted or new.data is null then return null; end if;
st := new.data->>'status';
if tg_op = 'UPDATE' then
-- Fiche restaurée (après suppression) : ce n'est pas une nouvelle activité
if old.deleted or old.data is null then return null; end if;
old_st := old.data->>'status';
old_notes := coalesce(old.data->>'notes', '');
end if;
-- Avis : quand un avis apparaît sur une fiche (pas à chaque retouche)
if old_notes = '' and coalesce(new.data->>'notes', '') <> '' then
perform public.azuu_notify_followers(new.user_id, 'friend_review', new.id);
end if;
-- Série / anime / drama commencé (récemment)
if st = 'en_cours' and old_st is distinct from 'en_cours' and coalesce(new.data->>'type', '') <> 'film'
and coalesce(public.azuu_day(new.data->>'startDate'), current_date) >= recent then
perform public.azuu_notify_followers(new.user_id, 'friend_started', new.id);
end if;
-- Ajouté à « À voir »
if tg_op = 'INSERT' and st = 'a_voir' and new.updated_at > now() - interval '2 days' then
perform public.azuu_notify_followers(new.user_id, 'friend_added', new.id);
end if;
return null;
end $$;
revoke execute on function public.azuu_item_notify() from public, anon, authenticated;
drop trigger if exists items_notify on public.items;
create trigger items_notify after insert or update on public.items
for each row execute function public.azuu_item_notify();
-- ─── Lecture ───
-- Le titre concerné est joint (fiche publique, sans les champs privés) ; une fiche que je ne peux plus voir est omise.
create or replace function public.get_notifications()
returns jsonb language sql stable security definer set search_path = '' as $$
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
where user_id = auth.uid() and public.azuu_mfa_ok()
order by 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)
$$;
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 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()))
$$;
revoke execute on function public.get_notifications() from public, anon;
revoke execute on function public.unread_notifications() from public, anon;
grant execute on function public.get_notifications() to authenticated;
grant execute on function public.unread_notifications() to authenticated;