mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
feat: save remote post url into hash for use
This commit is contained in:
@@ -85,6 +85,7 @@ Mocks.post = async (objects) => {
|
|||||||
|
|
||||||
let {
|
let {
|
||||||
id: pid,
|
id: pid,
|
||||||
|
url,
|
||||||
attributedTo: uid,
|
attributedTo: uid,
|
||||||
inReplyTo: toPid,
|
inReplyTo: toPid,
|
||||||
published, updated, name, content, sourceContent,
|
published, updated, name, content, sourceContent,
|
||||||
@@ -112,7 +113,7 @@ Mocks.post = async (objects) => {
|
|||||||
|
|
||||||
edited,
|
edited,
|
||||||
editor: edited ? uid : undefined,
|
editor: edited ? uid : undefined,
|
||||||
_activitypub: { to, cc, attachment, tag },
|
_activitypub: { to, cc, attachment, tag, url },
|
||||||
};
|
};
|
||||||
|
|
||||||
return payload;
|
return payload;
|
||||||
|
|||||||
@@ -44,6 +44,9 @@ module.exports = function (Posts) {
|
|||||||
if (data.handle && !parseInt(uid, 10)) {
|
if (data.handle && !parseInt(uid, 10)) {
|
||||||
postData.handle = data.handle;
|
postData.handle = data.handle;
|
||||||
}
|
}
|
||||||
|
if (_activitypub.url) {
|
||||||
|
postData.url = _activitypub.url;
|
||||||
|
}
|
||||||
|
|
||||||
({ post: postData } = await plugins.hooks.fire('filter:post.create', { post: postData, data: data }));
|
({ post: postData } = await plugins.hooks.fire('filter:post.create', { post: postData, data: data }));
|
||||||
await db.setObject(`post:${postData.pid}`, postData);
|
await db.setObject(`post:${postData.pid}`, postData);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
const validator = require('validator');
|
const validator = require('validator');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
const nconf = require('nconf');
|
||||||
|
|
||||||
const topics = require('../topics');
|
const topics = require('../topics');
|
||||||
const user = require('../user');
|
const user = require('../user');
|
||||||
@@ -20,7 +21,7 @@ module.exports = function (Posts) {
|
|||||||
options.parse = options.hasOwnProperty('parse') ? options.parse : true;
|
options.parse = options.hasOwnProperty('parse') ? options.parse : true;
|
||||||
options.extraFields = options.hasOwnProperty('extraFields') ? options.extraFields : [];
|
options.extraFields = options.hasOwnProperty('extraFields') ? options.extraFields : [];
|
||||||
|
|
||||||
const fields = ['pid', 'tid', 'toPid', 'content', 'uid', 'timestamp', 'deleted', 'upvotes', 'downvotes', 'replies', 'handle'].concat(options.extraFields);
|
const fields = ['pid', 'tid', 'toPid', 'url', 'content', 'uid', 'timestamp', 'deleted', 'upvotes', 'downvotes', 'replies', 'handle'].concat(options.extraFields);
|
||||||
|
|
||||||
let posts = await Posts.getPostsFields(pids, fields);
|
let posts = await Posts.getPostsFields(pids, fields);
|
||||||
posts = posts.filter(Boolean);
|
posts = posts.filter(Boolean);
|
||||||
@@ -56,6 +57,11 @@ module.exports = function (Posts) {
|
|||||||
post.isMainPost = post.topic && post.pid === post.topic.mainPid;
|
post.isMainPost = post.topic && post.pid === post.topic.mainPid;
|
||||||
post.deleted = post.deleted === 1;
|
post.deleted = post.deleted === 1;
|
||||||
post.timestampISO = utils.toISOString(post.timestamp);
|
post.timestampISO = utils.toISOString(post.timestamp);
|
||||||
|
|
||||||
|
// url only applies to remote posts; assume permalink otherwise
|
||||||
|
if (utils.isNumber(post.pid)) {
|
||||||
|
post.url = `${nconf.get('url')}/post/${post.pid}`;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
posts = posts.filter(post => tidToTopic[post.tid]);
|
posts = posts.filter(post => tidToTopic[post.tid]);
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ module.exports = function (SocketPosts) {
|
|||||||
}
|
}
|
||||||
const cid = await posts.getCidByPid(data.pid);
|
const cid = await posts.getCidByPid(data.pid);
|
||||||
const results = await utils.promiseParallel({
|
const results = await utils.promiseParallel({
|
||||||
posts: posts.getPostFields(data.pid, ['deleted', 'bookmarks', 'uid', 'ip', 'flagId']),
|
posts: posts.getPostFields(data.pid, ['deleted', 'bookmarks', 'uid', 'ip', 'flagId', 'url']),
|
||||||
isAdmin: user.isAdministrator(socket.uid),
|
isAdmin: user.isAdministrator(socket.uid),
|
||||||
isGlobalMod: user.isGlobalModerator(socket.uid),
|
isGlobalMod: user.isGlobalModerator(socket.uid),
|
||||||
isModerator: user.isModerator(socket.uid, cid),
|
isModerator: user.isModerator(socket.uid, cid),
|
||||||
|
|||||||
Reference in New Issue
Block a user