test: #13255, reply to topic in remote category addresses remote category

This commit is contained in:
Julian Lam
2025-03-21 14:22:22 -04:00
parent b8c531d53d
commit 85e7c1a20d
2 changed files with 37 additions and 1 deletions

View File

@@ -123,7 +123,7 @@ topicsAPI.reply = async function (caller, data) {
}
socketHelpers.notifyNew(caller.uid, 'newPost', result);
activitypubApi.create.note(caller, { post: postData });
await activitypubApi.create.note(caller, { post: postData });
return postData;
};

View File

@@ -323,6 +323,42 @@ describe('Notes', () => {
assert(addressees.has(cid));
});
});
describe('replies', () => {
it('should federate out a Create activity with the remote community addressed', async () => {
const { tid } = await api.topics.create({ uid }, {
cid,
title: utils.generateUUID(),
content: utils.generateUUID(),
});
activitypub._sent.clear();
const postData = await api.topics.reply({ uid }, {
tid,
content: utils.generateUUID(),
});
assert(postData);
assert.strictEqual(activitypub._sent.size, 1);
const key = Array.from(activitypub._sent.keys())[0];
const activity = activitypub._sent.get(key);
assert(activity && activity.to);
assert.strictEqual(activity.type, 'Create');
const addressees = new Set([
...(activity.to || []),
...(activity.cc || []),
...(activity.bcc || []),
...(activity.object.to || []),
...(activity.object.cc || []),
...(activity.object.bcc || []),
]);
assert(addressees.has(cid));
});
});
});
});