unoffical wafrn mirror
wafrn.net
atproto
social-network
activitypub
1import { Job } from 'bullmq'
2import { PostHostView, RemoteUserPostView } from '../../models/index.js'
3
4async function processRemotePostView(job: Job) {
5 // we move this to a queue to avoid doing the job as soon as we recive it
6 const serverView = job.data.federatedHostId
7 const userView = job.data.userId
8 const postId = job.data.postId
9 if (userView) {
10 await RemoteUserPostView.findOrCreate({
11 where: {
12 userId: userView,
13 postId: postId
14 }
15
16 })
17 }
18 if (serverView) {
19 await PostHostView.findOrCreate({
20 where: {
21 federatedHostId: serverView,
22 postId: postId
23 }
24 })
25 }
26}
27
28export { processRemotePostView }