fix(tickets): normalise createdBy manquant sur les payloads legacy
Les tickets legacy sans champ createdBy faisaient noircir la fenêtre tickets côté frontend. Les adapters (ticket.ts, streamGateways.ts) normalisent désormais ce champ absent, avec couverture de test dédiée. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@ -286,6 +286,16 @@ export class HttpTicketGateway implements TicketGateway {
|
||||
private readonly ws: WsLiveClient,
|
||||
) {}
|
||||
|
||||
private normalizeTicketActor(actor: unknown): Ticket["createdBy"] {
|
||||
if (!actor || typeof actor !== "object") return { kind: "user" };
|
||||
const rec = actor as Record<string, unknown>;
|
||||
if (rec.kind === "user" || rec.kind === "system") return { kind: rec.kind };
|
||||
if (rec.kind === "agent" && typeof rec.agentId === "string" && rec.agentId) {
|
||||
return { kind: "agent", agentId: rec.agentId };
|
||||
}
|
||||
return { kind: "user" };
|
||||
}
|
||||
|
||||
private normalizeTicket(ticket: Ticket): Ticket {
|
||||
return {
|
||||
...ticket,
|
||||
@ -294,6 +304,8 @@ export class HttpTicketGateway implements TicketGateway {
|
||||
? ticket.assignedAgentIds
|
||||
: [],
|
||||
attachments: Array.isArray(ticket.attachments) ? ticket.attachments : [],
|
||||
createdBy: this.normalizeTicketActor(ticket.createdBy),
|
||||
updatedBy: this.normalizeTicketActor(ticket.updatedBy),
|
||||
};
|
||||
}
|
||||
|
||||
@ -306,6 +318,7 @@ export class HttpTicketGateway implements TicketGateway {
|
||||
assignedAgentIds: Array.isArray(item.assignedAgentIds)
|
||||
? item.assignedAgentIds
|
||||
: [],
|
||||
createdBy: this.normalizeTicketActor(item.createdBy),
|
||||
}))
|
||||
: [],
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user