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

Function findThreadWithMessages

apps/web/services/threads/index.ts:518–562  ·  view source on GitHub ↗
({
  incrementId,
  id,
}: {
  incrementId?: number;
  id?: string;
})

Source from the content-addressed store, hash-verified

516};
517
518const findThreadWithMessages = async ({
519 incrementId,
520 id,
521}: {
522 incrementId?: number;
523 id?: string;
524}) => {
525 const MESSAGES_ORDER_BY = 'asc';
526 return await prisma.threads
527 .findUnique({
528 where: { incrementId, id },
529 include: {
530 messages: {
531 include: {
532 author: true,
533 //Don't like how it includes mentions when I just want users
534 // waiting on this to flatten it out
535 // https://github.com/prisma/prisma/issues/9719
536 mentions: {
537 include: {
538 users: true,
539 },
540 },
541 reactions: true,
542 attachments: true,
543 },
544 orderBy: {
545 sentAt: MESSAGES_ORDER_BY,
546 },
547 },
548 channel: {
549 include: {
550 account: { select: { anonymize: true, anonymizeUsers: true } },
551 },
552 },
553 },
554 })
555 .then((thread) => {
556 const account = thread?.channel.account;
557 if (thread && account?.anonymizeUsers) {
558 return anonymizeMessages(thread, account.anonymize as AnonymizeType);
559 }
560 return thread;
561 });
562};
563
564export const updateSlackThread = async (
565 id: string,

Callers 2

findThreadByIncrementIdFunction · 0.85
findThreadByIdFunction · 0.85

Calls 1

anonymizeMessagesFunction · 0.90

Tested by

no test coverage detected