Building Slack integration
This commit is contained in:
@@ -3,7 +3,8 @@ import type {
|
||||
ProviderSlug,
|
||||
SignatureScheme,
|
||||
} from '../types/integration.js';
|
||||
import { normalizeLinear, normalizeRest } from './normalizers.js';
|
||||
import { normalizeLinear, normalizeRest, normalizeSlack } from './normalizers.js';
|
||||
import { enrichSlackDelivery } from '../services/slack.service.js';
|
||||
|
||||
export type ChallengeResponse = { status: number; body: unknown };
|
||||
|
||||
@@ -22,6 +23,15 @@ export type ProviderConfig = {
|
||||
* infrastructure; the payload mapping belongs to the integration itself.
|
||||
*/
|
||||
normalize?: (payload: unknown) => NormalizedDelivery;
|
||||
/**
|
||||
* Runs after the ack, inside the retry queue, so it may make network calls.
|
||||
* Receives the raw payload because some providers deliver a reference rather
|
||||
* than content: a Slack reaction names a message without including its text.
|
||||
*/
|
||||
enrich?: (
|
||||
delivery: NormalizedDelivery,
|
||||
payload: unknown
|
||||
) => Promise<NormalizedDelivery>;
|
||||
oauth?: {
|
||||
authorizeUrl: string;
|
||||
tokenUrl: string;
|
||||
@@ -63,6 +73,8 @@ export const providers: Record<ProviderSlug, ProviderConfig> = {
|
||||
timestampHeader: 'x-slack-request-timestamp',
|
||||
secretEnvVar: 'SLACK_SIGNING_SECRET',
|
||||
challenge: slackChallenge,
|
||||
normalize: normalizeSlack,
|
||||
enrich: enrichSlackDelivery,
|
||||
oauth: {
|
||||
authorizeUrl: 'https://slack.com/oauth/v2/authorize',
|
||||
tokenUrl: 'https://slack.com/api/oauth.v2.access',
|
||||
|
||||
Reference in New Issue
Block a user