From 2ffce75056c79d30841d8fa4b6d7b41c6db54f4b Mon Sep 17 00:00:00 2001 From: Ali BARIN Date: Thu, 3 Nov 2022 18:01:35 +0100 Subject: [PATCH] refactor(slack): move scopes out of function definition --- .../src/apps/slack/auth/create-auth-data.ts | 81 ++++++++++--------- 1 file changed, 41 insertions(+), 40 deletions(-) diff --git a/packages/backend/src/apps/slack/auth/create-auth-data.ts b/packages/backend/src/apps/slack/auth/create-auth-data.ts index c12b1e0d..64006a74 100644 --- a/packages/backend/src/apps/slack/auth/create-auth-data.ts +++ b/packages/backend/src/apps/slack/auth/create-auth-data.ts @@ -1,47 +1,48 @@ import { IField, IGlobalVariable } from '@automatisch/types'; import qs from 'qs'; +const scopes = [ + 'channels:manage', + 'channels:read', + 'channels:join', + 'chat:write', + 'chat:write.customize', + 'chat:write.public', + 'files:write', + 'im:write', + 'mpim:write', + 'team:read', + 'users.profile:read', + 'users:read', + 'workflow.steps:execute', + 'users:read.email', + 'commands', +]; +const userScopes = [ + 'channels:history', + 'channels:read', + 'channels:write', + 'chat:write', + 'emoji:read', + 'files:read', + 'files:write', + 'groups:history', + 'groups:read', + 'groups:write', + 'im:write', + 'mpim:write', + 'reactions:read', + 'reminders:write', + 'search:read', + 'stars:read', + 'team:read', + 'users.profile:read', + 'users.profile:write', + 'users:read', + 'users:read.email', +]; + export default async function createAuthData($: IGlobalVariable) { - const scopes = [ - 'channels:manage', - 'channels:read', - 'channels:join', - 'chat:write', - 'chat:write.customize', - 'chat:write.public', - 'files:write', - 'im:write', - 'mpim:write', - 'team:read', - 'users.profile:read', - 'users:read', - 'workflow.steps:execute', - 'users:read.email', - 'commands', - ]; - const userScopes = [ - 'channels:history', - 'channels:read', - 'channels:write', - 'chat:write', - 'emoji:read', - 'files:read', - 'files:write', - 'groups:history', - 'groups:read', - 'groups:write', - 'im:write', - 'mpim:write', - 'reactions:read', - 'reminders:write', - 'search:read', - 'stars:read', - 'team:read', - 'users.profile:read', - 'users.profile:write', - 'users:read', - 'users:read.email', - ]; const oauthRedirectUrlField = $.app.auth.fields.find( (field: IField) => field.key == 'oAuthRedirectUrl' );