Compare commits

...

2 commits

Author SHA1 Message Date
Renovate Bot b650333bbc
Update dependency @slack/bolt to v3.21.2 2024-09-05 16:10:07 +00:00
DaInfLoop 7b6fcdf650
change whitelist to work with a JSON file 2024-09-05 17:07:28 +01:00
5 changed files with 25 additions and 25 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
.env
node_modules
whitelist.json

View file

@ -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"
]
```

View file

@ -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();

24
package-lock.json generated
View file

@ -16,15 +16,15 @@
}
},
"node_modules/@slack/bolt": {
"version": "3.21.1",
"resolved": "https://registry.npmjs.org/@slack/bolt/-/bolt-3.21.1.tgz",
"integrity": "sha512-cql+f8DypIE96mgFTREslP1DfsTUMyVR76whdepcQ1BpP2vXO1TZJxwJHnDKcnJ+NTg8KNGfPIjDfHZUMETCKw==",
"version": "3.21.2",
"resolved": "https://registry.npmjs.org/@slack/bolt/-/bolt-3.21.2.tgz",
"integrity": "sha512-Cft+5dbl+YApK2GVFX9O86k0qIqQXshnBGq9oK4a4rLfklyfw9TcydmOxEd32aR/2HbBwr7o/pwu5UAI2c/bUg==",
"license": "MIT",
"dependencies": {
"@slack/logger": "^4.0.0",
"@slack/oauth": "^2.6.3",
"@slack/socket-mode": "^1.3.6",
"@slack/types": "^2.11.0",
"@slack/types": "^2.13.0",
"@slack/web-api": "^6.12.1",
"@types/express": "^4.16.1",
"@types/promise.allsettled": "^1.0.3",
@ -32,7 +32,6 @@
"axios": "^1.7.4",
"express": "^4.16.4",
"path-to-regexp": "^6.2.1",
"please-upgrade-node": "^3.2.0",
"promise.allsettled": "^1.0.2",
"raw-body": "^2.3.3",
"tsscmp": "^1.0.6"
@ -1941,15 +1940,6 @@
"integrity": "sha512-GQX3SSMokngb36+whdpRXE+3f9V8UzyAorlYvOGx87ufGHehNTn5lCxrKtLyZ4Yl/wEKnNnr98ZzOwwDZV5ogw==",
"license": "MIT"
},
"node_modules/please-upgrade-node": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/please-upgrade-node/-/please-upgrade-node-3.2.0.tgz",
"integrity": "sha512-gQR3WpIgNIKwBMVLkpMUeR3e1/E1y42bqDQZfql+kDeXd8COYfM8PQA4X6y7a8u9Ua9FHmsrrmirW2vHs45hWg==",
"license": "MIT",
"dependencies": {
"semver-compare": "^1.0.0"
}
},
"node_modules/possible-typed-array-names": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/possible-typed-array-names/-/possible-typed-array-names-1.0.0.tgz",
@ -2137,12 +2127,6 @@
"node": ">=10"
}
},
"node_modules/semver-compare": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/semver-compare/-/semver-compare-1.0.0.tgz",
"integrity": "sha512-YM3/ITh2MJ5MtzaM429anh+x2jiLVjqILF4m4oyQB18W7Ggea7BfqdH/wGMK7dDiMghv/6WG7znWMwUDzJiXow==",
"license": "MIT"
},
"node_modules/send": {
"version": "0.18.0",
"resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz",

3
whitelist.example.json Normal file
View file

@ -0,0 +1,3 @@
[
]