From 5a4e358eee0e8bbc6cf41484b876edb798548e8a Mon Sep 17 00:00:00 2001 From: xCyanGrizzly Date: Mon, 22 Jun 2026 01:22:45 +0200 Subject: [PATCH] feat(telegram): add setTopicFetchEnabled server action Admin-guarded toggle of TopicProgress.fetchEnabled by row id. Persists immediately; the worker honours it on its next live per-topic read. Co-Authored-By: Claude Opus 4.8 --- src/app/(app)/telegram/actions.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/app/(app)/telegram/actions.ts b/src/app/(app)/telegram/actions.ts index 2096dca..2ba86ab 100644 --- a/src/app/(app)/telegram/actions.ts +++ b/src/app/(app)/telegram/actions.ts @@ -436,6 +436,32 @@ export async function rescanChannel(channelId: string): Promise { } } +// ── Topic fetch toggle ── + +export async function setTopicFetchEnabled( + topicProgressId: string, + enabled: boolean +): Promise { + const admin = await requireAdmin(); + if (!admin.success) return admin; + + const existing = await prisma.topicProgress.findUnique({ + where: { id: topicProgressId }, + }); + if (!existing) return { success: false, error: "Topic not found" }; + + try { + await prisma.topicProgress.update({ + where: { id: topicProgressId }, + data: { fetchEnabled: enabled }, + }); + revalidatePath(REVALIDATE_PATH); + return { success: true, data: undefined }; + } catch { + return { success: false, error: "Failed to update topic" }; + } +} + // ── Account-Channel link actions ── export async function linkChannel(