({
account,
domain,
accountId,
channelId,
fullSync,
fetchTeamInfo,
joinChannel,
getSlackChannels,
listUsers,
fetchConversationsTyped,
fetchReplies,
getMemberships,
logger,
}: SyncWrapperTypes & { logger: Logger })
| 9 | import { Logger } from '@linen/types'; |
| 10 | |
| 11 | export async function syncWrapper({ |
| 12 | account, |
| 13 | domain, |
| 14 | accountId, |
| 15 | channelId, |
| 16 | fullSync, |
| 17 | fetchTeamInfo, |
| 18 | joinChannel, |
| 19 | getSlackChannels, |
| 20 | listUsers, |
| 21 | fetchConversationsTyped, |
| 22 | fetchReplies, |
| 23 | getMemberships, |
| 24 | logger, |
| 25 | }: SyncWrapperTypes & { logger: Logger }) { |
| 26 | const { token, syncFrom, shouldJoinChannel } = await fetchToken({ |
| 27 | account, |
| 28 | domain, |
| 29 | accountId, |
| 30 | fetchTeamInfo, |
| 31 | }); |
| 32 | logger.log({ token, syncFrom, shouldJoinChannel }); |
| 33 | const oldest = syncFrom |
| 34 | ? Math.floor(syncFrom.getTime() / 1000).toString() |
| 35 | : '0'; |
| 36 | |
| 37 | // create and join channels |
| 38 | const channels = await syncChannels({ |
| 39 | account, |
| 40 | token, |
| 41 | accountId, |
| 42 | channelId, |
| 43 | joinChannel, |
| 44 | getSlackChannels, |
| 45 | shouldJoinChannel, |
| 46 | fullSync, |
| 47 | logger, |
| 48 | }); |
| 49 | |
| 50 | //paginate and find all the users |
| 51 | const usersInDb = await syncUsers({ |
| 52 | accountId, |
| 53 | token, |
| 54 | account, |
| 55 | fullSync, |
| 56 | listUsers, |
| 57 | logger, |
| 58 | }); |
| 59 | |
| 60 | for (const channel of channels) { |
| 61 | if (!channel.externalChannelId) { |
| 62 | continue; |
| 63 | } |
| 64 | |
| 65 | await syncMemberships({ |
| 66 | accountId, |
| 67 | channelId: channel.id, |
| 68 | externalChannelId: channel.externalChannelId, |
no test coverage detected