forked from ubiquity/ubiquibot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/development' into e2e-tests
- Loading branch information
Showing
24 changed files
with
951 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{ | ||
"useGitignore": true, | ||
"version": "0.2", | ||
"language": "en", | ||
"words": [ | ||
"autodetection", | ||
"autopay", | ||
"AUTOPAY", | ||
"bucketid", | ||
"bucketname", | ||
"demilestoned", | ||
"devpool", | ||
"ensname", | ||
"fkey", | ||
"gelato", | ||
"Gelato", | ||
"gollum", | ||
"keccak", | ||
"libsodium", | ||
"logdna", | ||
"LOGDNA", | ||
"mdast", | ||
"Mdast", | ||
"mergeable", | ||
"micromark", | ||
"milestoned", | ||
"Numberish", | ||
"orgname", | ||
"pavlovcik", | ||
"permisson", | ||
"prereleased", | ||
"probot", | ||
"Probot", | ||
"ratelimit", | ||
"rebaseable", | ||
"rerequested", | ||
"scalarmult", | ||
"signoff", | ||
"sortcolumn", | ||
"sortorder", | ||
"supabase", | ||
"Supabase", | ||
"SUPABASE", | ||
"svgs", | ||
"timelabel", | ||
"TURL", | ||
"typebox", | ||
"Ubiqui", | ||
"ubiquibot", | ||
"unarchived", | ||
"Unassigning", | ||
"Upserting", | ||
"URLSAFE", | ||
"vitalik", | ||
"WXDAI" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,5 @@ export enum IssueCommentCommands { | |
|
||
ALLOW = "/allow", | ||
AUTOPAY = "/autopay", | ||
AUTHORIZE = "/authorize", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { _approveLabelChange, getLabelChanges } from "../../../adapters/supabase"; | ||
import { getBotContext, getLogger } from "../../../bindings"; | ||
import { getUserPermission } from "../../../helpers"; | ||
import { Payload } from "../../../types"; | ||
import { ErrorDiff } from "../../../utils/helpers"; | ||
import { bountyInfo } from "../../wildcard"; | ||
|
||
export const approveLabelChange = async () => { | ||
const context = getBotContext(); | ||
const logger = getLogger(); | ||
const payload = context.payload as Payload; | ||
const sender = payload.sender.login; | ||
|
||
logger.info(`Received '/authorize' command from user: ${sender}`); | ||
|
||
const { issue, repository } = payload; | ||
if (!issue) { | ||
logger.info(`Skipping '/authorize' because of no issue instance`); | ||
return; | ||
} | ||
|
||
// check if sender is admin | ||
// passing in context so we don't have to make another request to get the user | ||
const permissionLevel = await getUserPermission(sender, context); | ||
|
||
// if sender is not admin, return | ||
if (permissionLevel !== "admin" && permissionLevel !== "billing_manager") { | ||
logger.info(`User ${sender} is not an admin/billing_manager`); | ||
return ErrorDiff(`You are not an admin/billing_manager and do not have the required permissions to access this function.`); | ||
} | ||
|
||
const issueDetailed = bountyInfo(issue); | ||
|
||
if (!issueDetailed.priceLabel || !issueDetailed.priorityLabel || !issueDetailed.timelabel) { | ||
logger.info(`Skipping... its not a bounty`); | ||
return ErrorDiff(`No valid bounty label on this issue`); | ||
} | ||
|
||
// check for label altering here | ||
const labelChanges = await getLabelChanges(repository.full_name, [issueDetailed.priceLabel, issueDetailed.priorityLabel, issueDetailed.timelabel]); | ||
|
||
await _approveLabelChange(labelChanges.id); | ||
|
||
return `Label change has been approved, permit can now be generated`; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { saveLabelChange } from "../../adapters/supabase"; | ||
import { getBotContext, getLogger } from "../../bindings"; | ||
import { hasLabelEditPermission } from "../../helpers"; | ||
import { Payload } from "../../types"; | ||
|
||
export const watchLabelChange = async () => { | ||
const logger = getLogger(); | ||
const context = getBotContext(); | ||
|
||
const payload = context.payload as Payload; | ||
|
||
const { repository, label, changes, sender } = payload; | ||
|
||
const { full_name } = repository; | ||
|
||
const previousLabel = changes?.name.from; | ||
const currentLabel = label?.name; | ||
const triggerUser = sender.login; | ||
|
||
if (!previousLabel || !currentLabel) { | ||
logger.debug("watchLabelChange: No label name change.. skipping"); | ||
return; | ||
} | ||
|
||
// check if user is authorized to make the change | ||
const hasAccess = await hasLabelEditPermission(currentLabel, triggerUser, repository.full_name); | ||
|
||
await saveLabelChange(triggerUser, full_name, previousLabel, currentLabel, hasAccess); | ||
logger.debug("watchLabelChange: label name change saved to db"); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.