kopia lustrzana https://github.com/cloudflare/wildebeest
lint ./consumer
rodzic
aa97690dec
commit
64743520f7
|
@ -1,16 +1,10 @@
|
|||
import type { MessageBody, DeliverMessageBody } from 'wildebeest/backend/src/types/queue'
|
||||
import type { DeliverMessageBody } from 'wildebeest/backend/src/types/queue'
|
||||
import { getSigningKey } from 'wildebeest/backend/src/mastodon/account'
|
||||
import * as actors from 'wildebeest/backend/src/activitypub/actors'
|
||||
import type { Actor } from 'wildebeest/backend/src/activitypub/actors'
|
||||
import type { Env } from './'
|
||||
import { generateDigestHeader } from 'wildebeest/backend/src/utils/http-signing-cavage'
|
||||
import { signRequest } from 'wildebeest/backend/src/utils/http-signing'
|
||||
import { deliverToActor } from 'wildebeest/backend/src/activitypub/deliver'
|
||||
|
||||
const headers = {
|
||||
'content-type': 'application/activity+json',
|
||||
}
|
||||
|
||||
export async function handleDeliverMessage(env: Env, actor: Actor, message: DeliverMessageBody) {
|
||||
const toActorId = new URL(message.toActorId)
|
||||
const targetActor = await actors.getAndCache(toActorId, env.DATABASE)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import type { MessageBody, InboxMessageBody } from 'wildebeest/backend/src/types/queue'
|
||||
import type { InboxMessageBody } from 'wildebeest/backend/src/types/queue'
|
||||
import * as activityHandler from 'wildebeest/backend/src/activitypub/activities/handle'
|
||||
import * as notification from 'wildebeest/backend/src/mastodon/notification'
|
||||
import * as timeline from 'wildebeest/backend/src/mastodon/timeline'
|
||||
|
|
|
@ -16,7 +16,7 @@ describe('Consumer', () => {
|
|||
|
||||
let receivedActivity: any = null
|
||||
|
||||
globalThis.fetch = async (input: any) => {
|
||||
globalThis.fetch = async (input: RequestInfo | Request) => {
|
||||
if (input.toString() === 'https://example.com/users/a') {
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
|
@ -28,10 +28,13 @@ describe('Consumer', () => {
|
|||
)
|
||||
}
|
||||
|
||||
// Make TypeScript happy
|
||||
input = input as Request
|
||||
|
||||
if (input.url.toString() === 'https://example.com/inbox') {
|
||||
assert(input.headers.get('accept').includes('json'))
|
||||
assert(input.headers.get('user-agent').includes('Wildebeest'))
|
||||
assert(input.headers.get('user-agent').includes(domain))
|
||||
assert(input.headers.get('accept')!.includes('json'))
|
||||
assert(input.headers.get('user-agent')!.includes('Wildebeest'))
|
||||
assert(input.headers.get('user-agent')!.includes(domain))
|
||||
assert.equal(input.method, 'POST')
|
||||
receivedActivity = await input.json()
|
||||
return new Response('')
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
"lint:frontend": "npm --prefix frontend run lint",
|
||||
"lint:backend": "npx eslint backend",
|
||||
"lint:functions": "npx eslint functions",
|
||||
"lint:consumer": "npx eslint consumer",
|
||||
"build": "yarn --cwd frontend install && yarn --cwd frontend build",
|
||||
"d1": "NO_D1_WARNING=true wrangler d1",
|
||||
"pages": "NO_D1_WARNING=true wrangler pages",
|
||||
|
|
Ładowanie…
Reference in New Issue