Some checks failed
CI (PR) / e2e (1) (pull_request) Successful in 5m9s
CI / build (push) Successful in 2m20s
CI (PR) / e2e (2) (pull_request) Successful in 5m18s
PR Ready + auto-merge / ready-automerge (pull_request) Failing after 30m17s
CI / e2e (1) (push) Successful in 4m5s
CI (PR) / scope (pull_request) Successful in 32s
CI / deploy homeserver (teqo-1313) (push) Has been cancelled
CI (PR) / lint (pull_request) Successful in 42s
CI (PR) / cycles (pull_request) Successful in 34s
CI (PR) / format (pull_request) Successful in 55s
CI (PR) / docs-guards (pull_request) Successful in 8s
CI (PR) / plans-only-closes (pull_request) Successful in 7s
Main merge flips claimed issues to done + in-prod / issue-done (pull_request) Successful in 13s
CI (PR) / typecheck (pull_request) Successful in 30s
CI (PR) / knip (pull_request) Successful in 31s
CI (PR) / unit (pull_request) Successful in 50s
CI (PR) / checks (pull_request) Successful in 2s
Promote plan-issue Related on main merge / plan-issue-ready (pull_request) Has been skipped
Agent pool supervisor / tick (pull_request) Successful in 27s
CI / static (push) Successful in 1m48s
CI / e2e (2) (push) Successful in 4m7s
CI (PR) / int (pull_request) Successful in 1m49s
CI / int (push) Successful in 1m57s
CI / checks (push) Successful in 2s
CI (PR) / build (pull_request) Successful in 2m31s
Board "Acompanhe de perto" (S1) ganha o feed automático do canal oficial: global SocialFeedSettings (admin-only, kill switch + toggle + maxItems + exclusões por item), loader src/utilities/youtubeFeed.ts (Data API v3 search→statistics, unstable_cache tag social-feed + revalidate 300, fail-closed com snapshot persistido via SQL direto — revalidateTag dentro de unstable_cache lança no Next 15.4), card generalizado (CampaignArticleCard → CampaignContentCard, external com noopener) e merge por recência com o grande = mais recente elegível. Stub HTTP do YouTube no webServer do Playwright (porta dev+1000) + 4 e2e novos no describe serial. Migration 20260818_111748_add_social_feed_settings (não destrutiva). Closes #18
52 lines
1.7 KiB
TypeScript
52 lines
1.7 KiB
TypeScript
import { ELECTION_TSE_CACHE_TAG } from '@/utilities/electionCache'
|
|
import { getGlobalCacheTag } from '@/utilities/globals'
|
|
import { MUNICIPALITY_CATALOG_CACHE_TAG } from '@/utilities/municipality/municipalityCatalogCache'
|
|
|
|
export const REVALIDATE_POSTS_TAG = 'posts' as const
|
|
|
|
export const REVALIDATE_PRIVACY_POLICY_CACHE_TAG = getGlobalCacheTag('privacy-policy')
|
|
|
|
/**
|
|
* Cache tag of the campaign home content board's external feeds (`unstable_cache`
|
|
* entry of `getYouTubeFeed`). The `SocialFeedSettings` global's `afterChange`
|
|
* busts it; the runbook tag is also allowlisted here for direct-DB writes.
|
|
*/
|
|
export const REVALIDATE_SOCIAL_FEED_TAG = 'social-feed' as const
|
|
|
|
const ALLOWED_REVALIDATE_TAGS = [
|
|
REVALIDATE_POSTS_TAG,
|
|
REVALIDATE_PRIVACY_POLICY_CACHE_TAG,
|
|
ELECTION_TSE_CACHE_TAG,
|
|
MUNICIPALITY_CATALOG_CACHE_TAG,
|
|
REVALIDATE_SOCIAL_FEED_TAG,
|
|
] as const
|
|
|
|
type AllowedRevalidateTag = (typeof ALLOWED_REVALIDATE_TAGS)[number]
|
|
|
|
const allowedTagSet = new Set<string>(ALLOWED_REVALIDATE_TAGS)
|
|
|
|
export type ResolveRevalidateTagResult =
|
|
| { ok: true; tag: AllowedRevalidateTag }
|
|
| { ok: false; error: string }
|
|
|
|
const isAllowedRevalidateTag = (tag: string): tag is AllowedRevalidateTag => allowedTagSet.has(tag)
|
|
|
|
export const resolveRevalidateTag = (
|
|
queryTag: string | null | undefined,
|
|
bodyTag: string | null | undefined,
|
|
): ResolveRevalidateTagResult => {
|
|
const requested = queryTag ?? bodyTag
|
|
|
|
if (requested == null || requested === '') {
|
|
return { ok: true, tag: REVALIDATE_POSTS_TAG }
|
|
}
|
|
|
|
if (!isAllowedRevalidateTag(requested)) {
|
|
return {
|
|
ok: false,
|
|
error: `Unknown tag. Allowed: ${ALLOWED_REVALIDATE_TAGS.join(', ')}`,
|
|
}
|
|
}
|
|
|
|
return { ok: true, tag: requested }
|
|
}
|