feat(chat): sync multi-role backend APIs
This commit is contained in:
@@ -5,6 +5,9 @@ import type {
|
||||
} from "@/data/repositories/interfaces";
|
||||
import {
|
||||
ChatHistoryResponse,
|
||||
ChatPreviewsResponse,
|
||||
ChatSyncRequest,
|
||||
ChatSyncRequestSchema,
|
||||
ChatSendResponse,
|
||||
SendMessageRequestSchema,
|
||||
UnlockHistoryRequestSchema,
|
||||
@@ -27,13 +30,43 @@ export class ChatRemoteDataSource {
|
||||
const request = SendMessageRequestSchema.parse({
|
||||
characterId,
|
||||
message,
|
||||
image: options?.image ?? "",
|
||||
...(options?.imageId ? { imageId: options.imageId } : {}),
|
||||
...(options?.imageThumbUrl
|
||||
? { imageThumbUrl: options.imageThumbUrl }
|
||||
: {}),
|
||||
...(options?.imageMediumUrl
|
||||
? { imageMediumUrl: options.imageMediumUrl }
|
||||
: {}),
|
||||
...(options?.imageOriginalUrl
|
||||
? { imageOriginalUrl: options.imageOriginalUrl }
|
||||
: {}),
|
||||
...(options?.imageWidth !== undefined
|
||||
? { imageWidth: options.imageWidth }
|
||||
: {}),
|
||||
...(options?.imageHeight !== undefined
|
||||
? { imageHeight: options.imageHeight }
|
||||
: {}),
|
||||
useWebSocket: options?.useWebSocket ?? false,
|
||||
});
|
||||
return await this.api.sendMessage(request, options);
|
||||
});
|
||||
}
|
||||
|
||||
async getPreviews(
|
||||
options?: ChatRequestOptions,
|
||||
): Promise<Result<ChatPreviewsResponse>> {
|
||||
return Result.wrap(() => this.api.getPreviews(options));
|
||||
}
|
||||
|
||||
async syncGuestHistory(
|
||||
request: ChatSyncRequest,
|
||||
options?: ChatRequestOptions,
|
||||
): Promise<Result<void>> {
|
||||
return Result.wrap(() =>
|
||||
this.api.syncGuestHistory(ChatSyncRequestSchema.parse(request), options),
|
||||
);
|
||||
}
|
||||
|
||||
async getHistory(
|
||||
characterId: string,
|
||||
limit = 50,
|
||||
|
||||
Reference in New Issue
Block a user