kopia lustrzana https://github.com/cloudflare/wildebeest
commit
346b0a19dc
|
@ -43,6 +43,10 @@ export async function deliverFollowers(
|
|||
queue: Queue<DeliverMessageBody>
|
||||
) {
|
||||
const followers = await getFollowers(db, from)
|
||||
if (followers.length === 0) {
|
||||
// No one is following the user so no updates to send. Sad.
|
||||
return
|
||||
}
|
||||
|
||||
const messages: Array<MessageSendRequest<DeliverMessageBody>> = await Promise.all(
|
||||
followers.map(async (id) => {
|
||||
|
|
|
@ -22,8 +22,18 @@ export async function readBody<T>(request: Request): Promise<T> {
|
|||
const out: any = {}
|
||||
|
||||
for (const [key, value] of form) {
|
||||
if (key.endsWith('[]')) {
|
||||
// The `key[]` notiation is used when sending an array of values.
|
||||
|
||||
const key2 = key.replace('[]', '')
|
||||
if (out[key2] === undefined) {
|
||||
out[key2] = []
|
||||
}
|
||||
out[key2].push(value)
|
||||
} else {
|
||||
out[key] = value
|
||||
}
|
||||
}
|
||||
return out as T
|
||||
}
|
||||
|
||||
|
|
|
@ -627,6 +627,33 @@ describe('Mastodon APIs', () => {
|
|||
|
||||
const res = await statuses.handleRequest(req, db, actor, userKEK, queue, kv_cache)
|
||||
assert.equal(res.status, 400)
|
||||
const data = await res.json<any>()
|
||||
assert(data.error.includes('Limit exceeded'))
|
||||
})
|
||||
|
||||
test('create new status sending multipart and too many image', async () => {
|
||||
const db = await makeDB()
|
||||
const queue = makeQueue()
|
||||
const actor = await createPerson(domain, db, userKEK, 'sven@cloudflare.com')
|
||||
|
||||
const body = new FormData()
|
||||
body.append('status', 'my status')
|
||||
body.append('visibility', 'public')
|
||||
body.append('media_ids[]', 'id')
|
||||
body.append('media_ids[]', 'id')
|
||||
body.append('media_ids[]', 'id')
|
||||
body.append('media_ids[]', 'id')
|
||||
body.append('media_ids[]', 'id')
|
||||
|
||||
const req = new Request('https://example.com', {
|
||||
method: 'POST',
|
||||
body,
|
||||
})
|
||||
|
||||
const res = await statuses.handleRequest(req, db, actor, userKEK, queue, kv_cache)
|
||||
assert.equal(res.status, 400)
|
||||
const data = await res.json<any>()
|
||||
assert(data.error.includes('Limit exceeded'))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Ładowanie…
Reference in New Issue