feat(chat): add contact inbox sources with per-user hide filters
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user