refactor(chat): simplify paid message lock state
This commit is contained in:
@@ -5,21 +5,15 @@ import { z } from "zod";
|
||||
|
||||
import {
|
||||
booleanOrFalse,
|
||||
booleanOrTrue,
|
||||
schemaOr,
|
||||
stringOrNull,
|
||||
unknownRecordOrNull,
|
||||
} from "../nullable-defaults";
|
||||
|
||||
const CHAT_IMAGE_DEFAULTS = { type: null, url: null } as const;
|
||||
|
||||
const CHAT_LOCK_DETAIL_DEFAULTS = {
|
||||
locked: false,
|
||||
showContent: true,
|
||||
showUpgrade: false,
|
||||
reason: null,
|
||||
hint: null,
|
||||
detail: null,
|
||||
} as const;
|
||||
|
||||
export const ChatImageSchema = schemaOr(
|
||||
@@ -33,11 +27,7 @@ export const ChatImageSchema = schemaOr(
|
||||
export const ChatLockDetailSchema = schemaOr(
|
||||
z.object({
|
||||
locked: booleanOrFalse,
|
||||
showContent: booleanOrTrue,
|
||||
showUpgrade: booleanOrFalse,
|
||||
reason: stringOrNull,
|
||||
hint: stringOrNull,
|
||||
detail: unknownRecordOrNull,
|
||||
}),
|
||||
CHAT_LOCK_DETAIL_DEFAULTS,
|
||||
);
|
||||
|
||||
@@ -9,7 +9,6 @@ import {
|
||||
numberOrLazy,
|
||||
numberOrZero,
|
||||
stringOrEmpty,
|
||||
stringOrNull,
|
||||
} from "../nullable-defaults";
|
||||
import { ChatImageSchema, ChatLockDetailSchema } from "./chat_payloads";
|
||||
|
||||
@@ -23,7 +22,6 @@ export const ChatSendResponseSchema = z.object({
|
||||
image: ChatImageSchema,
|
||||
lockDetail: ChatLockDetailSchema,
|
||||
canSendMessage: booleanOrTrue,
|
||||
cannotSendReason: stringOrNull,
|
||||
creditBalance: numberOrZero,
|
||||
creditsCharged: numberOrZero,
|
||||
requiredCredits: numberOrZero,
|
||||
|
||||
Reference in New Issue
Block a user