From decad1a42deeab58f6b0f19b2f50dca9c4310529 Mon Sep 17 00:00:00 2001 From: Loki Date: Tue, 3 Nov 2026 21:15:48 +0800 Subject: [PATCH] fix: find the GitLab record by its key MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit winlab-helper's records now link the recording on Nextcloud, so a search for meet.winlab.tw missed them and every recording read 還沒歸檔. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_014sgfmRNRtGuDLrKY4AjgHi --- lib/actions/recordings.ts | 2 +- lib/gitlab.ts | 42 +++++++++++++++++++-------------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/lib/actions/recordings.ts b/lib/actions/recordings.ts index 023aad3..85668af 100644 --- a/lib/actions/recordings.ts +++ b/lib/actions/recordings.ts @@ -410,7 +410,7 @@ export const getRecording = defineAction({ }) : null, gitlabConfigured() - ? recordUrl(recordKeys(rec), rec.startedAt).catch((error) => { + ? recordUrl(recordKeys(rec)).catch((error) => { emitErrorLog(error, { source: "gitlab record" }) return null }) diff --git a/lib/gitlab.ts b/lib/gitlab.ts index 2f80bc8..692ba38 100644 --- a/lib/gitlab.ts +++ b/lib/gitlab.ts @@ -12,29 +12,29 @@ export const gitlabConfigured = () => Boolean(process.env.GITLAB_API_TOKEN) type Epic = { web_url: string; description: string | null; state: string } /** The record's web URL for the first key found, or null. Searches the - * lab's epics that mention meet.winlab.tw, updated from a day before the - * recording started (filing a recording updates its record). */ -export async function recordUrl(keys: string[], since: Date) { + * lab's epics for each key in turn: the record links the recording on + * Nextcloud, not on meet.winlab.tw, so the key is the one text it is sure + * to hold. */ +export async function recordUrl(keys: string[]) { const token = process.env.GITLAB_API_TOKEN - if (!token || keys.length === 0) return null - const query = new URLSearchParams({ - search: "meet.winlab.tw", - include_descendant_groups: "true", - state: "all", - updated_after: new Date(since.getTime() - 86_400_000).toISOString(), - per_page: "100", - }) - const response = await fetch( - `${base()}/api/v4/groups/${encodeURIComponent(group())}/epics?${query}`, - { - headers: { "private-token": token }, - cache: "no-store", - signal: AbortSignal.timeout(8000), - } - ) - if (!response.ok) throw new Error(`GitLab ${response.status}`) - const epics = (await response.json()) as Epic[] + if (!token) return null for (const key of keys) { + const query = new URLSearchParams({ + search: key, + include_descendant_groups: "true", + state: "all", + per_page: "20", + }) + const response = await fetch( + `${base()}/api/v4/groups/${encodeURIComponent(group())}/epics?${query}`, + { + headers: { "private-token": token }, + cache: "no-store", + signal: AbortSignal.timeout(8000), + } + ) + if (!response.ok) throw new Error(`GitLab ${response.status}`) + const epics = (await response.json()) as Epic[] const marker = `request="${key}"` const found = epics.find((e) => e.description?.includes(marker)) if (found) return found.web_url