feat(chat): render commercial actions and persist greetings
Docker Image / Build and Push Docker Image (push) Successful in 1m56s
Docker Image / Build and Push Docker Image (push) Successful in 1m56s
This commit is contained in:
@@ -12,6 +12,10 @@ import { getApiConfig } from "@/core/net/config/api_config";
|
||||
import { ExceptionHandler } from "@/core/errors";
|
||||
import { AppEnvUtil } from "@/utils/app-env";
|
||||
import { Logger } from "@/utils/logger";
|
||||
import {
|
||||
CommercialActionSchema,
|
||||
type CommercialAction,
|
||||
} from "@/data/schemas/chat";
|
||||
|
||||
const log = new Logger("ChatWebSocket");
|
||||
const RECONNECT_DELAY_MS = 3000;
|
||||
@@ -40,6 +44,7 @@ export class ChatWebSocket {
|
||||
onVoiceReady: ((index: number, audioUrl: string) => void) | null = null;
|
||||
onImage: ((url: string) => void) | null = null;
|
||||
onPaywallStatus: ((payload: PaywallStatusPayload) => void) | null = null;
|
||||
onCommercialAction: ((action: CommercialAction) => void) | null = null;
|
||||
onError: ((errorMessage: string) => void) | null = null;
|
||||
|
||||
constructor(
|
||||
@@ -140,6 +145,12 @@ export class ChatWebSocket {
|
||||
url?: string | null;
|
||||
};
|
||||
lockDetail?: Partial<PaywallStatusPayload>;
|
||||
actionId?: string;
|
||||
type?: string;
|
||||
copy?: string;
|
||||
ctaLabel?: string;
|
||||
target?: string;
|
||||
ruleId?: string;
|
||||
};
|
||||
};
|
||||
try {
|
||||
@@ -179,6 +190,11 @@ export class ChatWebSocket {
|
||||
});
|
||||
break;
|
||||
}
|
||||
case "commercial_action": {
|
||||
const action = CommercialActionSchema.safeParse(payload.data);
|
||||
if (action.success) this.onCommercialAction?.(action.data);
|
||||
break;
|
||||
}
|
||||
case "error":
|
||||
this.onError?.(payload.error ?? "Unknown error");
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user