MCPcopy Index your code
hub / github.com/simstudioai/sim / cleanupGitLabHookByUrl

Function cleanupGitLabHookByUrl

apps/sim/lib/webhooks/providers/gitlab.ts:33–57  ·  view source on GitHub ↗

* Best-effort cleanup that deletes any project hook pointing at `url`. Used to * avoid orphaning a hook when the create response can't be parsed for its id.

(
  projectId: string,
  accessToken: string,
  url: string,
  host: unknown
)

Source from the content-addressed store, hash-verified

31 * avoid orphaning a hook when the create response can't be parsed for its id.
32 */
33async function cleanupGitLabHookByUrl(
34 projectId: string,
35 accessToken: string,
36 url: string,
37 host: unknown
38): Promise<void> {
39 const res = await secureFetchWithValidation(gitlabProjectHooksUrl(projectId, host), {
40 headers: { 'PRIVATE-TOKEN': accessToken },
41 }).catch(() => null)
42 if (!res || !res.ok) return
43
44 const hooks = (await res.json().catch(() => null)) as Array<{ id?: number; url?: string }> | null
45 if (!Array.isArray(hooks)) return
46
47 await Promise.all(
48 hooks
49 .filter((hook) => hook.url === url && hook.id != null)
50 .map((hook) =>
51 secureFetchWithValidation(`${gitlabProjectHooksUrl(projectId, host)}/${hook.id}`, {
52 method: 'DELETE',
53 headers: { 'PRIVATE-TOKEN': accessToken },
54 }).catch(() => null)
55 )
56 )
57}
58
59export const gitlabHandler: WebhookProviderHandler = {
60 /**

Callers 1

createSubscriptionFunction · 0.85

Calls 2

gitlabProjectHooksUrlFunction · 0.85

Tested by

no test coverage detected