Stub out some changes to the digest response

This commit is contained in:
Jackson Harper 2024-04-16 13:31:55 +08:00 committed by Hongbo Wu
parent 2b53d7791a
commit d2ea93a7dd

View file

@ -1,4 +1,5 @@
import { redisDataSource } from '../redis_data_source'
import { SpeechFile } from '@omnivore/text-to-speech-handler'
export const CREATE_DIGEST_JOB = 'create-digest'
@ -17,6 +18,8 @@ export interface Digest {
chapters?: Chapter[]
urlsToAudio?: string[]
jobState: string
speechFile: SpeechFile
}
interface Chapter {
@ -26,6 +29,40 @@ interface Chapter {
const digestKey = (userId: string) => `digest:${userId}`
export const getDigest = async (userId: string): Promise<Digest | null> => {
await redisDataSource.redisClient?.set(
digestKey(userId),
JSON.stringify({
id: 'BB3D5D89-70A2-4AE1-ADDC-713232B1281D',
title:
'SOTU response collapses, Trump hits new low, Biden fundraising explodes 3/11/24 TDPS Podcast',
content: 'content',
urlsToAudio: [],
jobState: 'completed',
speechFile: {
pageId: '1234',
wordCount: 2124,
language: 'en-US',
defaultVoice: 'en-US-ChristopherNeural',
utterances: [
{
idx: '',
text: 'TOP prospect JOINS Canucks - Team SPEAKS OUT on Demko Injury | Canucks News',
wordOffset: 0,
wordCount: 14,
voice: 'en-US-ChristopherNeural',
},
{
idx: '4',
text: 'Intro',
wordOffset: 14,
wordCount: 1,
voice: 'en-US-ChristopherNeural',
},
],
},
})
)
const digest = await redisDataSource.redisClient?.get(digestKey(userId))
return digest ? (JSON.parse(digest) as Digest) : null
}