mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-27 09:06:15 +01:00
fix: more duplicate detection in to/cc
This commit is contained in:
@@ -208,8 +208,8 @@ Mocks.note = async (post) => {
|
|||||||
const raw = await posts.getPostField(post.pid, 'content');
|
const raw = await posts.getPostField(post.pid, 'content');
|
||||||
|
|
||||||
// todo: post visibility
|
// todo: post visibility
|
||||||
const to = [activitypub._constants.publicAddress];
|
const to = new Set([activitypub._constants.publicAddress]);
|
||||||
const cc = [`${nconf.get('url')}/uid/${post.user.uid}/followers`];
|
const cc = new Set([`${nconf.get('url')}/uid/${post.user.uid}/followers`]);
|
||||||
|
|
||||||
let inReplyTo = null;
|
let inReplyTo = null;
|
||||||
let name = null;
|
let name = null;
|
||||||
@@ -217,10 +217,10 @@ Mocks.note = async (post) => {
|
|||||||
if (post.toPid) { // direct reply
|
if (post.toPid) { // direct reply
|
||||||
inReplyTo = utils.isNumber(post.toPid) ? `${nconf.get('url')}/post/${post.toPid}` : post.toPid;
|
inReplyTo = utils.isNumber(post.toPid) ? `${nconf.get('url')}/post/${post.toPid}` : post.toPid;
|
||||||
const parentId = await posts.getPostField(post.toPid, 'uid');
|
const parentId = await posts.getPostField(post.toPid, 'uid');
|
||||||
to.unshift(utils.isNumber(parentId) ? `${nconf.get('url')}/uid/${parentId}` : parentId);
|
to.add(utils.isNumber(parentId) ? `${nconf.get('url')}/uid/${parentId}` : parentId);
|
||||||
} else if (!post.isMainPost) { // reply to OP
|
} else if (!post.isMainPost) { // reply to OP
|
||||||
inReplyTo = utils.isNumber(post.topic.mainPid) ? `${nconf.get('url')}/post/${post.topic.mainPid}` : post.topic.mainPid;
|
inReplyTo = utils.isNumber(post.topic.mainPid) ? `${nconf.get('url')}/post/${post.topic.mainPid}` : post.topic.mainPid;
|
||||||
to.unshift(utils.isNumber(post.topic.uid) ? `${nconf.get('url')}/uid/${post.topic.uid}` : post.topic.uid);
|
to.add(utils.isNumber(post.topic.uid) ? `${nconf.get('url')}/uid/${post.topic.uid}` : post.topic.uid);
|
||||||
} else { // new topic
|
} else { // new topic
|
||||||
name = await topics.getTitleByPid(post.pid);
|
name = await topics.getTitleByPid(post.pid);
|
||||||
tag = post.topic.tags.map(tag => ({
|
tag = post.topic.tags.map(tag => ({
|
||||||
@@ -251,13 +251,15 @@ Mocks.note = async (post) => {
|
|||||||
};
|
};
|
||||||
}));
|
}));
|
||||||
|
|
||||||
to.push(...Array.from(matches).reduce((ids, { id }) => {
|
Array.from(matches)
|
||||||
if (!utils.isNumber(id)) {
|
.reduce((ids, { id }) => {
|
||||||
|
if (!utils.isNumber(id) && !to.has(id) && !cc.has(id)) {
|
||||||
ids.push(id);
|
ids.push(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ids;
|
return ids;
|
||||||
}, []));
|
}, [])
|
||||||
|
.forEach(id => cc.add(id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,8 +267,8 @@ Mocks.note = async (post) => {
|
|||||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||||
id,
|
id,
|
||||||
type: 'Note',
|
type: 'Note',
|
||||||
to,
|
to: Array.from(to),
|
||||||
cc,
|
cc: Array.from(cc),
|
||||||
inReplyTo,
|
inReplyTo,
|
||||||
published,
|
published,
|
||||||
url: id,
|
url: id,
|
||||||
|
|||||||
Reference in New Issue
Block a user