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

Function fetchToken

apps/web/services/slack/sync/fetchToken.ts:4–28  ·  view source on GitHub ↗
({
  account,
  domain,
  accountId,
  fetchTeamInfo,
}: {
  account: AccountWithSlackAuthAndChannels;
  domain?: string;
  accountId: string;
  fetchTeamInfo: Function;
})

Source from the content-addressed store, hash-verified

2import { AccountWithSlackAuthAndChannels } from '@linen/types';
3
4export async function fetchToken({
5 account,
6 domain,
7 accountId,
8 fetchTeamInfo,
9}: {
10 account: AccountWithSlackAuthAndChannels;
11 domain?: string;
12 accountId: string;
13 fetchTeamInfo: Function;
14}) {
15 const slackAuth = account.slackAuthorizations?.shift();
16
17 const token = slackAuth?.accessToken || '';
18 const syncFrom = slackAuth?.syncFrom || new Date(0);
19 const shouldJoinChannel = slackAuth?.joinChannel !== false;
20
21 const teamInfoResponse = await fetchTeamInfo(token);
22 const communityUrl = teamInfoResponse?.body?.team?.url;
23
24 if (!!domain && !!communityUrl) {
25 await updateAccountRedirectDomain(accountId, domain, communityUrl);
26 }
27 return { token, syncFrom, shouldJoinChannel };
28}

Callers 2

syncWrapperFunction · 0.90
fetchToken.test.tsFile · 0.90

Calls 2

fetchTeamInfoFunction · 0.50

Tested by

no test coverage detected