mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-05 07:10:30 +01:00
feat: handle Create(note)
This commit is contained in:
@@ -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 checks
|
||||
const localUid = await helpers.resolveLocalUid(req.body.object);
|
||||
|
||||
@@ -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/api
|
||||
switch (req.body.type) {
|
||||
case 'Create': {
|
||||
await activitypub.inbox.create(req);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'Follow': {
|
||||
await activitypub.inbox.follow(req);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user