kopia lustrzana https://github.com/cloudflare/wildebeest
add CORS for 404 subscription
rodzic
b9927c3dfe
commit
bd279cafff
|
|
@ -39,17 +39,21 @@ export function internalServerError(): Response {
|
|||
}
|
||||
|
||||
export function statusNotFound(id: string): Response {
|
||||
return generateErrorResponse('Resource not found', 404, `Status "${id}" not found`)
|
||||
return resourceNotFound('status', id)
|
||||
}
|
||||
|
||||
export function mediaNotFound(id: string): Response {
|
||||
return generateErrorResponse('Resource not found', 404, `Media "${id}" not found`)
|
||||
return resourceNotFound('media', id)
|
||||
}
|
||||
|
||||
export function tagNotFound(tag: string): Response {
|
||||
return generateErrorResponse('Resource not found', 404, `Tag "${tag}" not found`)
|
||||
return resourceNotFound('tag', tag)
|
||||
}
|
||||
|
||||
export function exceededLimit(detail: string): Response {
|
||||
return generateErrorResponse('Limit exceeded', 400, detail)
|
||||
}
|
||||
|
||||
export function resourceNotFound(name: string, id: string): Response {
|
||||
return generateErrorResponse('Resource not found', 404, `${name} "${id}" not found`)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { createSubscription } from '../../src/mastodon/subscription'
|
||||
import { createPerson } from 'wildebeest/backend/src/activitypub/actors'
|
||||
import { strict as assert } from 'node:assert/strict'
|
||||
import { makeDB, createTestClient, generateVAPIDKeys } from '../utils'
|
||||
import { makeDB, createTestClient, generateVAPIDKeys, assertCORS } from '../utils'
|
||||
import * as subscription from 'wildebeest/functions/api/v1/push/subscription'
|
||||
|
||||
const userKEK = 'test_kek21'
|
||||
|
|
@ -18,6 +18,7 @@ describe('Mastodon APIs', () => {
|
|||
|
||||
const res = await subscription.handleGetRequest(db, req, connectedActor, client.id, vapidKeys)
|
||||
assert.equal(res.status, 404)
|
||||
assertCORS(res)
|
||||
})
|
||||
|
||||
test('get existing subscription', async () => {
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ export async function handleGetRequest(
|
|||
const subscription = await getSubscription(db, connectedActor, client)
|
||||
|
||||
if (subscription === null) {
|
||||
return new Response('', { status: 404 })
|
||||
return errors.resourceNotFound('subscription', clientId)
|
||||
}
|
||||
|
||||
const vapidKey = VAPIDPublicKey(vapidKeys)
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue