Immich : retirer l'identifiant Immich du graphe envoyé aux visiteurs

- buildGraphPayload ne mappe plus immichPersonId ; test qu'il n'apparaît pas
- le front ne propage plus le champ (graphAdapter, mockData et son test)
- le panneau Immich propose le retrait d'association en permanence, sans lire
  le champ ; unassign sans association ne fait rien : pas d'écriture, pas
  d'entrée d'audit (test du no-op), et le bouton de la fiche garde un
  libellé fixe

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
Mistral Vibe committed 2026-10-13 17:39:23 +02:00
1 parent 0bda88920d
commit 8d36a08b11
10 files changed
+42 -19

No files matched your search

+6
View File
@@ -495,6 +495,12 @@ export const immichRoutes: FastifyPluginAsync = async (app) => {
return reply.code(404).send({ error: 'person_not_found' })
}
// Le graphe ne dit plus qui est associé : le retrait se propose toujours côté front. Sans
// association en place, il ne fait rien — pas d'écriture, pas d'entrée d'audit.
if (!person.immichPersonId) {
return reply.send({ ok: true, avatarRemoved: false })
}
// Le portrait vient d'Immich uniquement si son fichier porte notre préfixe. Un portrait
// envoyé à la main reste en place : seule l'association est retirée.
const avatarFromImmich = person.avatarPath !== null && path.basename(person.avatarPath).startsWith('immich-')
-2
View File
@@ -17,7 +17,6 @@ export type GraphPayload = {
avatarUrlPath: string | null
sex: string | null
notes: string | null
immichPersonId: string | null
}>
unions: Array<{
id: string
@@ -91,7 +90,6 @@ export function buildGraphPayload(
avatarUrlPath: person.avatarPath ? `/trees/${treeId}/persons/${person.id}/avatar` : null,
sex: person.sex,
notes: person.notes,
immichPersonId: person.immichPersonId,
})),
unions: unions.map((union) => ({
id: union.id,
+4
View File
@@ -18,6 +18,7 @@ describe('buildGraphPayload', () => {
sex: null,
notes: null,
avatarPath: 't-1/p-2/avatar.jpg',
immichPersonId: '123e4567-e89b-42d3-a456-426614174000',
createdBy: null,
updatedBy: null,
createdAt: new Date(),
@@ -97,6 +98,9 @@ describe('buildGraphPayload', () => {
expect(graph.persons[0].birthDate).toBe('1994-06-02')
expect(graph.persons[0].birthName).toBe('Durand')
expect(graph.persons[0].avatarUrlPath).toBe('/trees/t-1/persons/p-2/avatar')
// L'identifiant Immich ne part jamais dans le graphe : il ne sert qu'aux administrateurs.
expect(graph.persons[0]).not.toHaveProperty('immichPersonId')
expect(graph.persons[1]).not.toHaveProperty('immichPersonId')
expect(graph.persons[1].avatarUrlPath).toBeNull()
expect(graph.unions[0].id).toBe('u-1')
expect(graph.filiations[0].viaUnionId).toBe('u-1')
+20
View File
@@ -737,6 +737,26 @@ describe('Immich integration: unassign', () => {
await app.close()
})
it('does nothing when no association is in place', async () => {
const app = createApp()
const token = await createUserToken(app)
prismaMock.person.findFirst.mockResolvedValue({ id: 'person-1', avatarPath: null, immichPersonId: null })
const response = await app.inject({
method: 'POST',
url: '/trees/tree-1/immich/unassign',
headers: { authorization: `Bearer ${token}` },
payload: { personId: 'person-1' },
})
expect(response.statusCode).toBe(200)
expect(response.json()).toEqual({ ok: true, avatarRemoved: false })
expect(prismaMock.person.update).not.toHaveBeenCalled()
expect(prismaMock.auditLog.create).not.toHaveBeenCalled()
await app.close()
})
it('rejects unknown persons and non-admin members', async () => {
const app = createApp()
const token = await createUserToken(app)
+9 -7
View File
@@ -113,7 +113,7 @@ const ImmichFacePanel = ({ person, treeId, token, onClose, onImmichChange }) =>
}, [selected, actionLoading, treeId, person, token, onImmichChange, onClose])
const handleUnassign = useCallback(async () => {
if (!person.immichPersonId || actionLoading) return
if (actionLoading) return
setActionLoading(true)
setError('')
try {
@@ -137,11 +137,13 @@ const ImmichFacePanel = ({ person, treeId, token, onClose, onImmichChange }) =>
}
}
// L'association en place se retire aussi bien sans connexion : changer ou retirer le serveur
// Immich ne laisse jamais une ancienne image impossible à nettoyer manuellement.
const currentAssociation = person.immichPersonId && (
// Le retrait se propose toujours : le graphe ne dit plus qui est associé. Une association en
// place se retire aussi bien sans connexion : changer ou retirer le serveur Immich ne laisse
// jamais une ancienne image impossible à nettoyer manuellement. Sans association, le retrait
// ne fait rien côté serveur.
const unassignBlock = (
<div className="immich-current">
<p>{t('{name} est déjà associée à une personne Immich.', { name: person.firstName || person.lastName })}</p>
<p>{t('{name} peut être détachée d’une personne Immich, même si Immich est injoignable.', { name: person.firstName || person.lastName })}</p>
<button type="button" className="pz-btn pz-btn--danger-ghost" onClick={handleUnassign} disabled={actionLoading}>
<Unlink size={16} aria-hidden="true" /> {t('Retirer l’association')}
</button>
@@ -163,7 +165,7 @@ const ImmichFacePanel = ({ person, treeId, token, onClose, onImmichChange }) =>
<div className="immich-body"><PzBusy /></div>
) : available === false ? (
<div className="immich-body">
{currentAssociation}
{unassignBlock}
<p className="immich-empty">
{unavailableReason === 'not_configured'
? t('Immich n’est pas configuré pour cet arbre. Ses administrateurs le règlent dans Paramètres de l’arbre.')
@@ -173,7 +175,7 @@ const ImmichFacePanel = ({ person, treeId, token, onClose, onImmichChange }) =>
</div>
) : (
<div className="immich-body">
{currentAssociation}
{unassignBlock}
<div className="pz-field">
<span className="pz-label" id="immichSearchLabel">{t('Personne à associer dans Immich')}</span>
+1 -1
View File
@@ -378,7 +378,7 @@ const PersonCard = ({
)}
{treeId && onImmichChange && (
<button type="button" className="pc-photo-btn" onClick={() => setShowImmichPanel(true)} disabled={avatarActionLoading}>
<Sparkles size={14} aria-hidden="true" /> {person.immichPersonId ? t('Visage Immich') : t('Depuis Immich')}
<Sparkles size={14} aria-hidden="true" /> {t('Depuis Immich')}
</button>
)}
</div>
-1
View File
@@ -115,7 +115,6 @@ function mapRemotePersonToLocal(person, current = null) {
profession: person?.profession || null,
nationality: person?.nationality || null,
photo: current?.photo || null,
immichPersonId: person?.immichPersonId ?? null,
}
}
-5
View File
@@ -15,7 +15,6 @@ describe('loadGraphData avatar mapping', () => {
deathDate: null,
notes: null,
avatarUrlPath: '/trees/t-1/persons/p-1/avatar',
immichPersonId: '123e4567-e89b-42d3-a456-426614174000',
},
{
id: 'p-2',
@@ -25,7 +24,6 @@ describe('loadGraphData avatar mapping', () => {
deathDate: null,
notes: null,
avatarUrlPath: null,
immichPersonId: null,
},
],
unions: [],
@@ -50,9 +48,6 @@ describe('loadGraphData avatar mapping', () => {
expect(getPersonById('p-1')?.photo).toBe('/api/trees/t-1/persons/p-1/avatar?token=abc')
expect(getPersonById('p-2')?.photo).toBeNull()
expect(getPersonMedias('p-2')[0]?.source).toBe('Album familial')
// Association Immich portée par la personne (null quand il n'y en a pas)
expect(getPersonById('p-1')?.immichPersonId).toBe('123e4567-e89b-42d3-a456-426614174000')
expect(getPersonById('p-2')?.immichPersonId).toBeNull()
})
})
+2 -2
View File
@@ -261,7 +261,6 @@ export default {
'Inconnu': 'Unknown',
// Visages venus d'Immich (PersonCard, ImmichFacePanel, immichApi)
'Depuis Immich': 'From Immich',
'Visage Immich': 'Immich face',
'Reconnaissance des visages': 'Face recognition',
'Immich n’est pas configuré pour cet arbre.': 'Immich is not configured for this tree.',
'Immich n’est pas configuré pour cet arbre. Ses administrateurs le règlent dans Paramètres de l’arbre.': 'Immich is not configured for this tree. Its administrators set it up in Tree settings.',
@@ -275,7 +274,8 @@ export default {
'Cette adresse Immich n’est pas autorisée par l’opérateur du serveur.': 'This Immich address is not authorized by the server operator.',
'Seuls les administrateurs de l’arbre peuvent associer un visage Immich.': 'Only tree administrators can link an Immich face.',
'Erreur inattendue.': 'Unexpected error.',
'{name} est déjà associée à une personne Immich.': '{name} is already linked to an Immich person.',
'{name} peut être détachée d’une personne Immich, même si Immich est injoignable.':
'{name} can be detached from an Immich person, even when Immich cannot be reached.',
'Retirer l’association': 'Remove the link',
'Personne à associer dans Immich': 'Immich person to link',
'Rechercher par nom': 'Search by name',
-1
View File
@@ -57,7 +57,6 @@ export function adaptGraphForGalaxy(apiGraph, _treeId) {
birthDate: p.birthDate,
deathDate: p.deathDate,
photo: p.avatarUrlPath ? `/api${p.avatarUrlPath}` : null,
immichPersonId: p.immichPersonId || null,
frameType: 'round', // Default
}))