diff --git a/.gitignore b/.gitignore index 6ed48a9..fa77501 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .env node_modules +whitelist.json \ No newline at end of file diff --git a/README.md b/README.md index 0a78069..c8586d4 100644 --- a/README.md +++ b/README.md @@ -33,3 +33,11 @@ $ npm i ``` $ npx tsx . ``` + +6. (Optional) Rename `whitelist.example.json` to `whitelist.json` and fill it with Slack User IDs who apart from admins/owners/primary owners should be able to view other people's verification. +```json +[ + "UA1B2C3D4E5", + "U0123456789" +] +``` diff --git a/index.ts b/index.ts index b7cb3d1..d8196d3 100644 --- a/index.ts +++ b/index.ts @@ -1,6 +1,6 @@ import type { UsersInfoResponse } from "@slack/web-api"; -const { App, ExpressReceiver } = (await import("@slack/bolt")); +const { App } = (await import("@slack/bolt")); import "dotenv/config"; const app = new App({ @@ -8,17 +8,21 @@ const app = new App({ signingSecret: process.env.SLACK_SIGNING_SECRET, }); -const whitelist: string[] = [] +const whitelist: string[] = (() => { + try { + return require('./whitelist.json') + } catch (e) { + return [] + } +})(); function checkUserOk(user: UsersInfoResponse['user']) { if (whitelist.includes(user!.id!)) return true - console.log(user) - return user!.is_admin || user!.is_owner || user!.is_primary_owner } -const eligibilityCmd = async ctx => { +const eligibilityCmd = async (ctx: any) => { await ctx.ack(); const text = ctx.command.text.slice(); diff --git a/whitelist.example.json b/whitelist.example.json new file mode 100644 index 0000000..1610ea1 --- /dev/null +++ b/whitelist.example.json @@ -0,0 +1,3 @@ +[ + +] \ No newline at end of file