({
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>;
})
| 10 | import { Logger } from '@linen/types'; |
| 11 | |
| 12 | export 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, |
nothing calls this directly
no test coverage detected