From 4246de8ab73fb134b515577151a920de243c4467 Mon Sep 17 00:00:00 2001 From: Misty Release Bot Date: Tue, 12 Sep 2023 13:38:33 +0000 Subject: [PATCH 1/8] chore: incrementing version number - v3.4.2 --- install/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install/package.json b/install/package.json index 67e579e57f..4e5423142d 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.1", + "version": "3.4.2", "homepage": "https://www.nodebb.org", "repository": { "type": "git", @@ -194,4 +194,4 @@ "url": "https://github.com/barisusakli" } ] -} +} \ No newline at end of file From f9323de6e78bab2ca2a7a7f43448e3910a436e12 Mon Sep 17 00:00:00 2001 From: Misty Release Bot Date: Tue, 12 Sep 2023 13:38:34 +0000 Subject: [PATCH 2/8] chore: update changelog for v3.4.2 --- CHANGELOG.md | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ee1f3f3f7..82097ed85b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,60 @@ +#### v3.4.2 (2023-09-12) + +##### Chores + +* up harmony (bd94f263) +* up harmony (46f260b5) +* up harmony (62afd0bd) +* up composer/persona (5c628c56) +* up harmony (3e07c18d) +* up deps (3f7de1c7) +* up harmony (512c44d5) +* up harmony (319d3b1f) +* up themes (d7a7c355) +* incrementing version number - v3.4.1 (01e69574) +* update changelog for v3.4.1 (f24a334c) +* incrementing version number - v3.4.0 (fd9247c5) +* 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 + +* **deps:** bump 2factor (6bc2b6c5) +* move database call used to associate a NodeBB session UUID to its express session id into user.auth.addSession, which is the only time it is called (e1bced8c) +* toMid to posts you cant see (53106c00) +* closes #11982, fix element in prepEdit (e4ecb96f) +* prep edit so textarea isn't below text input (f2c4041f) + +##### Refactors + +* reduce socket.emits for typing (aebd9278) + +##### Tests + +* remove errant .only() (9dc9d5ef) +* fix room count (66251166) + #### v3.4.1 (2023-09-06) ##### Chores From 7ca37bd6c3b6c39cb40c34b5e9ac1824580e6281 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Fri, 15 Sep 2023 09:35:51 -0400 Subject: [PATCH 3/8] fix: #12009, check if suggested/current versions are valid --- src/cli/upgrade-plugins.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli/upgrade-plugins.js b/src/cli/upgrade-plugins.js index e789993388..2c76a6c5b1 100644 --- a/src/cli/upgrade-plugins.js +++ b/src/cli/upgrade-plugins.js @@ -106,7 +106,7 @@ async function checkPlugins() { current = plugins[suggestObj.package]; suggested = suggestObj.version; - if (suggestObj.code === 'match-found' && semver.gt(suggested, current)) { + if (suggestObj.code === 'match-found' && semver.valid(current) && semver.valid(suggested) && semver.gt(suggested, current)) { return { name: suggestObj.package, current: current, From c805824f438827815393d7c9d16a9175c1b8ec4d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 20 Sep 2023 18:28:38 -0400 Subject: [PATCH 4/8] fix(deps): update dependency nodebb-plugin-2factor to v7.3.0 (#12021) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- install/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install/package.json b/install/package.json index 4e5423142d..bb792382bf 100644 --- a/install/package.json +++ b/install/package.json @@ -92,7 +92,7 @@ "mousetrap": "1.6.5", "multiparty": "4.2.3", "nconf": "0.12.0", - "nodebb-plugin-2factor": "7.2.2", + "nodebb-plugin-2factor": "7.3.0", "nodebb-plugin-composer-default": "10.2.20", "nodebb-plugin-dbsearch": "6.2.2", "nodebb-plugin-emoji": "5.1.5", @@ -194,4 +194,4 @@ "url": "https://github.com/barisusakli" } ] -} \ No newline at end of file +} From aff19a6c6b6c678362c5de81f9524377f6cdb711 Mon Sep 17 00:00:00 2001 From: pkuanvil-uid1 <119569118+pkuanvil-uid1@users.noreply.github.com> Date: Mon, 25 Sep 2023 22:48:31 +0800 Subject: [PATCH 5/8] fix: properly wrap promise to callback-style function (#12030) Async function xhr use a mixture of await and callback, which is not correct when an exception is thrown before callback happens. Use only async/await for it and create a new callback-style wrapper. --- public/src/modules/api.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/public/src/modules/api.js b/public/src/modules/api.js index db8e0fb1b0..77e52148ca 100644 --- a/public/src/modules/api.js +++ b/public/src/modules/api.js @@ -27,16 +27,14 @@ function call(options, callback) { } }); } - return reject(err); } - resolve(data); }); }); } -async function xhr(options, cb) { +async function xhr_async(options) { // Normalize body based on type const { url } = options; delete options.url; @@ -79,16 +77,20 @@ async function xhr(options, cb) { if (!res.ok) { if (response) { - return cb(new Error(isJSON ? response.status.message : response)); + throw new Error(isJSON ? response.status.message : response); } - return cb(new Error(res.statusText)); + throw new Error(res.statusText); } - cb(null, ( - isJSON && response && response.hasOwnProperty('status') && response.hasOwnProperty('response') ? - response.response : - response - )); + return isJSON && response && response.hasOwnProperty('status') && response.hasOwnProperty('response') ? + response.response : + response; +} + +function xhr(options, callback) { + // then().catch() is not correct here because callback() is called twice when the first then() throws an exception. + // pass onfulfilled and onrejected here, as two parameters of Promise.prototype.then() + xhr_async(options).then(result => callback(null, result), error => callback(error)); } export function get(route, data, onSuccess) { From 379ed0e2e81f17678c2ebcc6bc7a7a7a00fbb812 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Mon, 25 Sep 2023 10:49:14 -0400 Subject: [PATCH 6/8] refactor: remove nested promise --- public/src/modules/api.js | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/public/src/modules/api.js b/public/src/modules/api.js index 77e52148ca..f510586549 100644 --- a/public/src/modules/api.js +++ b/public/src/modules/api.js @@ -7,34 +7,32 @@ import { confirm } from 'bootbox'; const baseUrl = config.relative_path + '/api/v3'; -function call(options, callback) { +async function call(options, callback) { options.url = options.url.startsWith('/api') ? config.relative_path + options.url : baseUrl + options.url; if (typeof callback === 'function') { - xhr(options, callback); + xhr(options).then(result => callback(null, result), err => callback(err)); return; } - return new Promise((resolve, reject) => { - xhr(options, function (err, data) { - if (err) { - if (err.message === 'A valid login session was not found. Please log in and try again.') { - return confirm('[[error:api.reauth-required]]', (ok) => { - if (ok) { - ajaxify.go('login'); - } - }); + try { + const result = await xhr(options); + return result; + } catch (err) { + if (err.message === 'A valid login session was not found. Please log in and try again.') { + return confirm('[[error:api.reauth-required]]', (ok) => { + if (ok) { + ajaxify.go('login'); } - return reject(err); - } - resolve(data); - }); - }); + }); + } + throw err; + } } -async function xhr_async(options) { +async function xhr(options) { // Normalize body based on type const { url } = options; delete options.url; @@ -87,12 +85,6 @@ async function xhr_async(options) { response; } -function xhr(options, callback) { - // then().catch() is not correct here because callback() is called twice when the first then() throws an exception. - // pass onfulfilled and onrejected here, as two parameters of Promise.prototype.then() - xhr_async(options).then(result => callback(null, result), error => callback(error)); -} - export function get(route, data, onSuccess) { return call({ url: route + (data && Object.keys(data).length ? ('?' + $.param(data)) : ''), From 77d6d0abfcc75b1ed627012f57038805692b9515 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Mon, 25 Sep 2023 20:34:10 -0400 Subject: [PATCH 7/8] fix: #12035, filter tids in mark all read --- src/topics/unread.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/topics/unread.js b/src/topics/unread.js index 63563525d5..c1666f7d91 100644 --- a/src/topics/unread.js +++ b/src/topics/unread.js @@ -317,7 +317,8 @@ module.exports = function (Topics) { Topics.markAllRead = async function (uid) { const cutoff = await Topics.unreadCutoff(uid); - const tids = await db.getSortedSetRevRangeByScore('topics:recent', 0, -1, '+inf', cutoff); + let tids = await db.getSortedSetRevRangeByScore('topics:recent', 0, -1, '+inf', cutoff); + tids = await privileges.topics.filterTids('read', tids, uid); Topics.markTopicNotificationsRead(tids, uid); await Topics.markAsRead(tids, uid); await db.delete(`uid:${uid}:tids_unread`); From cddac03a5f8ceef7fd4121c01a65a5590726be2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Tue, 26 Sep 2023 11:51:18 -0400 Subject: [PATCH 8/8] fix: change priv to topics:read --- src/topics/unread.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/topics/unread.js b/src/topics/unread.js index c1666f7d91..9c6d2c35c2 100644 --- a/src/topics/unread.js +++ b/src/topics/unread.js @@ -318,7 +318,7 @@ module.exports = function (Topics) { Topics.markAllRead = async function (uid) { const cutoff = await Topics.unreadCutoff(uid); let tids = await db.getSortedSetRevRangeByScore('topics:recent', 0, -1, '+inf', cutoff); - tids = await privileges.topics.filterTids('read', tids, uid); + tids = await privileges.topics.filterTids('topics:read', tids, uid); Topics.markTopicNotificationsRead(tids, uid); await Topics.markAsRead(tids, uid); await db.delete(`uid:${uid}:tids_unread`);