teqo-backup/src/utilities/speech/speechCutData.ts
Francisco Solla 77216481d8 feat(C168): biblioteca de cortes no acervo (origem, download, compartilhar, editar texto)
Lista + detalhe em /campanha/comunicacao/acervo/cortes: busca por título/descrição,\norigem da fala, player do MP4, edição de título/descrição e kill switch de\npublicar/despublicar no mesmo /corte/<id>. Gate speechCatalog fail-closed para\nadvisor/leader. Sem collection/migration nova.
2026-09-15 12:56:51 -03:00

29 lines
870 B
TypeScript

import 'server-only'
import type { Payload } from 'payload'
import type { SpeechCutRecordForView } from '@/lib/speechCut'
import type { CampaignUser } from '@/payload-types'
/**
* C167/C168 — the one read of one cut by id, with the origin speech expanded
* (depth 1). The C167 actions use it to inspect/return a cut and the C168
* library detail loader uses it to throw the named not-found error — same
* query, `overrideAccess: false` against the actor's access.
*/
export const findSpeechCutForActor = async (
payload: Payload,
actor: CampaignUser,
cutId: number,
): Promise<SpeechCutRecordForView | null> => {
const result = await payload.find({
collection: 'speechCut',
where: { id: { equals: cutId } },
depth: 1,
limit: 1,
pagination: false,
user: actor,
overrideAccess: false,
})
return result.docs[0] ?? null
}