feat(payment): add chat support discounts and gratitude
Docker Image / Build and Push Docker Image (push) Successful in 3m1s
Docker Image / Build and Push Docker Image (push) Successful in 3m1s
(cherry picked from commit ef9b79bc83)
This commit is contained in:
@@ -37,6 +37,13 @@ export interface PaywallStatusPayload {
|
||||
reason: string | null;
|
||||
}
|
||||
|
||||
export interface CommercialMessagePayload {
|
||||
messageId: string;
|
||||
message: string;
|
||||
characterId: string;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export class ChatWebSocket {
|
||||
private ws: WebSocket | null = null;
|
||||
private reconnectTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
@@ -52,6 +59,7 @@ export class ChatWebSocket {
|
||||
onCommercialAction: ((action: CommercialAction) => void) | null = null;
|
||||
onChatAction: ((action: ChatAction) => void) | null = null;
|
||||
onPaymentGuidance: ((guidance: PaymentGuidance) => void) | null = null;
|
||||
onCommercialMessage: ((message: CommercialMessagePayload) => void) | null = null;
|
||||
onError: ((errorMessage: string) => void) | null = null;
|
||||
|
||||
constructor(
|
||||
@@ -149,6 +157,10 @@ export class ChatWebSocket {
|
||||
done?: boolean;
|
||||
audioUrl?: string;
|
||||
error?: string;
|
||||
messageId?: string;
|
||||
message?: string;
|
||||
characterId?: string;
|
||||
createdAt?: string;
|
||||
data?: Record<string, unknown> & {
|
||||
image?: {
|
||||
type?: string | null;
|
||||
@@ -163,6 +175,10 @@ export class ChatWebSocket {
|
||||
ruleId?: string;
|
||||
kind?: string;
|
||||
orderId?: string | null;
|
||||
messageId?: string;
|
||||
message?: string;
|
||||
characterId?: string;
|
||||
createdAt?: string;
|
||||
};
|
||||
};
|
||||
try {
|
||||
@@ -217,6 +233,25 @@ export class ChatWebSocket {
|
||||
if (guidance.success) this.onPaymentGuidance?.(guidance.data);
|
||||
break;
|
||||
}
|
||||
case "commercial_message": {
|
||||
const commercialMessage = payload.data?.messageId
|
||||
? payload.data
|
||||
: payload;
|
||||
if (
|
||||
commercialMessage?.messageId &&
|
||||
commercialMessage.message &&
|
||||
commercialMessage.characterId &&
|
||||
commercialMessage.createdAt
|
||||
) {
|
||||
this.onCommercialMessage?.({
|
||||
messageId: commercialMessage.messageId,
|
||||
message: commercialMessage.message,
|
||||
characterId: commercialMessage.characterId,
|
||||
createdAt: commercialMessage.createdAt,
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "error":
|
||||
this.onError?.(payload.error ?? "Unknown error");
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user