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

Function getChannelsSettingsServerSideProps

apps/web/services/ssr/channels.ts:205–247  ·  view source on GitHub ↗
(
  context: GetServerSidePropsContext,
  isSubDomainRouting: boolean
)

Source from the content-addressed store, hash-verified

203}
204
205export async function getChannelsSettingsServerSideProps(
206 context: GetServerSidePropsContext,
207 isSubDomainRouting: boolean
208) {
209 const { props, notFound, ...rest } = await ssr(context, allowManagers);
210
211 if (rest.redirect) {
212 return RedirectTo(rest.location);
213 }
214
215 if (notFound || !props) {
216 return NotFound();
217 }
218
219 const channels = await prisma.channels.findMany({
220 where: {
221 accountId: props.currentCommunity.id,
222 type: {
223 in: [ChannelType.PUBLIC, ChannelType.PRIVATE],
224 },
225 },
226 include: {
227 _count: { select: { threads: true, memberships: true } },
228 },
229 });
230
231 const counts = channels.map((channel) => {
232 return {
233 channelId: channel.id,
234 threadsCount: channel._count.threads,
235 usersCount: channel._count.memberships,
236 };
237 });
238
239 return {
240 props: {
241 ...props,
242 channels: channels.map(serializeChannel).sort(sortByDisplayOrder),
243 isSubDomainRouting,
244 counts,
245 },
246 };
247}

Callers 1

getServerSidePropsFunction · 0.90

Calls 4

ssrFunction · 0.90
RedirectToFunction · 0.90
NotFoundFunction · 0.90
mapMethod · 0.80

Tested by

no test coverage detected