fix(chat): update unlock response contract

This commit is contained in:
2026-06-30 18:15:39 +08:00
parent bfc2c3cc1e
commit 5f94105bc6
7 changed files with 130 additions and 30 deletions
+7 -3
View File
@@ -10,6 +10,7 @@ import {
UnlockPrivateRequest,
UnlockPrivateResponse,
} from "@/data/dto/chat";
import type { ChatLockDetailData } from "@/data/schemas/chat";
import { AuthStorage } from "@/data/storage/auth";
import { UserStorage } from "@/data/storage/user/user_storage";
import { Logger, Result } from "@/utils";
@@ -69,7 +70,7 @@ export class ChatRepository implements IChatRepository {
return Result.wrap(() => this.api.getHistory(limit, offset));
}
/** 解锁私密消息。 */
/** 解锁单条历史付费 / 私密消息。 */
async unlockPrivateMessage(
messageId: string,
): Promise<Result<UnlockPrivateResponse>> {
@@ -83,10 +84,11 @@ export class ChatRepository implements IChatRepository {
return Result.wrap(() => this.api.unlockHistory());
}
/** 把本地缓存中的私密消息标记为已解锁。 */
/** 把本地缓存中的单条锁定消息标记为已解锁。 */
async markPrivateMessageUnlockedInLocal(
messageId: string,
content: string,
lockDetail?: ChatLockDetailData,
): Promise<Result<void>> {
return Result.wrap(async () => {
const localResult = await this.getLocalMessages();
@@ -101,12 +103,14 @@ export class ChatRepository implements IChatRepository {
return ChatMessage.from({
...message.toJson(),
content,
lockDetail: {
lockDetail: lockDetail ?? {
...message.lockDetail,
locked: false,
showContent: true,
showUpgrade: false,
reason: null,
hint: null,
detail: null,
},
});
});