fix(chat): sync paid voice audio unlock flow
This commit is contained in:
@@ -34,7 +34,6 @@ function makeResponse(
|
||||
): ChatSendResponse {
|
||||
return ChatSendResponse.from({
|
||||
reply: "",
|
||||
audioUrl: "",
|
||||
messageId: "msg-1",
|
||||
isGuest: false,
|
||||
timestamp: 1782356425363,
|
||||
@@ -92,6 +91,33 @@ describe("chat media cache helpers", () => {
|
||||
).toEqual([]);
|
||||
});
|
||||
|
||||
it("does not cache audio from a locked send response", () => {
|
||||
expect(
|
||||
getSendResponseMediaTargets(
|
||||
makeResponse({
|
||||
audioUrl: "https://example.com/locked.mp3",
|
||||
lockDetail: { locked: true, reason: "voice_message" },
|
||||
}),
|
||||
),
|
||||
).toEqual([]);
|
||||
});
|
||||
|
||||
it("caches audio from an unlocked send response", () => {
|
||||
expect(
|
||||
getSendResponseMediaTargets(
|
||||
makeResponse({
|
||||
audioUrl: "https://example.com/unlocked.mp3",
|
||||
}),
|
||||
),
|
||||
).toEqual([
|
||||
{
|
||||
messageId: "msg-1",
|
||||
kind: "audio",
|
||||
remoteUrl: "https://example.com/unlocked.mp3",
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("deduplicates media targets", () => {
|
||||
expect(
|
||||
uniqueMediaTargets([
|
||||
|
||||
@@ -42,11 +42,13 @@ export function getSendResponseMediaTargets(
|
||||
kind: "image",
|
||||
remoteUrl: response.image.url,
|
||||
});
|
||||
pushMediaTarget(targets, {
|
||||
messageId: response.messageId,
|
||||
kind: "audio",
|
||||
remoteUrl: response.audioUrl,
|
||||
});
|
||||
if (!response.lockDetail.locked) {
|
||||
pushMediaTarget(targets, {
|
||||
messageId: response.messageId,
|
||||
kind: "audio",
|
||||
remoteUrl: response.audioUrl,
|
||||
});
|
||||
}
|
||||
return targets;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user