DB-backed workspace + LangGraph agent
This commit is contained in:
40
Frontend/server/api/communications.get.ts
Normal file
40
Frontend/server/api/communications.get.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { prisma } from "../utils/prisma";
|
||||
import { getAuthContext } from "../utils/auth";
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const auth = await getAuthContext(event);
|
||||
|
||||
const items = await prisma.contactMessage.findMany({
|
||||
where: { contact: { teamId: auth.teamId } },
|
||||
orderBy: { occurredAt: "asc" },
|
||||
take: 2000,
|
||||
include: {
|
||||
contact: { select: { id: true, name: true } },
|
||||
},
|
||||
});
|
||||
|
||||
return {
|
||||
items: items.map((m) => ({
|
||||
id: m.id,
|
||||
at: m.occurredAt.toISOString(),
|
||||
contactId: m.contactId,
|
||||
contact: m.contact.name,
|
||||
channel:
|
||||
m.channel === "TELEGRAM"
|
||||
? "Telegram"
|
||||
: m.channel === "WHATSAPP"
|
||||
? "WhatsApp"
|
||||
: m.channel === "INSTAGRAM"
|
||||
? "Instagram"
|
||||
: m.channel === "EMAIL"
|
||||
? "Email"
|
||||
: "Phone",
|
||||
kind: m.kind === "CALL" ? "call" : "message",
|
||||
direction: m.direction === "IN" ? "in" : "out",
|
||||
text: m.content,
|
||||
duration: m.durationSec ? new Date(m.durationSec * 1000).toISOString().slice(14, 19) : undefined,
|
||||
transcript: Array.isArray(m.transcriptJson) ? (m.transcriptJson as any) : undefined,
|
||||
})),
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user