Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/actions/recordings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down
42 changes: 21 additions & 21 deletions lib/gitlab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading