From 19b7cdb245524f5c4d0a789e4b2013560a9bae70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Wed, 6 Sep 2023 11:00:34 -0400 Subject: [PATCH 1/4] fix: #11981, post immediately when canceling scheduling --- src/posts/edit.js | 2 +- src/topics/scheduled.js | 46 ++++++++++++++++++++++++----------------- 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/src/posts/edit.js b/src/posts/edit.js index c75f7f2379..fed05baa63 100644 --- a/src/posts/edit.js +++ b/src/posts/edit.js @@ -186,7 +186,7 @@ module.exports = function (Posts) { throw new Error('[[error:no-privileges]]'); } const isMain = parseInt(data.pid, 10) === parseInt(topicData.mainPid, 10); - if (isMain && (isNaN(data.timestamp) || data.timestamp < Date.now())) { + if (isMain && isNaN(data.timestamp)) { throw new Error('[[error:invalid-data]]'); } } diff --git a/src/topics/scheduled.js b/src/topics/scheduled.js index bd79e1b07c..52d70366dc 100644 --- a/src/topics/scheduled.js +++ b/src/topics/scheduled.js @@ -26,6 +26,11 @@ Scheduled.handleExpired = async function () { return; } + await postTids(tids); + await db.sortedSetsRemoveRangeByScore([`topics:scheduled`], '-inf', now); +}; + +async function postTids(tids) { let topicsData = await topics.getTopicsData(tids); // Filter deleted topicsData = topicsData.filter(topicData => Boolean(topicData)); @@ -43,9 +48,8 @@ Scheduled.handleExpired = async function () { updateUserLastposttimes(uids, topicsData), updateGroupPosts(uids, topicsData), ...topicsData.map(topicData => unpin(topicData.tid, topicData)), - db.sortedSetsRemoveRangeByScore([`topics:scheduled`], '-inf', now) )); -}; +} // topics/tools.js#pin/unpin would block non-admins/mods, thus the local versions Scheduled.pin = async function (tid, topicData) { @@ -62,23 +66,27 @@ Scheduled.pin = async function (tid, topicData) { }; Scheduled.reschedule = async function ({ cid, tid, timestamp, uid }) { - const mainPid = await topics.getTopicField(tid, 'mainPid'); - await Promise.all([ - db.sortedSetsAdd([ - 'topics:scheduled', - `uid:${uid}:topics`, - 'topics:tid', - `cid:${cid}:uid:${uid}:tids`, - ], timestamp, tid), - posts.setPostField(mainPid, 'timestamp', timestamp), - db.sortedSetsAdd([ - 'posts:pid', - `uid:${uid}:posts`, - `cid:${cid}:uid:${uid}:pids`, - ], timestamp, mainPid), - shiftPostTimes(tid, timestamp), - ]); - return topics.updateLastPostTimeFromLastPid(tid); + if (timestamp < Date.now()) { + await postTids([tid]); + } else { + const mainPid = await topics.getTopicField(tid, 'mainPid'); + await Promise.all([ + db.sortedSetsAdd([ + 'topics:scheduled', + `uid:${uid}:topics`, + 'topics:tid', + `cid:${cid}:uid:${uid}:tids`, + ], timestamp, tid), + posts.setPostField(mainPid, 'timestamp', timestamp), + db.sortedSetsAdd([ + 'posts:pid', + `uid:${uid}:posts`, + `cid:${cid}:uid:${uid}:pids`, + ], timestamp, mainPid), + shiftPostTimes(tid, timestamp), + ]); + await topics.updateLastPostTimeFromLastPid(tid); + } }; function unpin(tid, topicData) { From 8357bb2e0af22bf2b5e7f236540d444c3b29029c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Wed, 6 Sep 2023 11:33:53 -0400 Subject: [PATCH 2/4] chore: up dbsearch --- install/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/package.json b/install/package.json index 141a2dea79..8d712e4b65 100644 --- a/install/package.json +++ b/install/package.json @@ -94,7 +94,7 @@ "nconf": "0.12.0", "nodebb-plugin-2factor": "7.2.1", "nodebb-plugin-composer-default": "10.2.18", - "nodebb-plugin-dbsearch": "6.2.1", + "nodebb-plugin-dbsearch": "6.2.2", "nodebb-plugin-emoji": "5.1.5", "nodebb-plugin-emoji-android": "4.0.0", "nodebb-plugin-markdown": "12.2.3", From f9e93ba32ebc226d05f8a353d3da99972836632c Mon Sep 17 00:00:00 2001 From: Misty Release Bot Date: Wed, 6 Sep 2023 15:54:21 +0000 Subject: [PATCH 3/4] chore: incrementing version number - v3.4.1 --- install/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/package.json b/install/package.json index 8d712e4b65..83dc54d8dc 100644 --- a/install/package.json +++ b/install/package.json @@ -2,7 +2,7 @@ "name": "nodebb", "license": "GPL-3.0", "description": "NodeBB Forum", - "version": "3.4.0", + "version": "3.4.1", "homepage": "https://www.nodebb.org", "repository": { "type": "git", From f24a334c1d1805b7b6e066970f98283080ecd5ba Mon Sep 17 00:00:00 2001 From: Misty Release Bot Date: Wed, 6 Sep 2023 15:54:21 +0000 Subject: [PATCH 4/4] chore: update changelog for v3.4.1 --- CHANGELOG.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c7456e2ae..3ee1f3f3f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,38 @@ +#### v3.4.1 (2023-09-06) + +##### Chores + +* up dbsearch (8357bb2e) +* incrementing version number - v3.4.0 (fd9247c5) +* update changelog for v3.4.0 (5c023025) +* incrementing version number - v3.3.9 (5805e770) +* incrementing version number - v3.3.8 (a5603565) +* incrementing version number - v3.3.7 (b26f1744) +* incrementing version number - v3.3.6 (7fb38792) +* incrementing version number - v3.3.4 (a67f84ea) +* incrementing version number - v3.3.3 (f94d239b) +* incrementing version number - v3.3.2 (ec9dac97) +* incrementing version number - v3.3.1 (151cc68f) +* incrementing version number - v3.3.0 (fc1ad70f) +* incrementing version number - v3.2.3 (b06d3e63) +* incrementing version number - v3.2.2 (758ecfcd) +* incrementing version number - v3.2.1 (20145074) +* incrementing version number - v3.2.0 (9ecac38e) +* incrementing version number - v3.1.7 (0b4e81ab) +* incrementing version number - v3.1.6 (b3a3b130) +* incrementing version number - v3.1.5 (ec19343a) +* incrementing version number - v3.1.4 (2452783c) +* incrementing version number - v3.1.3 (3b4e9d3f) +* incrementing version number - v3.1.2 (40fa3489) +* incrementing version number - v3.1.1 (40250733) +* incrementing version number - v3.1.0 (0cb386bd) +* incrementing version number - v3.0.1 (26f6ea49) +* incrementing version number - v3.0.0 (224e08cd) + +##### Bug Fixes + +* #11981, post immediately when canceling scheduling (19b7cdb2) + #### v3.4.0 (2023-09-06) ##### Chores