mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
feat: ability to load remote post data in a topic
This commit is contained in:
@@ -8,6 +8,7 @@ const _ = require('lodash');
|
||||
|
||||
const meta = require('../meta');
|
||||
const plugins = require('../plugins');
|
||||
const activitypub = require('../activitypub');
|
||||
const translator = require('../translator');
|
||||
const utils = require('../utils');
|
||||
|
||||
@@ -51,7 +52,7 @@ module.exports = function (Posts) {
|
||||
if (!postData) {
|
||||
return postData;
|
||||
}
|
||||
postData.content = String(postData.content || '');
|
||||
postData.content = String(postData.sourceContent || postData.content || '');
|
||||
const cache = require('./cache');
|
||||
const pid = String(postData.pid);
|
||||
const cachedContent = cache.get(pid);
|
||||
@@ -60,12 +61,14 @@ module.exports = function (Posts) {
|
||||
return postData;
|
||||
}
|
||||
|
||||
const data = await plugins.hooks.fire('filter:parse.post', { postData: postData });
|
||||
data.postData.content = translator.escape(data.postData.content);
|
||||
if (data.postData.pid) {
|
||||
cache.set(pid, data.postData.content);
|
||||
if (!activitypub.helpers.isUri(postData.pid) || postData.hasOwnProperty('sourceContent')) {
|
||||
({ postData } = await plugins.hooks.fire('filter:parse.post', { postData }));
|
||||
}
|
||||
return data.postData;
|
||||
postData.content = translator.escape(postData.content);
|
||||
if (postData.pid) {
|
||||
cache.set(pid, postData.content);
|
||||
}
|
||||
return postData;
|
||||
};
|
||||
|
||||
Posts.parseSignature = async function (userData, uid) {
|
||||
|
||||
Reference in New Issue
Block a user