Skip to content

Node.js based forum software built for the modern web

fix: add in a deduplication guard after calling contexts.getItems

Julian Lamb3600e0b7f2e
diff --git a/src/activitypub/notes.js b/src/activitypub/notes.js
index 73d864db6e..3ca30b7aa5 100644
--- a/src/activitypub/notes.js
+++ b/src/activitypub/notes.js
@@ -84,6 +84,14 @@ Notes.assert = async (uid, input, options = { skipChecks: false }) => {
} else if (context.context) {
chain = Array.from(await activitypub.contexts.getItems(uid, context.context, { input }));
if (chain && chain.length) {
+ // Deduplicate by id (just in case, also a buggy NodeBB impl. sent dupes)
+ const ids = new Set();
+ chain = chain.filter((item) => {
+ const seen = ids.has(item.pid);
+ ids.add(item.pid);
+ return !seen;
+ });
+
// Context resolves, use in later topic creation
context = context.context;
}