Add ability to link Slack <-> Outline accounts (#6682)

This commit is contained in:
Tom Moor
2024-03-18 19:21:38 -06:00
committed by GitHub
parent e294fafd4f
commit cbdacc7cfd
23 changed files with 647 additions and 421 deletions

View File

@@ -1,18 +1,36 @@
import env from "@shared/env";
import { IntegrationType } from "@shared/types";
import { integrationSettingsPath } from "@shared/utils/routeHelpers";
export class SlackUtils {
private static authBaseUrl = "https://slack.com/oauth/authorize";
static commandsUrl(
{ baseUrl, params }: { baseUrl: string; params?: string } = {
baseUrl: `${env.URL}`,
params: undefined,
}
/**
* Create a state string for use in OAuth flows
*
* @param teamId The team ID
* @param type The integration type
* @param data Additional data to include in the state
* @returns A state string
*/
static createState(
teamId: string,
type: IntegrationType,
data?: Record<string, any>
) {
return params
? `${baseUrl}/auth/slack.commands?${params}`
: `${baseUrl}/auth/slack.commands`;
return JSON.stringify({ type, teamId, ...data });
}
/**
* Parse a state string from an OAuth flow
*
* @param state The state string
* @returns The parsed state
*/
static parseState<T>(
state: string
): { teamId: string; type: IntegrationType } & T {
return JSON.parse(state);
}
static callbackUrl(
@@ -26,7 +44,7 @@ export class SlackUtils {
: `${baseUrl}/auth/slack.callback`;
}
static postUrl(
static connectUrl(
{ baseUrl, params }: { baseUrl: string; params?: string } = {
baseUrl: `${env.URL}`,
params: undefined,