Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: public access control #41

Closed
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
38 changes: 18 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,24 @@ Helps settings prices and adds label to the issues accordingly.
Example of valid configuration:

```yml
- plugin: https://ubiquity-os-daemon-pricing.ubq.fi
type: github
with:
labels:
time:
- "Time: <1 Hour"
- "Time: <2 Hours"
- "Time: <4 Hours"
- "Time: <1 Day"
- "Time: <1 Week"
priority:
- "Priority: 1 (Normal)"
- "Priority: 2 (Medium)"
- "Priority: 3 (High)"
- "Priority: 4 (Urgent)"
- "Priority: 5 (Emergency)"
basePriceMultiplier: 1
publicAccessControl:
setLabel: true
fundExternalClosedIssue: false
- plugin: https://ubiquibot-assistive-pricing.ubq.fi
type: github
with:
labels:
time:
- "Time: <1 Hour"
- "Time: <2 Hours"
- "Time: <4 Hours"
- "Time: <1 Day"
- "Time: <1 Week"
priority:
- "Priority: 1 (Normal)"
- "Priority: 2 (Medium)"
- "Priority: 3 (High)"
- "Priority: 4 (Urgent)"
- "Priority: 5 (Emergency)"
basePriceMultiplier: 1
fundContributorClosedIssue: false
```

## Running locally
Expand Down
8 changes: 4 additions & 4 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@
"default": {},
"type": "object",
"properties": {
"setLabel": {
"default": false,
"type": "boolean"
},
"fundExternalClosedIssue": {
"default": false,
"type": "boolean"
}
},
"required": [
"fundContributorClosedIssue"
]
}
}
}
Expand Down
7 changes: 1 addition & 6 deletions src/shared/permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,9 @@ export async function labelAccessPermissionsCheck(context: ContextPlugin) {
return;
}
const { logger, payload } = context;
const { publicAccessControl } = context.config;
if (!payload.label?.name) return;

if (publicAccessControl.setLabel) {
logger.info("Public access control is enabled for setting labels");
return true;
}
if (payload.sender?.type === UserType.Bot) {
if (payload.sender.type === UserType.Bot) {
logger.info("Bot has full control over all labels");
return true;
}
Expand Down
8 changes: 1 addition & 7 deletions src/types/plugin-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,7 @@ export const pluginSettingsSchema = T.Object(
{ default: {} }
),
basePriceMultiplier: T.Number({ default: 1 }),
publicAccessControl: T.Object(
{
setLabel: T.Boolean({ default: false }),
fundExternalClosedIssue: T.Boolean({ default: false }),
},
{ default: {} }
),
fundContributorClosedIssue: T.Boolean({ default: false }),
},
{ default: {} }
);
Expand Down
Loading