mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
feat: 1b12 category announce on post move to a new tid, #13236
This commit is contained in:
@@ -321,6 +321,10 @@ postsAPI.move = async function (caller, data) {
|
|||||||
|
|
||||||
if (!postDeleted && !topicDeleted) {
|
if (!postDeleted && !topicDeleted) {
|
||||||
socketHelpers.sendNotificationToPostOwner(data.pid, caller.uid, 'move', 'notifications:moved-your-post');
|
socketHelpers.sendNotificationToPostOwner(data.pid, caller.uid, 'move', 'notifications:moved-your-post');
|
||||||
|
|
||||||
|
// ideally we should federate a "move" activity instead. tbd
|
||||||
|
const { activity } = await activitypub.mocks.activities.create(data.pid, caller.uid);
|
||||||
|
await activitypub.feps.announce(data.pid, activity);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -97,34 +97,37 @@ describe('FEPs', () => {
|
|||||||
assert.strictEqual(activity.object.id, `${nconf.get('url')}/post/${reply1Pid}`);
|
assert.strictEqual(activity.object.id, `${nconf.get('url')}/post/${reply1Pid}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
// it('should be called when a post is moved to another topic', async () => {
|
it('should be called when a post is moved to another topic', async () => {
|
||||||
//
|
const [{ topicData: topic1 }, { topicData: topic2 }] = await Promise.all([
|
||||||
// });
|
topics.post({
|
||||||
});
|
uid,
|
||||||
|
cid,
|
||||||
|
title: utils.generateUUID(),
|
||||||
|
content: utils.generateUUID(),
|
||||||
|
}),
|
||||||
|
topics.post({
|
||||||
|
uid,
|
||||||
|
cid,
|
||||||
|
title: utils.generateUUID(),
|
||||||
|
content: utils.generateUUID(),
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
|
||||||
describe('announceObject()', () => {
|
assert(topic1 && topic2);
|
||||||
let cid;
|
|
||||||
let uid;
|
|
||||||
let adminUid;
|
|
||||||
|
|
||||||
before(async () => {
|
// Create new reply and move it to topic 2
|
||||||
const name = utils.generateUUID();
|
const { pid } = await topics.reply({ uid, tid: topic1.tid, content: utils.generateUUID() });
|
||||||
const description = utils.generateUUID();
|
await api.posts.move({ uid: adminUid }, { pid, tid: topic2.tid });
|
||||||
({ cid } = await categories.create({ name, description }));
|
|
||||||
|
|
||||||
adminUid = await user.create({ username: utils.generateUUID() });
|
assert.strictEqual(activitypub._sent.size, 1);
|
||||||
await groups.join('administrators', adminUid);
|
const activities = Array.from(activitypub._sent.keys()).map(key => activitypub._sent.get(key));
|
||||||
uid = await user.create({ username: utils.generateUUID() });
|
|
||||||
|
|
||||||
const { id: followerId, actor } = helpers.mocks.actor();
|
const activity = activities.pop();
|
||||||
activitypub._cache.set(`0;${followerId}`, actor);
|
assert.strictEqual(activity.type, 'Announce');
|
||||||
user.setCategoryWatchState(followerId, [cid], categories.watchStates.tracking);
|
assert(activity.object && activity.object.type);
|
||||||
|
assert.strictEqual(activity.object.type, 'Create');
|
||||||
activitypub._sent.clear();
|
assert(activity.object.object && activity.object.object.type);
|
||||||
});
|
assert.strictEqual(activity.object.object.type, 'Note');
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
activitypub._sent.clear();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user