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

Function slackSyncWithFiles

apps/web/services/slack/syncWithFiles.ts:12–114  ·  view source on GitHub ↗
({
  accountId,
  channelId,
  domain,
  fullSync,
  fileLocation,
  logger,
  getFileFromS3 = thisGetFileFromS3,
  extractIntoTemp = thisExtractIntoTemp,
}: {
  accountId: string;
  channelId?: string;
  domain?: string;
  fullSync?: boolean | undefined;
  fileLocation?: string;
  logger: Logger;
  getFileFromS3?(fileLocation: string): Promise<unknown>;
  extractIntoTemp?(file: any): Promise<string>;
})

Source from the content-addressed store, hash-verified

10import { Logger } from '@linen/types';
11
12export async function slackSyncWithFiles({
13 accountId,
14 channelId,
15 domain,
16 fullSync,
17 fileLocation,
18 logger,
19 getFileFromS3 = thisGetFileFromS3,
20 extractIntoTemp = thisExtractIntoTemp,
21}: {
22 accountId: string;
23 channelId?: string;
24 domain?: string;
25 fullSync?: boolean | undefined;
26 fileLocation?: string;
27 logger: Logger;
28 getFileFromS3?(fileLocation: string): Promise<unknown>;
29 extractIntoTemp?(file: any): Promise<string>;
30}) {
31 logger.log({ startAt: new Date(), fullSync });
32
33 if (!fileLocation) throw 'missing files location';
34
35 const account = await findAccountById(accountId);
36
37 if (!account) {
38 throw { status: 404, error: 'Account not found' };
39 }
40
41 logger.setPrefix(account.slackDomain || account.name || account.id);
42
43 const file = await getFileFromS3(fileLocation);
44 const tempFolder = await extractIntoTemp(file);
45
46 const {
47 fetchConversationsTyped,
48 fetchReplies,
49 fetchTeamInfo,
50 getSlackChannels,
51 joinChannel,
52 listUsers,
53 getMemberships,
54 } = new SlackFileAdapter(tempFolder);
55
56 await updateAndNotifySyncStatus({
57 accountId,
58 status: SyncStatus.IN_PROGRESS,
59 accountName: account.name,
60 homeUrl: account.homeUrl,
61 communityUrl: account.communityUrl,
62 pathDomain: account.slackDomain,
63 });
64
65 try {
66 await syncWrapper({
67 account,
68 domain,
69 accountId,

Callers

nothing calls this directly

Calls 6

findAccountByIdFunction · 0.90
syncWrapperFunction · 0.90
logMethod · 0.65
setPrefixMethod · 0.65
errorMethod · 0.65

Tested by

no test coverage detected