diff --git a/public/language/en-GB/admin/manage/categories.json b/public/language/en-GB/admin/manage/categories.json index a5c0253dae..9965edf634 100644 --- a/public/language/en-GB/admin/manage/categories.json +++ b/public/language/en-GB/admin/manage/categories.json @@ -94,6 +94,7 @@ "federation.followers-handle": "Handle", "federation.followers-id": "ID", "federation.followers-none": "No followers.", + "federation.followers-autofill": "Autofill", "alert.created": "Created", "alert.create-success": "Category successfully created!", diff --git a/src/topics/fork.js b/src/topics/fork.js index da0875cb9c..b12c54ecc9 100644 --- a/src/topics/fork.js +++ b/src/topics/fork.js @@ -39,25 +39,29 @@ module.exports = function (Topics) { cid = await posts.getCidByPid(mainPid); } - const [postData, isAdminOrMod] = await Promise.all([ + const [mainPost, isAdminOrMod] = await Promise.all([ posts.getPostData(mainPid), privileges.categories.isAdminOrMod(cid, uid), ]); + let lastPost = mainPost; + if (pids.length > 1) { + lastPost = await posts.getPostData(pids[pids.length - 1]); + } if (!isAdminOrMod) { throw new Error('[[error:no-privileges]]'); } - - const scheduled = postData.timestamp > Date.now(); + const now = Date.now(); + const scheduled = mainPost.timestamp > now; const params = { - uid: postData.uid, + uid: mainPost.uid, title: title, cid: cid, - timestamp: scheduled && postData.timestamp, + timestamp: mainPost.timestamp, }; const result = await plugins.hooks.fire('filter:topic.fork', { params: params, - tid: postData.tid, + tid: mainPost.tid, }); const tid = await Topics.create(result.params); @@ -72,22 +76,22 @@ module.exports = function (Topics) { await Topics.movePostToTopic(uid, pid, tid, scheduled); } - await Topics.updateLastPostTime(tid, scheduled ? (postData.timestamp + 1) : Date.now()); + await Topics.updateLastPostTime(tid, scheduled ? (mainPost.timestamp + 1) : lastPost.timestamp); await Promise.all([ Topics.setTopicFields(tid, { - upvotes: postData.upvotes, - downvotes: postData.downvotes, + upvotes: mainPost.upvotes, + downvotes: mainPost.downvotes, forkedFromTid: fromTid, forkerUid: uid, - forkTimestamp: Date.now(), + forkTimestamp: now, }), - db.sortedSetsAdd(['topics:votes', `cid:${cid}:tids:votes`], postData.votes, tid), + db.sortedSetsAdd(['topics:votes', `cid:${cid}:tids:votes`], mainPost.votes, tid), Topics.events.log(fromTid, { type: 'fork', uid, href: `/topic/${tid}` }), activitypub.feps.announceObject(pids[0]), ]); - plugins.hooks.fire('action:topic.fork', { tid: tid, fromTid: fromTid, uid: uid }); + plugins.hooks.fire('action:topic.fork', { tid, fromTid, uid }); return await Topics.getTopicData(tid); }; diff --git a/src/views/admin/manage/category-federation.tpl b/src/views/admin/manage/category-federation.tpl index 9d8f1d632f..1f2652b68b 100644 --- a/src/views/admin/manage/category-federation.tpl +++ b/src/views/admin/manage/category-federation.tpl @@ -14,85 +14,85 @@ [[admin/manage/categories:federation.disabled-cta]] {{{ else }}} -