diff --git a/.github/workflows/conventional-commits.yml b/.github/workflows/conventional-commits.yml index 2547809e6..6482cd5e2 100644 --- a/.github/workflows/conventional-commits.yml +++ b/.github/workflows/conventional-commits.yml @@ -11,4 +11,4 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: ubiquity/action-conventional-commits@v1.1.2 + - uses: ubiquity/action-conventional-commits@master diff --git a/app.yml b/app.yml index 7c0b7f66c..8d0ae6726 100644 --- a/app.yml +++ b/app.yml @@ -24,7 +24,7 @@ default_events: # - gollum - issue_comment - issues - # - label + - label # - milestone # - member # - membership diff --git a/src/adapters/supabase/helpers/client.ts b/src/adapters/supabase/helpers/client.ts index 480ecd0f9..b8a3b23da 100644 --- a/src/adapters/supabase/helpers/client.ts +++ b/src/adapters/supabase/helpers/client.ts @@ -317,7 +317,7 @@ export const upsertAccessControl = async (username: string, repository: string, const { data: _data, error: _error } = await supabase.from("access").insert({ created_at: new Date().toUTCString(), price_access: false, - time_access: false, + time_access: true, multiplier_access: false, priority_access: false, ...properties, @@ -521,3 +521,55 @@ export const savePermit = async (permit: InsertPermit): Promise => { } return getPermitFromDbData(data[0]); }; + +export const saveLabelChange = async (username: string, repository: string, label_from: string, label_to: string, hasAccess: boolean) => { + const { supabase } = getAdapters(); + const { data, error } = await supabase + .from("label_changes") + .insert({ + username, + repository, + label_from, + label_to, + authorized: hasAccess || false, + created: new Date().toISOString(), + updated: new Date().toISOString(), + }) + .select(); + if (error) { + throw new Error(error.message); + } + if (!data || data.length === 0) { + throw new Error("No data returned"); + } + return data[0]; +}; + +export const getLabelChanges = async (repository: string, labels: string[]) => { + const { supabase } = getAdapters(); + const logger = getLogger(); + + const { data, error } = await supabase.from("label_changes").select("*").in("label_to", labels).eq("repository", repository).eq("authorized", false); + + logger.debug(`Getting label changes done, { data: ${JSON.stringify(data)}, error: ${JSON.stringify(error)} }`); + + if (error) { + throw new Error(`Error getting label changes: ${error.message}`); + } + + if (data.length === 0) { + return null; + } + return data[0]; +}; + +export const _approveLabelChange = async (changeId: number) => { + const { supabase } = getAdapters(); + const { error } = await supabase.from("label_changes").update({ authorized: true }).eq("id", changeId); + + if (error) { + throw new Error(error.message); + } + + return; +}; diff --git a/src/handlers/comment/commands.ts b/src/handlers/comment/commands.ts index 1f70da85c..1e390e581 100644 --- a/src/handlers/comment/commands.ts +++ b/src/handlers/comment/commands.ts @@ -12,4 +12,5 @@ export enum IssueCommentCommands { ALLOW = "/allow", AUTOPAY = "/autopay", + AUTHORIZE = "/authorize", } diff --git a/src/handlers/comment/handlers/assign.ts b/src/handlers/comment/handlers/assign.ts index e50831a64..6a8fabfe4 100644 --- a/src/handlers/comment/handlers/assign.ts +++ b/src/handlers/comment/handlers/assign.ts @@ -101,7 +101,7 @@ export const assign = async (body: string) => { commit: `@${payload.sender.login} ${deadLinePrefix} ${endTime.toUTCString()}`, tips: `
Tips: