mirror of
https://github.com/fsolla/teqo.git
synced 2026-12-03 13:53:06 +00:00
Envio em lote (1 request raw-body por arquivo, fan-out ≤2, até 50 arquivos) e adicionar por link (Instagram/YouTube; extração só pela Graph API da conta própria, senão peça-link) em /campanha/comunicacao/conteudos. Cada peça tem estado próprio (Processando/Pronto/Falhou + Reprocessar), transcrição/texto e catalogação automática revisável; publicar/despublicar preserva arquivo, slug e publishedAt. - collections contentPiece + contentMedia (upload privado no S3) e migration 20260923_032714_add_content_piece (slug único gerado no 1º publish, sourceUrl única, searchText com índice trigram) - pipeline reusa C199 (job after() + reaper + retry condicional, transcrição DeepInfra, ffmpeg/chunk), o classificador de facetas do acervo e o institutionCatalog; curatedFields impede o job de sobrescrever curadoria - gate único canReadCommunicationCatalog (advisor/leader negados); delete só pelo admin; sem Consent novo - UI portada do design aprovado (lista desktop + cards mobile, diálogo de lote com progresso por arquivo, diálogo de link, ficha editável, kill switch); nav/chrome/column-picker/manifest atualizados - instagramFeed expõe mediaUrl; revalidateTag ganha wrapper seguro fora de request (fixtures/scripts) - testes: 2 unit specs, 1 int spec (16 casos) e 7 e2e na vertical - follow-up de engenharia: #1267 (docs/plans/escala-dry-pos-c211.md) Closes #1254
45 lines
1.8 KiB
TypeScript
45 lines
1.8 KiB
TypeScript
// ---------------------------------------------------------------------------
|
|
// C211 — content pieces of the internal communication Central
|
|
// ---------------------------------------------------------------------------
|
|
|
|
import type { Access } from 'payload'
|
|
|
|
import { canReadCommunicationCatalog } from '@/lib/campaignRoles'
|
|
import { getFreshCampaignUser, isPayloadAdmin } from '@/utilities/access/shared'
|
|
|
|
/**
|
|
* Readers of the content pieces: Payload admin or campaign users with the
|
|
* `communicator`, `coordinator` or `candidate` role — the same vertical gate as
|
|
* the acervo and the reels. Advisors and leaders are denied (fail-closed): the
|
|
* Central is editorial material, not a municipality-scoped staff area.
|
|
*/
|
|
export const canReadContentPiece: Access = async ({ req }) => {
|
|
if (isPayloadAdmin(req.user)) return true
|
|
|
|
const currentUser = await getFreshCampaignUser(req)
|
|
return currentUser ? canReadCommunicationCatalog(currentUser.role) : false
|
|
}
|
|
|
|
/**
|
|
* Who may add a piece to the Central (upload, link, attach the original file):
|
|
* the same audience. Written as its own predicate, never an alias of
|
|
* `canReadContentPiece`, so a future widening of the read surface cannot
|
|
* silently grant writes.
|
|
*/
|
|
export const canCreateContentPiece: Access = async ({ req }) => {
|
|
if (isPayloadAdmin(req.user)) return true
|
|
|
|
const currentUser = await getFreshCampaignUser(req)
|
|
return currentUser ? canReadCommunicationCatalog(currentUser.role) : false
|
|
}
|
|
|
|
/**
|
|
* Who may edit a piece's catalogue and move the kill switch. Its own predicate
|
|
* for the same reason as the create one.
|
|
*/
|
|
export const canUpdateContentPiece: Access = async ({ req }) => {
|
|
if (isPayloadAdmin(req.user)) return true
|
|
|
|
const currentUser = await getFreshCampaignUser(req)
|
|
return currentUser ? canReadCommunicationCatalog(currentUser.role) : false
|
|
}
|