forked from mattkenney/wildebeest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinbox.ts
26 lines (23 loc) · 1.16 KB
/
inbox.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import type { InboxMessageBody } from 'wildebeest/backend/src/types/queue'
import { getDatabase } from 'wildebeest/backend/src/database'
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'
import { cacheFromEnv } from 'wildebeest/backend/src/cache'
import type { Actor } from 'wildebeest/backend/src/activitypub/actors'
import type { Env } from './'
export async function handleInboxMessage(env: Env, actor: Actor, message: InboxMessageBody) {
const domain = env.DOMAIN
const db = await getDatabase(env)
const adminEmail = env.ADMIN_EMAIL
const cache = cacheFromEnv(env)
const activity = message.activity
console.log(JSON.stringify(activity))
await activityHandler.handle(domain, activity, db, message.userKEK, adminEmail, message.vapidKeys)
// Assuming we received new posts or a like, pregenerate the user's timelines
// and notifications.
await Promise.all([
timeline.pregenerateTimelines(domain, db, cache, actor),
notification.pregenerateNotifications(db, cache, actor, domain),
])
}