Modération et fiabilité : signalements, blocage, signaler un bug, remontée d'erreurs, sauvegardes
- Signaler (motif + précision ≤ 500 car.) un avis ou un profil via un bouton ⋯ générique (ReportButton / ReportDialog, cibles review | profile | comment | list). - Bloquer / débloquer un membre depuis son profil : abonnements retirés, plus de suivi ni de réaction possible, ses avis masqués côté app. - Administration : onglets Signalements (file regroupée par cible, aperçu actuel + copie au moment du signalement, actions supprimer / suspendre / résolu / classer), Suspendus, Bugs, Erreurs ; compteurs « à traiter » dans les onglets et dans Réglages. - Réglages > À propos : « Signaler un bug » avec infos techniques affichées avant envoi (sans compte : lien rdacet.fr). - Remontée d'erreurs sans tiers : window.onerror, unhandledrejection, ErrorBoundary global (écran « Oups… »), nettoyage des données perso, dédoublonnage, 10 envois max par session. - SQL (à appliquer) : 20261009160000_moderation.sql, 20261009160100_bugs_errors.sql — RLS partout, fonctions security definer + is_admin(), anti-abus. - Sauvegardes : workflow Gitea planifié, deploy/backup.sh (pg_dump, contrôles, gpg AES-256, rotation 7/4/6), deploy/BACKUP.md et deploy/restore.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YVo1qxKoBQCaMd7Ue8PGbe
This commit is contained in:
42 files changed
+4983
-32
No files matched your search
@@ -11,6 +11,7 @@ import { useMedia } from '../../store'
|
||||
import type { MediaInput, MediaItem } from '../../types'
|
||||
import { StatusPill, TypeBadge } from '../Badges'
|
||||
import Poster from '../Poster'
|
||||
import ReportButton from '../moderation/ReportButton'
|
||||
import Avatar from './Avatar'
|
||||
import Reactions from './Reactions'
|
||||
import { useEscape } from '../../lib/escape'
|
||||
@@ -120,6 +121,7 @@ export default function ItemPeek({ item, owner, onClose }: { item: MediaItem; ow
|
||||
{formatRating(item.rating, settings.ratingScale)}
|
||||
</span>
|
||||
)}
|
||||
{canReact && review && <ReportButton target={{ type: 'review', id: review.item_id, userId: review.user_id }} className="-me-1.5 size-8" size={16} />}
|
||||
</div>
|
||||
<div className="mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-ink-3">
|
||||
<StatusPill status={item.status} />
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Check, Loader2, Lock, Share2, Star, UserPlus } from 'lucide-react'
|
||||
import { Ban, Check, Loader2, Lock, Share2, Star, UserCheck, UserPlus } from 'lucide-react'
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { fmtNumber, t } from '../../i18n'
|
||||
import { follow, getProfile, getProfileItems, profileLink, unfollow, type Profile } from '../../lib/cloud/social'
|
||||
@@ -7,6 +7,8 @@ import { cx, formatRating } from '../../lib/utils'
|
||||
import { useMedia } from '../../store'
|
||||
import type { MediaItem, WatchStatus } from '../../types'
|
||||
import ConfirmDialog from '../ConfirmDialog'
|
||||
import ReportButton from '../moderation/ReportButton'
|
||||
import { blockUser, unblockUser, useBlocked } from '../../lib/cloud/moderation'
|
||||
import Poster from '../Poster'
|
||||
import { EmptyState, SectionTitle } from '../ui'
|
||||
import Avatar from './Avatar'
|
||||
@@ -58,6 +60,9 @@ export default function ProfileView({ username, onClose }: { username: string; o
|
||||
const [busy, setBusy] = useState(false)
|
||||
const [confirmUnfollow, setConfirmUnfollow] = useState(false)
|
||||
const [toast, setToast] = useState<string>()
|
||||
const [confirmBlock, setConfirmBlock] = useState(false)
|
||||
const { isBlocked } = useBlocked(!!profile && !profile.isMe)
|
||||
const blocked = !!profile && !profile.isMe && isBlocked(profile.id)
|
||||
|
||||
const load = useCallback(async () => {
|
||||
setError(undefined)
|
||||
@@ -132,6 +137,36 @@ export default function ProfileView({ username, onClose }: { username: string; o
|
||||
}
|
||||
}
|
||||
|
||||
// Bloquer : il ne peut plus me suivre ni réagir à mes avis ; ses avis me sont masqués
|
||||
const doBlock = async () => {
|
||||
if (!profile) return
|
||||
setConfirmBlock(false)
|
||||
setBusy(true)
|
||||
try {
|
||||
await blockUser({ id: profile.id, username: profile.username, displayName: profile.displayName, avatarUrl: profile.avatarUrl })
|
||||
await load()
|
||||
void social.refresh()
|
||||
setToast(t('block.done', { name: profile.displayName }))
|
||||
} catch (e) {
|
||||
setToast((e as Error).message)
|
||||
} finally {
|
||||
setBusy(false)
|
||||
}
|
||||
}
|
||||
|
||||
const doUnblock = async () => {
|
||||
if (!profile) return
|
||||
setBusy(true)
|
||||
try {
|
||||
await unblockUser(profile.id)
|
||||
setToast(t('block.undone', { name: profile.displayName }))
|
||||
} catch (e) {
|
||||
setToast((e as Error).message)
|
||||
} finally {
|
||||
setBusy(false)
|
||||
}
|
||||
}
|
||||
|
||||
const topByCategory = useMemo(() => {
|
||||
const out: { label: string; items: MediaItem[] }[] = []
|
||||
// Mon profil : mes réglages locaux font foi tout de suite (même avant la synchro)
|
||||
@@ -179,26 +214,43 @@ export default function ProfileView({ username, onClose }: { username: string; o
|
||||
{t('social.editProfile')}
|
||||
</button>
|
||||
) : (
|
||||
<button
|
||||
onClick={toggleFollow}
|
||||
disabled={busy}
|
||||
className={cx('btn mb-1 px-4 py-2 text-sm', profile.relation === 'none' ? 'btn-primary' : 'btn-ghost')}
|
||||
>
|
||||
{busy ? (
|
||||
<Loader2 size={15} className="animate-spin" />
|
||||
) : profile.relation === 'accepted' ? (
|
||||
<Check size={15} />
|
||||
) : profile.relation === 'none' ? (
|
||||
<UserPlus size={15} />
|
||||
) : null}
|
||||
{profile.relation === 'accepted'
|
||||
? t('social.following')
|
||||
: profile.relation === 'pending'
|
||||
? t('social.requested')
|
||||
: profile.followsMe
|
||||
? t('social.followBack')
|
||||
: t('social.follow')}
|
||||
</button>
|
||||
<div className="mb-1 flex items-center gap-1">
|
||||
{blocked ? (
|
||||
<button onClick={doUnblock} disabled={busy} className="btn btn-ghost px-4 py-2 text-sm">
|
||||
{busy ? <Loader2 size={15} className="animate-spin" /> : <UserCheck size={15} />}
|
||||
{t('block.unblock')}
|
||||
</button>
|
||||
) : (
|
||||
<button
|
||||
onClick={toggleFollow}
|
||||
disabled={busy}
|
||||
className={cx('btn px-4 py-2 text-sm', profile.relation === 'none' ? 'btn-primary' : 'btn-ghost')}
|
||||
>
|
||||
{busy ? (
|
||||
<Loader2 size={15} className="animate-spin" />
|
||||
) : profile.relation === 'accepted' ? (
|
||||
<Check size={15} />
|
||||
) : profile.relation === 'none' ? (
|
||||
<UserPlus size={15} />
|
||||
) : null}
|
||||
{profile.relation === 'accepted'
|
||||
? t('social.following')
|
||||
: profile.relation === 'pending'
|
||||
? t('social.requested')
|
||||
: profile.followsMe
|
||||
? t('social.followBack')
|
||||
: t('social.follow')}
|
||||
</button>
|
||||
)}
|
||||
<ReportButton
|
||||
target={{ type: 'profile', id: profile.id, userId: profile.id }}
|
||||
actions={[
|
||||
blocked
|
||||
? { icon: <UserCheck size={18} />, label: t('block.unblock'), onClick: () => void doUnblock() }
|
||||
: { icon: <Ban size={18} />, label: t('block.block'), onClick: () => setConfirmBlock(true) },
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -213,6 +265,12 @@ export default function ProfileView({ username, onClose }: { username: string; o
|
||||
)}
|
||||
</p>
|
||||
{profile.bio && <p className="mt-3 whitespace-pre-line text-sm leading-relaxed text-ink-2 lg:max-w-3xl lg:text-base">{profile.bio}</p>}
|
||||
{blocked && (
|
||||
<p className="mt-4 flex items-start gap-2.5 rounded-2xl border border-line px-4 py-3 text-sm text-ink-2 lg:max-w-2xl">
|
||||
<Ban size={16} className="mt-0.5 shrink-0 text-accent" />
|
||||
{t('block.notice')}
|
||||
</p>
|
||||
)}
|
||||
|
||||
<div className="mt-5 flex divide-x divide-line rounded-2xl border border-line py-3 lg:max-w-2xl">
|
||||
<Stat value={profile.visible ? (profile.stats?.finished ?? 0) : undefined} label={t('social.seen')} />
|
||||
@@ -262,6 +320,14 @@ export default function ProfileView({ username, onClose }: { username: string; o
|
||||
{toast}
|
||||
</p>
|
||||
)}
|
||||
<ConfirmDialog
|
||||
open={confirmBlock}
|
||||
title={t('block.confirmTitle', { name: profile?.displayName ?? '' })}
|
||||
message={t('block.confirmText')}
|
||||
confirmLabel={t('block.block')}
|
||||
onConfirm={doBlock}
|
||||
onCancel={() => setConfirmBlock(false)}
|
||||
/>
|
||||
<ConfirmDialog
|
||||
open={confirmUnfollow}
|
||||
title={profile?.relation === 'pending' ? t('social.cancelRequestTitle') : t('social.unfollowTitle', { name: profile?.displayName ?? '' })}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import { Loader2, Star } from 'lucide-react'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { t } from '../../i18n'
|
||||
import { useBlocked } from '../../lib/cloud/moderation'
|
||||
import { titleReviews, type TitleReview, type TitleReviews as TitleReviewsData } from '../../lib/cloud/reviews'
|
||||
import { formatRating } from '../../lib/utils'
|
||||
import { useMedia } from '../../store'
|
||||
import ReportButton from '../moderation/ReportButton'
|
||||
import Avatar from './Avatar'
|
||||
import Reactions from './Reactions'
|
||||
import Sheet from './Sheet'
|
||||
@@ -12,6 +14,8 @@ import Sheet from './Sheet'
|
||||
export default function TitleReviews({ externalId, title, onClose, onOpenProfile }: { externalId: string; title: string; onClose: () => void; onOpenProfile: (username: string) => void }) {
|
||||
const [data, setData] = useState<TitleReviewsData>()
|
||||
const [error, setError] = useState(false)
|
||||
// Avis des comptes que j'ai bloqués : masqués
|
||||
const { isBlocked } = useBlocked()
|
||||
|
||||
useEffect(() => {
|
||||
let alive = true
|
||||
@@ -23,7 +27,9 @@ export default function TitleReviews({ externalId, title, onClose, onOpenProfile
|
||||
}
|
||||
}, [externalId])
|
||||
|
||||
const bothEmpty = !!data && data.friends.length === 0 && data.others.length === 0
|
||||
const friends = data?.friends.filter((r) => !isBlocked(r.user_id)) ?? []
|
||||
const others = data?.others.filter((r) => !isBlocked(r.user_id)) ?? []
|
||||
const bothEmpty = !!data && friends.length === 0 && others.length === 0
|
||||
|
||||
return (
|
||||
<Sheet title={title} label={t('reviews.title')} onClose={onClose} elevated>
|
||||
@@ -36,8 +42,8 @@ export default function TitleReviews({ externalId, title, onClose, onOpenProfile
|
||||
<p className="px-4 py-16 text-center text-sm text-ink-3">{t('reviews.none')}</p>
|
||||
) : (
|
||||
<div className="grid grid-cols-1 gap-4 px-4 pt-4 sm:grid-cols-2">
|
||||
<ReviewColumn heading={t('reviews.friends')} empty={t('reviews.noneFriends')} list={data.friends} onOpenProfile={onOpenProfile} />
|
||||
<ReviewColumn heading={t('reviews.others')} empty={t('reviews.noneOthers')} list={data.others} onOpenProfile={onOpenProfile} />
|
||||
<ReviewColumn heading={t('reviews.friends')} empty={t('reviews.noneFriends')} list={friends} onOpenProfile={onOpenProfile} />
|
||||
<ReviewColumn heading={t('reviews.others')} empty={t('reviews.noneOthers')} list={others} onOpenProfile={onOpenProfile} />
|
||||
</div>
|
||||
)}
|
||||
</Sheet>
|
||||
@@ -77,6 +83,7 @@ function ReviewCard({ r, onOpenProfile }: { r: TitleReview; onOpenProfile: (user
|
||||
{formatRating(r.rating, settings.ratingScale)}
|
||||
</span>
|
||||
)}
|
||||
<ReportButton target={{ type: 'review', id: r.item_id, userId: r.user_id }} className="-me-1.5" size={16} />
|
||||
</div>
|
||||
{r.notes && <p className="mt-2 whitespace-pre-line text-sm leading-relaxed text-ink-2">{r.notes}</p>}
|
||||
<div className="mt-3">
|
||||
|
||||
Reference in new issue
Block a user