Node.js based forum software built for the modern web
feat: handle Create(note)
Julian Lamf74775365a57
diff --git a/src/activitypub/inbox.js b/src/activitypub/inbox.jsindex 89c62192e2..97a535e668 100644--- a/src/activitypub/inbox.js+++ b/src/activitypub/inbox.js@@ -1,5 +1,7 @@'use strict';+const winston = require('winston');+const db = require('../database');const user = require('../user');const activitypub = require('.');@@ -8,6 +10,18 @@ const helpers = require('./helpers');const inbox = module.exports;+inbox.create = async (req) => {+ const { object } = req.body;+ const postData = await activitypub.mocks.post(object);++ if (postData) {+ await activitypub.notes.assert(1, [postData]);+ await activitypub.notes.assertTopic(1, postData.pid);+ } else {+ winston.warn('[activitypub/inbox] Received object was not a note');+ }+};+inbox.follow = async (req) => {// Sanity checksconst localUid = await helpers.resolveLocalUid(req.body.object);diff --git a/src/controllers/activitypub/index.js b/src/controllers/activitypub/index.jsindex 41721ac28d..98d58104d5 100644--- a/src/controllers/activitypub/index.js+++ b/src/controllers/activitypub/index.js@@ -105,6 +105,11 @@ Controller.getInbox = async (req, res) => {Controller.postInbox = async (req, res) => {// Note: underlying methods are internal use only, hence no exposure via src/apiswitch (req.body.type) {+ case 'Create': {+ await activitypub.inbox.create(req);+ break;+ }+case 'Follow': {await activitypub.inbox.follow(req);break;