diff --git a/consumer/src/deliver.ts b/consumer/src/deliver.ts index 6e825cb..3f1dcd2 100644 --- a/consumer/src/deliver.ts +++ b/consumer/src/deliver.ts @@ -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) diff --git a/consumer/src/inbox.ts b/consumer/src/inbox.ts index 09203eb..9c3ff81 100644 --- a/consumer/src/inbox.ts +++ b/consumer/src/inbox.ts @@ -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' diff --git a/consumer/test/consumer.spec.ts b/consumer/test/consumer.spec.ts index 999d4cc..41bf7a2 100644 --- a/consumer/test/consumer.spec.ts +++ b/consumer/test/consumer.spec.ts @@ -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('') diff --git a/package.json b/package.json index 3f6ca14..2a5719f 100644 --- a/package.json +++ b/package.json @@ -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",