teqo-backup/src/utilities/access/archivePhotos.ts
Francisco Solla aba3aa4816 feat(C231): ingerir o acervo de fotos do Flickr no storage privado
Collection privada archivePhoto (flickrId unique+index, metadados do Flickr +
EXIF, leitura pela comunicação, mutação admin, entrada no mapa S3) com migration
aditiva add_archive_photo; ingestão idempotente (transação + upload) e CLI
pnpm flickr:import (plano dry-run por padrão, --apply com intenção/TEQO_ENV/S3,
--verify inventário read-only, recibos JSON em data/flickr/reports). Guard de
alvo extraído de reel-ingest para scripts/lib/cli.mjs; downloadUrlToFile ganha
headers (User-Agent do Flickr).
2026-09-26 05:40:22 -03:00

23 lines
1 KiB
TypeScript

// ---------------------------------------------------------------------------
// C231 — Flickr photo archive
// ---------------------------------------------------------------------------
import type { Access } from 'payload'
import { canReadCommunicationCatalog } from '@/lib/campaignRoles'
import { getFreshCampaignUser, isPayloadAdmin } from '@/utilities/access/shared'
/**
* Readers of the photo archive: Payload admin or campaign users with the
* `communicator`, `coordinator` or `candidate` role — the same vertical gate as
* the acervo de falas, the reels and the Central. Advisors and leaders are
* denied (fail-closed): the raw archive is editorial material, not a
* municipality-scoped staff area. C232 curates these same rows; the CLI
* ingests with an explicit documented bypass.
*/
export const canReadArchivePhoto: Access = async ({ req }) => {
if (isPayloadAdmin(req.user)) return true
const currentUser = await getFreshCampaignUser(req)
return currentUser ? canReadCommunicationCatalog(currentUser.role) : false
}