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

Function fetchCommon

apps/web/services/ssr/common/index.ts:73–117  ·  view source on GitHub ↗
(
  permissions: Permissions,
  community: accounts,
  isBot: boolean = false
)

Source from the content-addressed store, hash-verified

71}
72
73export async function fetchCommon(
74 permissions: Permissions,
75 community: accounts,
76 isBot: boolean = false
77) {
78 const publicChannels = await ChannelsService.findPublic(community.id, isBot);
79
80 const joinedChannels = !!permissions.user?.id
81 ? await ChannelsService.findJoined({
82 accountId: community.id,
83 userId: permissions.user.id,
84 })
85 : publicChannels;
86
87 const privateChannels = !!permissions.user?.id
88 ? await ChannelsService.findPrivates({
89 accountId: community.id,
90 userId: permissions.user.id,
91 })
92 : [];
93
94 const settings = serializeSettings(community);
95 const communities = !!permissions.auth?.id
96 ? await CommunityService.findByAuthId(permissions.auth.id)
97 : [];
98
99 const currentCommunity = serializeAccount(community);
100
101 const dmChannels = !!permissions.user?.id
102 ? await getDMs({
103 accountId: currentCommunity.id,
104 userId: permissions.user.id,
105 })
106 : [];
107
108 return {
109 currentCommunity,
110 publicChannels: publicChannels.map(serializeChannel),
111 joinedChannels: joinedChannels.map(serializeChannel),
112 privateChannels: privateChannels.map(serializeChannel),
113 communities,
114 settings,
115 dmChannels: dmChannels.map(serializeChannel),
116 };
117}
118
119export function allowAccess(
120 permissions: Permissions

Callers 4

getPropsFunction · 0.90
threads.tsFile · 0.90
channels.tsFile · 0.90
ssrFunction · 0.85

Calls 8

serializeSettingsFunction · 0.90
serializeAccountFunction · 0.90
getDMsFunction · 0.90
findPublicMethod · 0.80
findJoinedMethod · 0.80
findPrivatesMethod · 0.80
findByAuthIdMethod · 0.80
mapMethod · 0.80

Tested by

no test coverage detected