refactor ai naming and make omni raw-json first
This commit is contained in:
@@ -325,6 +325,24 @@ async function ingestInbound(env: OmniInboundEnvelopeV1) {
|
||||
businessConnectionId,
|
||||
title: asString(n.chatTitle),
|
||||
});
|
||||
const rawEnvelope = {
|
||||
version: env.version,
|
||||
source: "omni_chat.receiver",
|
||||
provider: env.provider,
|
||||
channel: env.channel,
|
||||
direction,
|
||||
providerEventId: env.providerEventId,
|
||||
receivedAt: env.receivedAt,
|
||||
occurredAt: occurredAt.toISOString(),
|
||||
normalized: {
|
||||
text,
|
||||
threadExternalId: externalChatId,
|
||||
contactExternalId,
|
||||
businessConnectionId,
|
||||
},
|
||||
payloadNormalized: n,
|
||||
payloadRaw: (env.payloadRaw ?? null) as Prisma.InputJsonValue,
|
||||
} as Prisma.InputJsonValue;
|
||||
|
||||
if (env.providerMessageId) {
|
||||
await prisma.omniMessage.upsert({
|
||||
@@ -344,13 +362,13 @@ async function ingestInbound(env: OmniInboundEnvelopeV1) {
|
||||
text,
|
||||
providerMessageId: env.providerMessageId,
|
||||
providerUpdateId: String((n.updateId as string | null | undefined) ?? env.providerEventId),
|
||||
rawJson: (env.payloadRaw ?? null) as Prisma.InputJsonValue,
|
||||
rawJson: rawEnvelope,
|
||||
occurredAt,
|
||||
},
|
||||
update: {
|
||||
text,
|
||||
providerUpdateId: String((n.updateId as string | null | undefined) ?? env.providerEventId),
|
||||
rawJson: (env.payloadRaw ?? null) as Prisma.InputJsonValue,
|
||||
rawJson: rawEnvelope,
|
||||
occurredAt,
|
||||
},
|
||||
});
|
||||
@@ -366,7 +384,7 @@ async function ingestInbound(env: OmniInboundEnvelopeV1) {
|
||||
text,
|
||||
providerMessageId: null,
|
||||
providerUpdateId: String((n.updateId as string | null | undefined) ?? env.providerEventId),
|
||||
rawJson: (env.payloadRaw ?? null) as Prisma.InputJsonValue,
|
||||
rawJson: rawEnvelope,
|
||||
occurredAt,
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user