feat(chat): add contact inbox sources with per-user hide filters

This commit is contained in:
Ruslan Bakiev
2026-02-23 10:41:02 +07:00
parent 6bc154a1e6
commit 95fd9a64ce
11 changed files with 538 additions and 29 deletions

View File

@@ -27,6 +27,23 @@ export async function exportDatasetFromPrisma() {
export async function exportDatasetFromPrismaFor(input: { teamId: string; userId: string }) {
const root = datasetRoot(input);
const tmp = root + ".tmp";
const hiddenRows = await prisma.contactInboxPreference.findMany({
where: {
teamId: input.teamId,
userId: input.userId,
isHidden: true,
},
select: { contactInboxId: true },
});
const hiddenInboxIds = hiddenRows.map((row) => row.contactInboxId);
const messageWhere = hiddenInboxIds.length
? {
OR: [
{ contactInboxId: null },
{ contactInboxId: { notIn: hiddenInboxIds } },
],
}
: undefined;
await fs.rm(tmp, { recursive: true, force: true });
await ensureDir(tmp);
@@ -50,6 +67,7 @@ export async function exportDatasetFromPrismaFor(input: { teamId: string; userId
include: {
note: { select: { content: true, updatedAt: true } },
messages: {
where: messageWhere,
select: {
kind: true,
direction: true,