MCPcopy Index your code
hub / github.com/Linen-dev/linen.dev / slackChatSync

Function slackChatSync

apps/web/services/slack/api/postMessage.ts:86–182  ·  view source on GitHub ↗
({
  channel,
  threadId,
  messageId,
  isThread,
  isReply,
  logger,
}: {
  channel:
    | channels & {
        channelsIntegration: channelsIntegration[];
        account:
          | (accounts & {
              slackAuthorizations: slackAuthorizations[];
              discordAuthorizations: discordAuthorizations[];
            })
          | null;
      };
  threadId?: string;
  messageId: string;
  isThread?: boolean;
  isReply?: boolean;
  logger: Logger;
})

Source from the content-addressed store, hash-verified

84}
85
86export async function slackChatSync({
87 channel,
88 threadId,
89 messageId,
90 isThread,
91 isReply,
92 logger,
93}: {
94 channel:
95 | channels & {
96 channelsIntegration: channelsIntegration[];
97 account:
98 | (accounts & {
99 slackAuthorizations: slackAuthorizations[];
100 discordAuthorizations: discordAuthorizations[];
101 })
102 | null;
103 };
104 threadId?: string;
105 messageId: string;
106 isThread?: boolean;
107 isReply?: boolean;
108 logger: Logger;
109}) {
110 logger.log({ threadId, messageId });
111 // check if has enough permissions
112 const slackToken = channel.account?.slackAuthorizations.find((s) =>
113 isAllowToSendMessages(s)
114 );
115 if (!slackToken?.accessToken) {
116 return 'missing scope on slack token';
117 }
118
119 const message = await prisma.messages.findUnique({
120 where: { id: messageId },
121 include: {
122 author: true,
123 threads: true,
124 attachments: true,
125 mentions: {
126 include: {
127 users: true,
128 },
129 },
130 },
131 });
132 if (!message) {
133 return 'message not found';
134 }
135 if (!message.threads) {
136 return 'thread is missing from message';
137 }
138 if (!!message.externalMessageId) {
139 return 'message has externalId already';
140 }
141
142 const token = slackToken.accessToken;
143 const externalChannelId = channel.externalChannelId!;

Callers 1

twoWaySyncJobFunction · 0.90

Calls 8

isAllowToSendMessagesFunction · 0.85
isAllowToCustomizeAuthorFunction · 0.85
newThreadFunction · 0.85
newReplyFunction · 0.85
mapMethod · 0.80
logMethod · 0.65
findMethod · 0.45

Tested by

no test coverage detected