kopia lustrzana https://github.com/cloudflare/wildebeest
handle empty timeline
rodzic
e4337540ab
commit
92c2b063ff
|
@ -29,10 +29,6 @@ export function userConflict(): Response {
|
|||
return generateErrorResponse(`User already exists or conflicts`, 403)
|
||||
}
|
||||
|
||||
export function timelineMissing(): Response {
|
||||
return generateErrorResponse(`The timeline is invalid or being regenerated`, 404)
|
||||
}
|
||||
|
||||
export function clientUnknown(): Response {
|
||||
return generateErrorResponse(`The client is unknown or invalid`, 403)
|
||||
}
|
||||
|
|
|
@ -83,6 +83,21 @@ describe('Mastodon APIs', () => {
|
|||
assert.equal(await data.text(), 'cached data')
|
||||
})
|
||||
|
||||
test('home returns empty if not in cache', async () => {
|
||||
const db = await makeDB()
|
||||
const connectedActor = await createPerson(domain, db, userKEK, 'sven@cloudflare.com')
|
||||
const kv_cache: any = {
|
||||
async get() {
|
||||
return null
|
||||
},
|
||||
}
|
||||
const req = new Request('https://' + domain)
|
||||
const data = await timelines_home.handleRequest(req, kv_cache, connectedActor)
|
||||
const posts = await data.json<Array<any>>()
|
||||
|
||||
assert.equal(posts.length, 0)
|
||||
})
|
||||
|
||||
test('public returns Notes', async () => {
|
||||
const db = await makeDB()
|
||||
const actor = await createPerson(domain, db, userKEK, 'sven@cloudflare.com')
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import type { Env } from 'wildebeest/backend/src/types/env'
|
||||
import type { ContextData } from 'wildebeest/backend/src/types/context'
|
||||
import type { Actor } from 'wildebeest/backend/src/activitypub/actors/'
|
||||
import * as errors from 'wildebeest/backend/src/errors'
|
||||
|
||||
const headers = {
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
|
@ -24,7 +23,7 @@ export async function handleRequest(request: Request, cache: KVNamespace, actor:
|
|||
|
||||
const timeline = await cache.get(actor.id + '/timeline/home')
|
||||
if (timeline === null) {
|
||||
return errors.timelineMissing()
|
||||
return new Response(JSON.stringify([]), { headers })
|
||||
}
|
||||
return new Response(timeline, { headers })
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue