({
incrementId,
id,
}: {
incrementId?: number;
id?: string;
})
| 516 | }; |
| 517 | |
| 518 | const 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 | |
| 564 | export const updateSlackThread = async ( |
| 565 | id: string, |
no test coverage detected