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

Function syncWrapper

apps/web/services/slack/syncWrapper.ts:11–91  ·  view source on GitHub ↗
({
  account,
  domain,
  accountId,
  channelId,
  fullSync,
  fetchTeamInfo,
  joinChannel,
  getSlackChannels,
  listUsers,
  fetchConversationsTyped,
  fetchReplies,
  getMemberships,
  logger,
}: SyncWrapperTypes & { logger: Logger })

Source from the content-addressed store, hash-verified

9import { Logger } from '@linen/types';
10
11export 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,

Callers 2

slackSyncWithFilesFunction · 0.90
slackSyncFunction · 0.90

Calls 8

fetchTokenFunction · 0.90
syncChannelsFunction · 0.90
syncUsersFunction · 0.90
syncMembershipsFunction · 0.90
fetchAllTopLevelMessagesFunction · 0.90
saveAllThreadsFunction · 0.90
hideEmptyChannelsFunction · 0.90
logMethod · 0.65

Tested by

no test coverage detected