({
channelIds,
limit = 3,
anonymize,
anonymizeUsers = false,
}: {
channelIds: string[];
limit?: number;
anonymize: AnonymizeType;
anonymizeUsers?: boolean;
})
| 461 | }; |
| 462 | |
| 463 | export 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 | |
| 510 | export const findThreadByIncrementId = async (incrementId: number) => { |
| 511 | return findThreadWithMessages({ incrementId }); |
no test coverage detected