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

Function findPinnedThreads

apps/web/services/threads/index.ts:463–508  ·  view source on GitHub ↗
({
  channelIds,
  limit = 3,
  anonymize,
  anonymizeUsers = false,
}: {
  channelIds: string[];
  limit?: number;
  anonymize: AnonymizeType;
  anonymizeUsers?: boolean;
})

Source from the content-addressed store, hash-verified

461};
462
463export async function findPinnedThreads({
464 channelIds,
465 limit = 3,
466 anonymize,
467 anonymizeUsers = false,
468}: {
469 channelIds: string[];
470 limit?: number;
471 anonymize: AnonymizeType;
472 anonymizeUsers?: boolean;
473}): Promise<ThreadsWithMessagesFull[]> {
474 if (!channelIds.length) {
475 return [];
476 }
477
478 const threads = await prisma.threads.findMany({
479 take: limit,
480 where: {
481 channelId: {
482 in: channelIds,
483 },
484 hidden: false,
485 pinned: true,
486 },
487 include: {
488 messages: {
489 include: {
490 author: true,
491 mentions: {
492 include: {
493 users: true,
494 },
495 },
496 reactions: true,
497 attachments: true,
498 },
499 orderBy: { sentAt: 'asc' },
500 },
501 },
502 });
503 return (
504 anonymizeUsers
505 ? threads.map((thread) => anonymizeMessages(thread, anonymize))
506 : threads
507 ) as ThreadsWithMessagesFull[];
508}
509
510export const findThreadByIncrementId = async (incrementId: number) => {
511 return findThreadWithMessages({ incrementId });

Callers 3

topicGetServerSidePropsFunction · 0.90
channels.tsFile · 0.90

Calls 2

anonymizeMessagesFunction · 0.90
mapMethod · 0.80

Tested by

no test coverage detected