Files
Codex d6f6bc2d87
Docker Image / Build and Push Docker Image (push) Successful in 2m15s
test(chat): enforce locked image URL masking
2026-07-27 15:44:17 +08:00

110 lines
4.5 KiB
TypeScript

export const emptyChatHistoryResponse = {
messages: [],
total: 0,
limit: 50,
offset: 0,
isVip: false,
privateFreeLimit: 0,
privateUsedToday: 0,
privateCanViewFree: false,
};
export const emptyChatPreviewsResponse = { items: [] };
export const chatSendResponse = {
reply: "Hello from the E2E boyfriend.",
audioUrl: "",
messageId: "msg_e2e_reply_001",
isGuest: true,
timestamp: 1_782_356_425_363,
image: { type: null, url: null },
lockDetail: {
locked: false,
showContent: true,
showUpgrade: false,
reason: null,
hint: null,
detail: null,
},
};
export function createChatSendResponse(sendCount: number) {
return {
...chatSendResponse,
reply: `Hello from the E2E boyfriend. Reply ${sendCount}.`,
messageId: `msg_e2e_reply_${String(sendCount).padStart(3, "0")}`,
timestamp: chatSendResponse.timestamp + sendCount,
};
}
export function createWeeklyLimitChatSendResponse(
usedMessageCount: number,
limit: number,
) {
return {
reply: "",
audioUrl: "",
messageId: "",
isGuest: true,
canSendMessage: false,
cannotSendReason: "insufficient_credits",
creditBalance: 0,
creditsCharged: 0,
requiredCredits: limit,
shortfallCredits: Math.max(0, limit - usedMessageCount),
timestamp: chatSendResponse.timestamp + usedMessageCount,
image: { type: null, url: null },
lockDetail: {
locked: true,
showContent: false,
showUpgrade: true,
reason: "weekly_limit",
hint: "Free message limit reached.",
detail: { type: "weekly_msg_limit", usedThisWeek: usedMessageCount, limit },
},
};
}
export const paidImageMessageId = "msg_photo_paywall_001";
export const paidImageDisplayMessageId = `server:${paidImageMessageId}:assistant`;
export const paidImageUrl =
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+/p9sAAAAASUVORK5CYII=";
export const paidImageChatSendResponse = {
reply: "I can show you that photo after you activate VIP.",
audioUrl: "",
messageId: paidImageMessageId,
isGuest: true,
timestamp: 1_782_180_725_000,
image: { type: "elio_schedule", url: null },
lockDetail: { locked: true, showContent: true, showUpgrade: true, reason: "image", hint: "Activate VIP to unlock the full photo.", detail: null },
};
export function createPaidImageHistoryResponse(unlocked: boolean) {
return {
messages: [{ role: "assistant", type: "image", content: unlocked ? "" : paidImageChatSendResponse.reply, id: paidImageMessageId, created_at: "2026-06-30T00:00:00.000Z", audioUrl: null, image: { type: "elio_schedule", url: unlocked ? paidImageUrl : null }, lockDetail: unlocked ? { locked: false, showContent: true, showUpgrade: false, reason: null, hint: null, detail: null } : paidImageChatSendResponse.lockDetail }],
total: 1, limit: 50, offset: 0, isVip: unlocked, privateFreeLimit: 0, privateUsedToday: 0, privateCanViewFree: false,
};
}
export const paidImageUnlockHistoryResponse = {
unlocked: true, reason: "ok", totalLocked: 1, unlockedCount: 1, privateCount: 0, imageCount: 1, voiceCount: 0,
requiredCredits: 0, currentCredits: 0, remainingCredits: 0, shortfallCredits: 0,
costsByMessage: { [paidImageMessageId]: 0 }, messageIds: [paidImageMessageId],
};
export const paidVoiceMessageId = "msg_voice_paywall_001";
export const paidVoiceAudioUrl = "data:audio/mpeg;base64,//uQZAAAAAAAAAAAAAAAAAAAAAAAWGluZwAAAA8AAAACAAACcQCA";
export const paidVoiceHistoryResponse = {
messages: [{ role: "assistant", type: "voice", content: "", id: paidVoiceMessageId, created_at: "2026-07-01T00:00:00.000Z", audioUrl: paidVoiceAudioUrl, image: { type: null, url: null }, lockDetail: { locked: true, showContent: true, showUpgrade: true, reason: "voice_message", hint: "Unlock this voice message with credits.", detail: null } }],
total: 1, limit: 50, offset: 0, isVip: false, privateFreeLimit: 0, privateUsedToday: 0, privateCanViewFree: false,
};
export const insufficientCreditsUnlockVoiceResponse = {
unlocked: false, content: "", reason: "insufficient_balance", creditBalance: 3, creditsCharged: 0, requiredCredits: 20, shortfallCredits: 17,
lockDetail: paidVoiceHistoryResponse.messages[0].lockDetail,
};
export const insufficientCreditsUnlockImageResponse = {
unlocked: false, content: "", reason: "insufficient_balance", creditBalance: 3, creditsCharged: 0, requiredCredits: 30, shortfallCredits: 27,
lockDetail: { locked: true, showContent: true, showUpgrade: true, reason: "image", hint: "Unlock this high-definition image with credits.", detail: null },
};