MCPcopy
hub / github.com/Linen-dev/linen.dev / syncChannels

Function syncChannels

apps/web/services/slack/sync/syncChannels.ts:71–116  ·  view source on GitHub ↗
({
  account,
  token,
  accountId,
  channelId,
  getSlackChannels,
  joinChannel,
  shouldJoinChannel,
  fullSync,
  logger,
}: {
  account: AccountWithSlackAuthAndChannels;
  token: string;
  accountId: string;
  channelId?: string;
  getSlackChannels: GetSlackChannelsFnType;
  joinChannel: JoinChannelFnType;
  shouldJoinChannel: boolean;
  fullSync?: boolean;
  logger: Logger;
})

Source from the content-addressed store, hash-verified

69}
70
71export async function syncChannels({
72 account,
73 token,
74 accountId,
75 channelId,
76 getSlackChannels,
77 joinChannel,
78 shouldJoinChannel,
79 fullSync,
80 logger,
81}: {
82 account: AccountWithSlackAuthAndChannels;
83 token: string;
84 accountId: string;
85 channelId?: string;
86 getSlackChannels: GetSlackChannelsFnType;
87 joinChannel: JoinChannelFnType;
88 shouldJoinChannel: boolean;
89 fullSync?: boolean;
90 logger: Logger;
91}) {
92 let channels = await createChannels({
93 slackTeamId: account.slackTeamId as string,
94 token,
95 accountId,
96 getSlackChannels,
97 joinChannel,
98 hideChannels: account.newChannelsConfig === 'HIDDEN',
99 shouldJoinChannel,
100 logger,
101 });
102
103 // If channelId is part of parameter only sync the specific channel
104 if (!!channelId) {
105 const channel = channels.find((c) => c.id === channelId);
106 if (!!channel) {
107 channels = [channel];
108 }
109 }
110
111 if (fullSync) {
112 await ChannelsService.setCursorNull({ accountId: account.id });
113 }
114
115 return channels;
116}

Callers 2

syncWrapperFunction · 0.90

Calls 3

createChannelsFunction · 0.85
setCursorNullMethod · 0.80
findMethod · 0.45

Tested by

no test coverage detected