mirror of
https://github.com/mfts/papermark.git
synced 2025-12-20 01:03:24 +08:00
fix: slack integration types
This commit is contained in:
@@ -3,7 +3,7 @@ import prisma from "@/lib/prisma";
|
||||
import { SlackClient } from "./client";
|
||||
import { getSlackEnv } from "./env";
|
||||
import { createSlackMessage } from "./templates";
|
||||
import { SlackEventData, SlackIntegration } from "./types";
|
||||
import { SlackEventData, SlackIntegrationServer } from "./types";
|
||||
|
||||
export class SlackEventManager {
|
||||
private client: SlackClient;
|
||||
@@ -36,7 +36,7 @@ export class SlackEventManager {
|
||||
|
||||
await this.sendSlackNotification(
|
||||
eventData,
|
||||
integration as unknown as SlackIntegration,
|
||||
integration as SlackIntegrationServer,
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("Error processing Slack event:", error);
|
||||
@@ -48,7 +48,7 @@ export class SlackEventManager {
|
||||
*/
|
||||
private async sendSlackNotification(
|
||||
eventData: SlackEventData,
|
||||
integration: SlackIntegration,
|
||||
integration: SlackIntegrationServer,
|
||||
): Promise<void> {
|
||||
try {
|
||||
const channels = await this.getNotificationChannels(
|
||||
@@ -105,7 +105,7 @@ export class SlackEventManager {
|
||||
|
||||
private async getNotificationChannels(
|
||||
eventData: SlackEventData,
|
||||
integration: SlackIntegration,
|
||||
integration: SlackIntegrationServer,
|
||||
): Promise<any[]> {
|
||||
const enabledChannels = integration.configuration?.enabledChannels || {};
|
||||
return Object.values(enabledChannels)
|
||||
|
||||
@@ -35,6 +35,14 @@ export type SlackIntegration = Omit<
|
||||
configuration: SlackConfiguration | null;
|
||||
};
|
||||
|
||||
export type SlackIntegrationServer = Omit<
|
||||
InstalledIntegration,
|
||||
"credentials" | "configuration"
|
||||
> & {
|
||||
credentials: SlackCredential;
|
||||
configuration: SlackConfiguration | null;
|
||||
};
|
||||
|
||||
export interface SlackMessage {
|
||||
channel?: string;
|
||||
text?: string;
|
||||
|
||||
Reference in New Issue
Block a user