From b7920b7ad9049dd5a8eca6607c689b64856f995a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Wed, 16 Aug 2023 19:35:23 -0400 Subject: [PATCH 001/126] lets test perm redirect --- src/controllers/posts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/posts.js b/src/controllers/posts.js index 128fdc130a..7865ba0af7 100644 --- a/src/controllers/posts.js +++ b/src/controllers/posts.js @@ -26,7 +26,7 @@ postsController.redirectToPost = async function (req, res, next) { } const qs = querystring.stringify(req.query); - helpers.redirect(res, qs ? `${path}?${qs}` : path); + helpers.redirect(res, qs ? `${path}?${qs}` : path, true); }; postsController.getRecentPosts = async function (req, res) { From fcc04ef376fa77e4ec9d263262aa9989755aba7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Wed, 16 Aug 2023 19:49:21 -0400 Subject: [PATCH 002/126] use same settings for spiders --- src/user/settings.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/user/settings.js b/src/user/settings.js index 6f560e58f7..9d8c92fdc3 100644 --- a/src/user/settings.js +++ b/src/user/settings.js @@ -10,11 +10,16 @@ const notifications = require('../notifications'); const languages = require('../languages'); module.exports = function (User) { + const spiderDefaultSettings = { + usePagination: 1, + topicPostSort: 'oldest_to_newest', + postsPerPage: 20, + topicsPerPage: 20, + }; User.getSettings = async function (uid) { if (parseInt(uid, 10) <= 0) { - return await onSettingsLoaded(uid, { - usePagination: parseInt(uid, 10) === -1 ? 1 : undefined, // force spiders to use pagination - }); + const isSpider = parseInt(uid, 10) === -1; + return await onSettingsLoaded(uid, isSpider ? spiderDefaultSettings : {}); } let settings = await db.getObject(`user:${uid}:settings`); settings = settings || {}; From e5fc4a52103baf1852792d177046feb1697fc414 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Wed, 16 Aug 2023 19:59:13 -0400 Subject: [PATCH 003/126] remove /1 from url if it goes to first post of topic --- src/posts/topics.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/posts/topics.js b/src/posts/topics.js index 9c17d33ba9..8e94db3017 100644 --- a/src/posts/topics.js +++ b/src/posts/topics.js @@ -44,7 +44,8 @@ module.exports = function (Posts) { const postIndex = utils.isNumber(indices[index]) ? parseInt(indices[index], 10) + 1 : null; if (slug && postIndex) { - return `/topic/${slug}/${postIndex}`; + const index = postIndex === 1 ? '' : `/${postIndex}`; + return `/topic/${slug}${index}`; } return null; }); From c7df93b4baefa2df6cdaf14095f6c4689929704b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Wed, 16 Aug 2023 20:08:59 -0400 Subject: [PATCH 004/126] chore: up harmony --- install/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/package.json b/install/package.json index ea60bdca28..9e3305c193 100644 --- a/install/package.json +++ b/install/package.json @@ -102,7 +102,7 @@ "nodebb-plugin-ntfy": "1.4.0", "nodebb-plugin-spam-be-gone": "2.1.1", "nodebb-rewards-essentials": "0.2.3", - "nodebb-theme-harmony": "1.1.35", + "nodebb-theme-harmony": "1.1.36", "nodebb-theme-lavender": "7.1.3", "nodebb-theme-peace": "2.1.10", "nodebb-theme-persona": "13.2.17", From 35e689cff5924feb9d93891e21e590bfa4cab4ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Wed, 16 Aug 2023 20:11:22 -0400 Subject: [PATCH 005/126] test: fix redirect test --- test/controllers.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/controllers.js b/test/controllers.js index 9c6790d5c5..70e3b8a80a 100644 --- a/test/controllers.js +++ b/test/controllers.js @@ -2037,8 +2037,8 @@ describe('Controllers', () => { request(`${nconf.get('url')}/api/post/${pid}`, { json: true }, (err, res, body) => { assert.ifError(err); assert.equal(res.statusCode, 200); - assert.equal(res.headers['x-redirect'], '/topic/1/test-topic-title/1'); - assert.equal(body, '/topic/1/test-topic-title/1'); + assert.equal(res.headers['x-redirect'], '/topic/1/test-topic-title'); + assert.equal(body, '/topic/1/test-topic-title'); done(); }); }); From 9e829b983df9ebdb7511dfc5513adaa677f2b13c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Wed, 16 Aug 2023 20:28:34 -0400 Subject: [PATCH 006/126] 308 /uid/ to /user/ --- src/middleware/user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/middleware/user.js b/src/middleware/user.js index c9713df9aa..710c121d52 100644 --- a/src/middleware/user.js +++ b/src/middleware/user.js @@ -206,7 +206,7 @@ module.exports = function (middleware) { } const path = req.url.replace(/^\/api/, '') .replace(`/uid/${uid}`, () => `/user/${userslug}`); - controllers.helpers.redirect(res, path); + controllers.helpers.redirect(res, path, true); }); middleware.redirectMeToUserslug = helpers.try(async (req, res) => { From cb3252be8ab861f7ff74904edd45b89709eb5adb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Thu, 17 Aug 2023 13:48:50 -0400 Subject: [PATCH 007/126] chore: up themes --- install/package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/install/package.json b/install/package.json index 9e3305c193..7d3a2a16d3 100644 --- a/install/package.json +++ b/install/package.json @@ -102,10 +102,10 @@ "nodebb-plugin-ntfy": "1.4.0", "nodebb-plugin-spam-be-gone": "2.1.1", "nodebb-rewards-essentials": "0.2.3", - "nodebb-theme-harmony": "1.1.36", + "nodebb-theme-harmony": "1.1.37", "nodebb-theme-lavender": "7.1.3", - "nodebb-theme-peace": "2.1.10", - "nodebb-theme-persona": "13.2.17", + "nodebb-theme-peace": "2.1.11", + "nodebb-theme-persona": "13.2.18", "nodebb-widget-essentials": "7.0.13", "nodemailer": "6.9.4", "nprogress": "0.2.0", From 5c14438d36f8e1716baf4201d3b04522373234ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Thu, 17 Aug 2023 14:08:07 -0400 Subject: [PATCH 008/126] chore: up themes --- install/package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/install/package.json b/install/package.json index 7d3a2a16d3..99243a7955 100644 --- a/install/package.json +++ b/install/package.json @@ -102,10 +102,10 @@ "nodebb-plugin-ntfy": "1.4.0", "nodebb-plugin-spam-be-gone": "2.1.1", "nodebb-rewards-essentials": "0.2.3", - "nodebb-theme-harmony": "1.1.37", + "nodebb-theme-harmony": "1.1.38", "nodebb-theme-lavender": "7.1.3", - "nodebb-theme-peace": "2.1.11", - "nodebb-theme-persona": "13.2.18", + "nodebb-theme-peace": "2.1.12", + "nodebb-theme-persona": "13.2.19", "nodebb-widget-essentials": "7.0.13", "nodemailer": "6.9.4", "nprogress": "0.2.0", From 560215969197fe031c0c9f713bce03083c365682 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Thu, 17 Aug 2023 15:04:08 -0400 Subject: [PATCH 009/126] hmm node 20, yummy --- .github/workflows/test.yaml | 8 +++----- src/start.js | 8 +++++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index c97b7fb8da..80e8d4e1ed 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -5,12 +5,10 @@ on: branches: - master - develop - - bootstrap5 pull_request: branches: - master - develop - - bootstrap5 defaults: run: @@ -29,19 +27,19 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - node: [16, 18] + node: [16, 18, 20] database: [mongo-dev, mongo, redis, postgres] include: # only run coverage once - os: ubuntu-latest - node: 16 + node: 18 coverage: true # test under development once - database: mongo-dev test_env: development # only run eslint once - os: ubuntu-latest - node: 16 + node: 18 database: mongo-dev lint: true runs-on: ${{ matrix.os }} diff --git a/src/start.js b/src/start.js index f87f0b4ddf..94a785bcc7 100644 --- a/src/start.js +++ b/src/start.js @@ -95,8 +95,9 @@ function printStartupInfo() { } function addProcessHandlers() { - process.on('SIGTERM', shutdown); - process.on('SIGINT', shutdown); + ['SIGTERM', 'SIGINT', 'SIGQUIT'].forEach((signal) => { + process.on(signal, () => shutdown()); + }); process.on('SIGHUP', restart); process.on('uncaughtException', (err) => { winston.error(err.stack); @@ -130,7 +131,7 @@ function restart() { } async function shutdown(code) { - winston.info('[app] Shutdown (SIGTERM/SIGINT) Initialised.'); + winston.info('[app] Shutdown (SIGTERM/SIGINT/SIGQUIT) Initialised.'); try { await require('./webserver').destroy(); winston.info('[app] Web server closed to connections.'); @@ -142,6 +143,7 @@ async function shutdown(code) { process.exit(code || 0); } catch (err) { winston.error(err.stack); + return process.exit(code || 0); } } From 2804b5ac9a6e4b489fa613861c6697ad353f8f31 Mon Sep 17 00:00:00 2001 From: Misty Release Bot Date: Fri, 18 Aug 2023 09:18:56 +0000 Subject: [PATCH 010/126] Latest translations and fallbacks --- public/language/he/admin/admin.json | 2 +- public/language/he/admin/dashboard.json | 8 ++++---- public/language/he/admin/menu.json | 2 +- public/language/he/admin/settings/chat.json | 2 +- public/language/he/error.json | 4 ++-- public/language/he/global.json | 4 ++-- public/language/he/modules.json | 10 +++++----- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/public/language/he/admin/admin.json b/public/language/he/admin/admin.json index 05c6ac70fb..7e94d2b2ba 100644 --- a/public/language/he/admin/admin.json +++ b/public/language/he/admin/admin.json @@ -14,5 +14,5 @@ "view": "צפייה", "edit": "עריכה", "add": "הוספה", - "select-icon": "Select Icon" + "select-icon": "בחר סמל" } \ No newline at end of file diff --git a/public/language/he/admin/dashboard.json b/public/language/he/admin/dashboard.json index 472c01a389..c551343564 100644 --- a/public/language/he/admin/dashboard.json +++ b/public/language/he/admin/dashboard.json @@ -48,7 +48,7 @@ "restart-disabled": "הפעלה או בניה מחדש של הפורום בוטלה, נראה שאינך מפעיל את הפורום דרך שרת מתאים.", "maintenance-mode": "מצב תחזוקה", "maintenance-mode-title": "לחץ כאן על מנת להכניס את הפורום למצב תחזוקה", - "dark-mode": "Dark Mode", + "dark-mode": "מצב כהה", "realtime-chart-updates": "עדכן תרשים בזמן אמת", "active-users": "משתמשים פעילים", @@ -91,8 +91,8 @@ "start": "התחלה", "end": "סיום", "filter": "סינון", - "view-as-json": "View as JSON", + "view-as-json": "הצג כ-JSON", "expand-analytics": "Expand analytics", - "clear-search-history": "Clear Search History", - "clear-search-history-confirm": "Are you sure you want to clear entire search history?" + "clear-search-history": "מחק היסטוריית חיפושים", + "clear-search-history-confirm": "האם אתה בטוח שברצונך למחוק את כל היסטוריית החיפושים?" } diff --git a/public/language/he/admin/menu.json b/public/language/he/admin/menu.json index affb02c2e8..af4a3d8276 100644 --- a/public/language/he/admin/menu.json +++ b/public/language/he/admin/menu.json @@ -14,7 +14,7 @@ "manage/users": "משתמשים", "manage/admins-mods": "מנחים ומנהלים", "manage/registration": "תור הרשמה", - "manage/flagged-content": "Flagged Content", + "manage/flagged-content": "תוכן מדווח", "manage/post-queue": "תור פוסטים", "manage/groups": "קבוצות", "manage/ip-blacklist": "רשימה שחורה של כתובות IP", diff --git a/public/language/he/admin/settings/chat.json b/public/language/he/admin/settings/chat.json index c7a3bdf478..27a5f0e69d 100644 --- a/public/language/he/admin/settings/chat.json +++ b/public/language/he/admin/settings/chat.json @@ -4,7 +4,7 @@ "disable-editing": "השבת עריכה/מחיקה של הודעות צ'אט", "disable-editing-help": "מנהלי מערכת ומנחים גלובליים פטורים מהגבלה זו", "max-length": "אורך מקסימלי של הודעת צ'אט", - "max-chat-room-name-length": "Maximum length of chat room names", + "max-chat-room-name-length": "אורך מקסימלי של שם חדר צ'אט", "max-room-size": "מספר המשתמשים המרבי בחדרי צ'אט", "delay": "זמן המתנה בין הודעות צ'אט - באלפיות שניה", "notification-delay": "עיכוב התראות להודעות צ'אט. (0 ללא עיכוב)", diff --git a/public/language/he/error.json b/public/language/he/error.json index c959a0e711..17b77ce97d 100644 --- a/public/language/he/error.json +++ b/public/language/he/error.json @@ -55,7 +55,7 @@ "user-banned-reason-until": "מצטערים, חשבון זה הורחק עד %1 (סיבה: %2)", "user-too-new": "אנא המתינו %1 שניות לפני פרסום ההודעה", "blacklisted-ip": "מצטערים, אך הורחקתם מקהילה זו. אם הנכם סבורים שמדובר בטעות, אנא צרו קשר עם מנהלי הקהילה.", - "cant-blacklist-self-ip": "You can't blacklist your own IP", + "cant-blacklist-self-ip": "לא ניתן לרשום את ה-IP של עצמך ברשימה השחורה", "ban-expiry-missing": "אנא ספקו תאריך סיום להרחקה זו.", "no-category": "קטגוריה אינה קיימת", "no-topic": "נושא אינו קיים", @@ -165,7 +165,7 @@ "chat-room-does-not-exist": "חדר צ'אט אינו קיים.", "cant-add-users-to-chat-room": "לא ניתן להוסיף משתמשים לחדר הצ'אט.", "cant-remove-users-from-chat-room": "לא ניתן להסיר משתמשים מחדר הצ'אט.", - "chat-room-name-too-long": "Chat room name too long. Names can't be longer than %1 characters.", + "chat-room-name-too-long": "שם החדר ארוך מדי. השם לא יכול להיות ארוך מ-%1 תווים.", "already-voting-for-this-post": "הצבעתם כבר בנושא זה.", "reputation-system-disabled": "מערכת המוניטין לא פעילה.", "downvoting-disabled": "היכולת להצביע נגד מושבתת", diff --git a/public/language/he/global.json b/public/language/he/global.json index 4e0395b1dc..7dd51cee85 100644 --- a/public/language/he/global.json +++ b/public/language/he/global.json @@ -51,8 +51,8 @@ "nextpage": "העמוד הבא", "alert.success": "הצלחה", "alert.error": "שגיאה", - "alert.warning": "Warning", - "alert.info": "Info", + "alert.warning": "אזהרה", + "alert.info": "מידע", "alert.banned": "מורחק", "alert.banned.message": "You have just been banned, your access is now restricted.", "alert.unbanned": "Unbanned", diff --git a/public/language/he/modules.json b/public/language/he/modules.json index 1968510ea0..b1a835c79b 100644 --- a/public/language/he/modules.json +++ b/public/language/he/modules.json @@ -10,7 +10,7 @@ "chat.no_active": "אין לכם צ'אטים פעילים.", "chat.user_typing": "%1 מקליד...", "chat.user_has_messaged_you": "ל%1 יש הודעה עבורכם.", - "chat.replying-to": "Replying to %1", + "chat.replying-to": "מגיב ל%1", "chat.see_all": "צפו בכל הצ'אטים", "chat.mark_all_read": "סמנו את כל הצ'אטים כ'נקראו'", "chat.no-messages": "בחרו משתמש על מנת לראות את שיחות הצ'אט ביניכם", @@ -50,7 +50,7 @@ "chat.rename-room": "שינוי שם חדר", "chat.rename-placeholder": "הזינו את שם החדר שלכם כאן", "chat.rename-help": "שם החדר המוגדר כאן יהיה זמין לכל המשתתפים בחדר.", - "chat.leave": "Leave", + "chat.leave": "יציאה", "chat.leave-room": "עזוב חדר", "chat.leave-prompt": "האם לעזוב שיחה זו?", "chat.leave-help": "עזיבת שיחה, תסיר אתכם מהתכתבות עתידית בצ'אט זה. אם תצטרפו מחדש בעתיד, לא תראו את היסטוריית הצ'אט שלפני הצטרפותכם מחדש.", @@ -62,9 +62,9 @@ "chat.show-ip": "הצג IP", "chat.owner": "מנהלי החדר", "chat.grant-rescind-ownership": "הענק/בטל בעלות", - "chat.system.user-join": "%1 has joined the room ", - "chat.system.user-leave": "%1 has left the room ", - "chat.system.room-rename": "%2 has renamed this room to \"%1\" ", + "chat.system.user-join": "%1 הצטרף לחדר ", + "chat.system.user-leave": "%1 עזב את החדר ", + "chat.system.room-rename": "%2 שינה את שם החדר הזה ל \"%1\" ", "composer.compose": "יצירה", "composer.show_preview": "הצגת תצוגה מקדימה", "composer.hide_preview": "הסתרת תצוגה מקדימה", From b958a39a660eb2d37be25c1d8c3cb4e39406b54e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Fri, 18 Aug 2023 20:47:55 -0400 Subject: [PATCH 011/126] feat: log roomId/roomName on delete --- src/controllers/write/admin.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/controllers/write/admin.js b/src/controllers/write/admin.js index 84d25ac300..4ffeb4df54 100644 --- a/src/controllers/write/admin.js +++ b/src/controllers/write/admin.js @@ -34,10 +34,16 @@ Admin.getAnalyticsData = async (req, res) => { Admin.chats = {}; Admin.chats.deleteRoom = async (req, res) => { + const roomData = await messaging.getRoomData(req.params.roomId); + if (!roomData) { + throw new Error('[[error:no-room]]'); + } await messaging.deleteRooms([req.params.roomId]); events.log({ type: 'chat-room-deleted', + roomId: req.params.roomId, + roomName: roomData.roomName ? roomData.roomName : `No room name`, uid: req.uid, ip: req.ip, }); From 7dd143e1f88d91ad9fe01c01443347c953c14a1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Fri, 18 Aug 2023 21:40:39 -0400 Subject: [PATCH 012/126] fix: show access denied instead of internal error when user doesn't have access to chats --- src/controllers/accounts/chats.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/accounts/chats.js b/src/controllers/accounts/chats.js index 221e1f5fae..d8555967df 100644 --- a/src/controllers/accounts/chats.js +++ b/src/controllers/accounts/chats.js @@ -20,7 +20,7 @@ chatsController.get = async function (req, res, next) { } const canChat = await privileges.global.can('chat', req.uid); if (!canChat) { - return next(new Error('[[error:no-privileges]]')); + return helpers.notAllowed(req, res, '[[error:no-privileges]]'); } const payload = { From aeb27f4b8d6b3cbc2eff10f7349d3268fd07bd53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Fri, 18 Aug 2023 21:41:00 -0400 Subject: [PATCH 013/126] fix: admins should see public chats even if they are not in any of the groups --- src/messaging/index.js | 11 +++++++++-- src/messaging/rooms.js | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/messaging/index.js b/src/messaging/index.js index 5199345720..0d58e0c019 100644 --- a/src/messaging/index.js +++ b/src/messaging/index.js @@ -130,11 +130,13 @@ Messaging.getPublicRooms = async (callerUid, uid) => { const allRoomIds = await Messaging.getPublicRoomIdsFromSet('chat:rooms:public:order'); const allRoomData = await Messaging.getRoomsData(allRoomIds); + const isAdmin = await privileges.users.isAdministrator(callerUid); const checks = await Promise.all( allRoomData.map( room => room && ( !Array.isArray(room.groups) || !room.groups.length || + isAdmin || groups.isMemberOfAny(uid, room && room.groups) ) ) @@ -369,16 +371,21 @@ Messaging.canMessageUser = async (uid, toUid) => { }; Messaging.canMessageRoom = async (uid, roomId) => { + console.log('can message room', uid, roomId); if (meta.config.disableChat || uid <= 0) { throw new Error('[[error:chat-disabled]]'); } - const [inRoom, canChat] = await Promise.all([ + const [roomData, inRoom, canChat] = await Promise.all([ + Messaging.getRoomData(roomId), Messaging.isUserInRoom(uid, roomId), privileges.global.can('chat', uid), checkReputation(uid), ]); - + if (!roomData) { + throw new Error('[[error:no-room]]'); + } + console.log('can chat', canChat); if (!inRoom) { throw new Error('[[error:not-in-room]]'); } diff --git a/src/messaging/rooms.js b/src/messaging/rooms.js index 5428489f42..202b8238df 100644 --- a/src/messaging/rooms.js +++ b/src/messaging/rooms.js @@ -454,7 +454,7 @@ module.exports = function (Messaging) { if (!room || (!room.public && !inRoom) || (room.public && ( - Array.isArray(room.groups) && room.groups.length && !(await groups.isMemberOfAny(uid, room.groups))) + Array.isArray(room.groups) && room.groups.length && !isAdmin && !(await groups.isMemberOfAny(uid, room.groups))) ) ) { return null; From 82d95ba812fd95340f6d50ac93800c2e4bd8c804 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Fri, 18 Aug 2023 21:42:21 -0400 Subject: [PATCH 014/126] remove logs --- src/messaging/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/messaging/index.js b/src/messaging/index.js index 0d58e0c019..789b6de2a0 100644 --- a/src/messaging/index.js +++ b/src/messaging/index.js @@ -371,7 +371,6 @@ Messaging.canMessageUser = async (uid, toUid) => { }; Messaging.canMessageRoom = async (uid, roomId) => { - console.log('can message room', uid, roomId); if (meta.config.disableChat || uid <= 0) { throw new Error('[[error:chat-disabled]]'); } @@ -385,7 +384,7 @@ Messaging.canMessageRoom = async (uid, roomId) => { if (!roomData) { throw new Error('[[error:no-room]]'); } - console.log('can chat', canChat); + if (!inRoom) { throw new Error('[[error:not-in-room]]'); } From 6b09b7c7d45b74ef9cabd6cab6241bc5bbf2785c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Sat, 19 Aug 2023 16:40:43 -0400 Subject: [PATCH 015/126] test: fix tests, dont hang if payload is string closes #11933 --- src/controllers/accounts/chats.js | 2 +- src/controllers/helpers.js | 9 +++++---- src/messaging/rooms.js | 10 +++++----- test/messaging.js | 6 +++--- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/controllers/accounts/chats.js b/src/controllers/accounts/chats.js index d8555967df..5bee1f65a6 100644 --- a/src/controllers/accounts/chats.js +++ b/src/controllers/accounts/chats.js @@ -20,7 +20,7 @@ chatsController.get = async function (req, res, next) { } const canChat = await privileges.global.can('chat', req.uid); if (!canChat) { - return helpers.notAllowed(req, res, '[[error:no-privileges]]'); + return helpers.notAllowed(req, res); } const payload = { diff --git a/src/controllers/helpers.js b/src/controllers/helpers.js index 0f6b5b4a34..fb228cbfb7 100644 --- a/src/controllers/helpers.js +++ b/src/controllers/helpers.js @@ -475,8 +475,8 @@ helpers.formatApiResponse = async (statusCode, res, payload) => { status: { code, message }, response: payload || {}, }); - } else if (payload instanceof Error) { - const { message } = payload; + } else if (payload instanceof Error || typeof payload === 'string') { + const message = payload instanceof Error ? payload.message : payload; const response = {}; // Update status code based on some common error codes @@ -512,9 +512,10 @@ helpers.formatApiResponse = async (statusCode, res, payload) => { process.stdout.write(payload.stack); } res.status(statusCode).json(returnPayload); - } else if (!payload) { + } else { // Non-2xx statusCode, generate predefined error - const returnPayload = await helpers.generateError(statusCode, null, res); + const message = payload ? String(payload) : null; + const returnPayload = await helpers.generateError(statusCode, message, res); res.status(statusCode).json(returnPayload); } }; diff --git a/src/messaging/rooms.js b/src/messaging/rooms.js index 202b8238df..03586ef6da 100644 --- a/src/messaging/rooms.js +++ b/src/messaging/rooms.js @@ -447,17 +447,17 @@ module.exports = function (Messaging) { user.isAdministrator(uid), user.isGlobalModerator(uid), ]); - - if (!canChat) { - throw new Error('[[error:no-privileges]]'); + if (!room) { + return null; } - if (!room || + + if (!canChat || (!room.public && !inRoom) || (room.public && ( Array.isArray(room.groups) && room.groups.length && !isAdmin && !(await groups.isMemberOfAny(uid, room.groups))) ) ) { - return null; + throw new Error('[[error:no-privileges]]'); } // add user to public room onload diff --git a/test/messaging.js b/test/messaging.js index 1501f28e17..2e5af6b60c 100644 --- a/test/messaging.js +++ b/test/messaging.js @@ -697,7 +697,7 @@ describe('Messaging Library', () => { assert.equal(response.statusCode, 404); }); - it('should 500 for guest with no privilege error', async () => { + it('should 401 for guest with not-authorised status code', async () => { meta.config.disableChat = 0; const response = await request(`${nconf.get('url')}/api/user/baz/chats`, { resolveWithFullResponse: true, @@ -706,8 +706,8 @@ describe('Messaging Library', () => { }); const { body } = response; - assert.equal(response.statusCode, 500); - assert.equal(body.error, '[[error:no-privileges]]'); + assert.equal(response.statusCode, 401); + assert.equal(body.status.code, 'not-authorised'); }); it('should 404 for non-existent user', async () => { From 8b533d5467c3aa47724663ae1bb13e17c2df52df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Sat, 19 Aug 2023 16:47:10 -0400 Subject: [PATCH 016/126] test: one more fix --- src/messaging/rooms.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/messaging/rooms.js b/src/messaging/rooms.js index 03586ef6da..c78be73671 100644 --- a/src/messaging/rooms.js +++ b/src/messaging/rooms.js @@ -447,16 +447,16 @@ module.exports = function (Messaging) { user.isAdministrator(uid), user.isGlobalModerator(uid), ]); - if (!room) { - return null; - } - if (!canChat || + if (!room || (!room.public && !inRoom) || (room.public && ( Array.isArray(room.groups) && room.groups.length && !isAdmin && !(await groups.isMemberOfAny(uid, room.groups))) ) ) { + return null; + } + if (!canChat) { throw new Error('[[error:no-privileges]]'); } From 9534f9b9b987eb96af39bc1d97c15262a0e826d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Sat, 19 Aug 2023 17:15:06 -0400 Subject: [PATCH 017/126] feat: check mute when messaging, closes #11932 --- src/messaging/index.js | 1 + src/user/posts.js | 26 ++++++++++++++++---------- test/messaging.js | 22 ++++++++++++++++++++++ 3 files changed, 39 insertions(+), 10 deletions(-) diff --git a/src/messaging/index.js b/src/messaging/index.js index 789b6de2a0..c5e9dfe9d0 100644 --- a/src/messaging/index.js +++ b/src/messaging/index.js @@ -380,6 +380,7 @@ Messaging.canMessageRoom = async (uid, roomId) => { Messaging.isUserInRoom(uid, roomId), privileges.global.can('chat', uid), checkReputation(uid), + user.checkMuted(uid), ]); if (!roomData) { throw new Error('[[error:no-room]]'); diff --git a/src/user/posts.js b/src/user/posts.js index 9ca31cd6e7..26b0f348bf 100644 --- a/src/user/posts.js +++ b/src/user/posts.js @@ -13,6 +13,20 @@ module.exports = function (User) { await isReady(uid, cid, 'lastqueuetime'); }; + User.checkMuted = async function (uid) { + const now = Date.now(); + const mutedUntil = await User.getUserField(uid, 'mutedUntil'); + if (mutedUntil > now) { + let muteLeft = ((mutedUntil - now) / (1000 * 60)); + if (muteLeft > 60) { + muteLeft = (muteLeft / 60).toFixed(0); + throw new Error(`[[error:user-muted-for-hours, ${muteLeft}]]`); + } else { + throw new Error(`[[error:user-muted-for-minutes, ${muteLeft.toFixed(0)}]]`); + } + } + }; + async function isReady(uid, cid, field) { if (parseInt(uid, 10) === 0) { return; @@ -30,17 +44,9 @@ module.exports = function (User) { return; } - const now = Date.now(); - if (userData.mutedUntil > now) { - let muteLeft = ((userData.mutedUntil - now) / (1000 * 60)); - if (muteLeft > 60) { - muteLeft = (muteLeft / 60).toFixed(0); - throw new Error(`[[error:user-muted-for-hours, ${muteLeft}]]`); - } else { - throw new Error(`[[error:user-muted-for-minutes, ${muteLeft.toFixed(0)}]]`); - } - } + await User.checkMuted(uid); + const now = Date.now(); if (now - userData.joindate < meta.config.initialPostDelay * 1000) { throw new Error(`[[error:user-too-new, ${meta.config.initialPostDelay}]]`); } diff --git a/test/messaging.js b/test/messaging.js index 2e5af6b60c..c829eb5077 100644 --- a/test/messaging.js +++ b/test/messaging.js @@ -113,6 +113,28 @@ describe('Messaging Library', () => { }); }); }); + + it('should not allow messaging room if user is muted', async () => { + const twoMinutesFromNow = Date.now() + (2 * 60 * 1000); + const twoHoursFromNow = Date.now() + (2 * 60 * 60 * 1000); + const roomId = 0; + + await User.setUserField(mocks.users.herp.uid, 'mutedUntil', twoMinutesFromNow); + await assert.rejects(Messaging.canMessageRoom(mocks.users.herp.uid, roomId), (err) => { + assert(err.message.startsWith('[[error:user-muted-for-minutes,')); + return true; + }); + + await User.setUserField(mocks.users.herp.uid, 'mutedUntil', twoHoursFromNow); + await assert.rejects(Messaging.canMessageRoom(mocks.users.herp.uid, roomId), (err) => { + assert(err.message.startsWith('[[error:user-muted-for-hours,')); + return true; + }); + await db.deleteObjectField(`user:${mocks.users.herp.uid}`, 'mutedUntil'); + await assert.rejects(Messaging.canMessageRoom(mocks.users.herp.uid, roomId), { + message: '[[error:no-room]]', + }); + }); }); describe('rooms', () => { From 7ebdfe71533ef6079431d997a621415cb8ea6125 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 19 Aug 2023 19:13:10 -0400 Subject: [PATCH 018/126] chore(deps): update mongo docker tag to v7 (#11928) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 80e8d4e1ed..097bba573a 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -75,7 +75,7 @@ jobs: - 6379:6379 mongo: - image: 'mongo:6.0' + image: 'mongo:7.0' ports: # Maps port 27017 on service container to the host - 27017:27017 From c09c29fae41ec33caf7c8de9e8dfc331085d6d82 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 19 Aug 2023 19:13:39 -0400 Subject: [PATCH 019/126] fix(deps): update dependency pg-cursor to v2.10.3 (#11920) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- install/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/package.json b/install/package.json index fe1241d406..9b8cc0324f 100644 --- a/install/package.json +++ b/install/package.json @@ -113,7 +113,7 @@ "passport-http-bearer": "1.0.1", "passport-local": "1.0.0", "pg": "8.11.2", - "pg-cursor": "2.10.2", + "pg-cursor": "2.10.3", "postcss": "8.4.28", "postcss-clean": "1.2.0", "progress-webpack-plugin": "1.0.16", From 01c94daf119ea52d93b3d592399a9fb3f7400c60 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 19 Aug 2023 19:14:21 -0400 Subject: [PATCH 020/126] fix(deps): update dependency sass to v1.66.1 (#11927) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- install/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/package.json b/install/package.json index 9b8cc0324f..b3ece0aaa6 100644 --- a/install/package.json +++ b/install/package.json @@ -125,7 +125,7 @@ "rss": "1.2.2", "rtlcss": "4.1.0", "sanitize-html": "2.11.0", - "sass": "1.65.1", + "sass": "1.66.1", "semver": "7.5.4", "serve-favicon": "2.5.0", "sharp": "0.32.5", From 0b1b6af379a1ae3fba2e911a5860b8069f574ff8 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 19 Aug 2023 19:15:11 -0400 Subject: [PATCH 021/126] fix(deps): update dependency archiver to v6 (#11929) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- install/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/package.json b/install/package.json index b3ece0aaa6..68140d6f60 100644 --- a/install/package.json +++ b/install/package.json @@ -35,7 +35,7 @@ "@isaacs/ttlcache": "1.4.1", "@popperjs/core": "2.11.8", "ace-builds": "1.24.1", - "archiver": "5.3.1", + "archiver": "6.0.0", "async": "3.2.4", "autoprefixer": "10.4.15", "bcryptjs": "2.4.3", From 6492557887f846c703975cb8c6efe5a42dc3342e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 19 Aug 2023 19:15:33 -0400 Subject: [PATCH 022/126] chore(deps): update dependency sass-embedded to v1.66.1 (#11926) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- install/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/package.json b/install/package.json index 68140d6f60..1ca6d2c422 100644 --- a/install/package.json +++ b/install/package.json @@ -171,7 +171,7 @@ "smtp-server": "3.13.0" }, "optionalDependencies": { - "sass-embedded": "1.64.2" + "sass-embedded": "1.66.1" }, "resolutions": { "*/jquery": "3.7.0" From 9c837632ccb84a77997b7f198c830cc8c9edf09d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 19 Aug 2023 20:30:42 -0400 Subject: [PATCH 023/126] fix(deps): update dependency pg to v8.11.3 (#11919) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- install/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/package.json b/install/package.json index 1ca6d2c422..209f78f258 100644 --- a/install/package.json +++ b/install/package.json @@ -112,7 +112,7 @@ "passport": "0.6.0", "passport-http-bearer": "1.0.1", "passport-local": "1.0.0", - "pg": "8.11.2", + "pg": "8.11.3", "pg-cursor": "2.10.3", "postcss": "8.4.28", "postcss-clean": "1.2.0", From c41a4a0fddbe70e459f0c5e8e346fdbacc19ffcd Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 19 Aug 2023 20:31:58 -0400 Subject: [PATCH 024/126] chore(deps): update redis docker tag to v7.2.0 (#11924) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 097bba573a..16d171c2c6 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -63,7 +63,7 @@ jobs: - 5432:5432 redis: - image: 'redis:7.0.12' + image: 'redis:7.2.0' # Set health checks to wait until redis has started options: >- --health-cmd "redis-cli ping" From 44a9d88a2877017c876cbc8dc615df9d0e01126d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 19 Aug 2023 21:27:40 -0400 Subject: [PATCH 025/126] chore(deps): update dependency eslint-plugin-import to v2.28.1 (#11848) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- install/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/package.json b/install/package.json index 209f78f258..1e92b21d59 100644 --- a/install/package.json +++ b/install/package.json @@ -158,7 +158,7 @@ "coveralls": "3.1.1", "eslint": "8.47.0", "eslint-config-nodebb": "0.2.1", - "eslint-plugin-import": "2.27.5", + "eslint-plugin-import": "2.28.1", "grunt": "1.6.1", "grunt-contrib-watch": "1.1.0", "husky": "8.0.3", From c92ecfb4b95980a5dd84f5566b82b8b8a09a8f60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Sat, 19 Aug 2023 21:46:09 -0400 Subject: [PATCH 026/126] feat: better acp sidebar in dark mode --- public/scss/admin/common.scss | 22 ++++++++++------------ public/scss/admin/overrides.scss | 6 +++--- src/views/admin/partials/mobile-footer.tpl | 2 +- src/views/admin/partials/offcanvas.tpl | 2 +- src/views/admin/partials/sidebar-left.tpl | 2 +- 5 files changed, 16 insertions(+), 18 deletions(-) diff --git a/public/scss/admin/common.scss b/public/scss/admin/common.scss index b94eddd2da..b99da61b94 100644 --- a/public/scss/admin/common.scss +++ b/public/scss/admin/common.scss @@ -64,18 +64,16 @@ } @include color-mode(dark) { - #content { - .btn-light { - @extend .btn-dark; - } - .text-bg-light { - @extend .text-bg-dark; - } - .btn-ghost, .btn-ghost-sm, .btn-outline, .btn-outline-sm { - color: $btn-ghost-color-dark; - &:hover, &.active { - background-color: $btn-ghost-hover-color-dark; - } + .btn-light { + @extend .btn-dark; + } + .text-bg-light { + @extend .text-bg-dark; + } + .btn-ghost, .btn-ghost-sm, .btn-outline, .btn-outline-sm { + color: $btn-ghost-color-dark; + &:hover, &.active { + background-color: $btn-ghost-hover-color-dark; } } } diff --git a/public/scss/admin/overrides.scss b/public/scss/admin/overrides.scss index 90f71d908f..bf8403063b 100644 --- a/public/scss/admin/overrides.scss +++ b/public/scss/admin/overrides.scss @@ -16,10 +16,10 @@ $yellow: #ffc107 !default; $green: #198754 !default; $cyan: #0dcaf0 !default; -$light: $gray-100 !default; -$dark: $gray-900 !default; +$light: $gray-100 !default; +$dark: $gray-800 !default; -$body-color: $gray-800; +$body-color: $gray-800 !default; $text-muted: $gray-600 !default; $btn-ghost-color: rgb(73, 80, 87); diff --git a/src/views/admin/partials/mobile-footer.tpl b/src/views/admin/partials/mobile-footer.tpl index faa2e547c3..f2baba36e3 100644 --- a/src/views/admin/partials/mobile-footer.tpl +++ b/src/views/admin/partials/mobile-footer.tpl @@ -1,5 +1,5 @@
-
+
diff --git a/src/views/admin/partials/offcanvas.tpl b/src/views/admin/partials/offcanvas.tpl index 20688bd1ab..f4651a74e6 100644 --- a/src/views/admin/partials/offcanvas.tpl +++ b/src/views/admin/partials/offcanvas.tpl @@ -1,4 +1,4 @@ -
+
diff --git a/src/views/admin/partials/sidebar-left.tpl b/src/views/admin/partials/sidebar-left.tpl index 3a336101a6..d56029d806 100644 --- a/src/views/admin/partials/sidebar-left.tpl +++ b/src/views/admin/partials/sidebar-left.tpl @@ -1,4 +1,4 @@ -