Merge commit '6790000d1aec8a6babfe96aebb8ac57dafbe719e' into v3.x

This commit is contained in:
Misty Release Bot
2023-11-29 17:21:34 +00:00
8 changed files with 79 additions and 27 deletions

View File

@@ -1,3 +1,49 @@
#### v3.5.1 (2023-11-14)
##### Chores
* up mentions (b1b3dcb6)
* incrementing version number - v3.5.0 (d06fb4f0)
* update changelog for v3.5.0 (5d7c10f1)
* incrementing version number - v3.4.3 (5c984250)
* incrementing version number - v3.4.2 (3f0dac38)
* incrementing version number - v3.4.1 (01e69574)
* 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)
##### New Features
* closes #12123, allow setting hh:mm for pin expiry (1f800747)
##### Bug Fixes
* update ajaxifyTimer logic to only drop the request if the URL is the same as the one it's already processing (dcb0c4db)
* closes #12156, missing data for privilege tables (21e59538)
* thumb width (46f6f9ef)
* closes #12126, fix language keys (668a355a)
#### v3.5.0 (2023-10-25)
##### Chores

View File

@@ -93,7 +93,7 @@
"multiparty": "4.2.3",
"nconf": "0.12.1",
"nodebb-plugin-2factor": "7.4.0",
"nodebb-plugin-composer-default": "10.2.24",
"nodebb-plugin-composer-default": "10.2.27",
"nodebb-plugin-dbsearch": "6.2.2",
"nodebb-plugin-emoji": "5.1.13",
"nodebb-plugin-emoji-android": "4.0.0",

View File

@@ -1,6 +1,5 @@
'use strict';
const util = require('util');
const path = require('path');
const fs = require('fs').promises;
@@ -330,10 +329,6 @@ usersAPI.deleteToken = async (caller, { uid, token }) => {
return true;
};
const getSessionAsync = util.promisify((sid, callback) => {
db.sessionStore.get(sid, (err, sessionObj) => callback(err, sessionObj || null));
});
usersAPI.revokeSession = async (caller, { uid, uuid }) => {
// Only admins or global mods (besides the user themselves) can revoke sessions
if (parseInt(uid, 10) !== caller.uid && !await user.isAdminOrGlobalMod(caller.uid)) {
@@ -344,7 +339,7 @@ usersAPI.revokeSession = async (caller, { uid, uuid }) => {
let _id;
for (const sid of sids) {
/* eslint-disable no-await-in-loop */
const sessionObj = await getSessionAsync(sid);
const sessionObj = await db.sessionStoreGet(sid);
if (sessionObj && sessionObj.meta && sessionObj.meta.uuid === uuid) {
_id = sid;
break;

View File

@@ -77,6 +77,7 @@ let winston;
async function init() {
db = require('../database');
await db.init();
await db.initSessionStore();
user = require('../user');
groups = require('../groups');

View File

@@ -34,4 +34,26 @@ primaryDB.initSessionStore = async function () {
primaryDB.sessionStore = await sessionStoreDB.createSessionStore(sessionStoreConfig);
};
function promisifySessionStoreMethod(method, sid) {
return new Promise((resolve, reject) => {
if (!primaryDB.sessionStore) {
resolve(method === 'get' ? null : undefined);
return;
}
primaryDB.sessionStore[method](sid, (err, result) => {
if (err) reject(err);
else resolve(method === 'get' ? result || null : undefined);
});
});
}
primaryDB.sessionStoreGet = function (sid) {
return promisifySessionStoreMethod('get', sid);
};
primaryDB.sessionStoreDestroy = function (sid) {
return promisifySessionStoreMethod('destroy', sid);
};
module.exports = primaryDB;

View File

@@ -241,10 +241,6 @@ async function checkMaintenance(socket) {
throw new Error(`[[pages:maintenance.text, ${validator.escape(String(meta.config.title || 'NodeBB'))}]]`);
}
const getSessionAsync = util.promisify(
(sid, callback) => db.sessionStore.get(sid, (err, sessionObj) => callback(err, sessionObj || null))
);
async function validateSession(socket, errorMsg) {
const req = socket.request;
const { sessionId } = await plugins.hooks.fire('filter:sockets.sessionId', {
@@ -256,7 +252,7 @@ async function validateSession(socket, errorMsg) {
return;
}
const sessionData = await getSessionAsync(sessionId);
const sessionData = await db.sessionStoreGet(sessionId);
if (!sessionData) {
throw new Error(errorMsg);
}
@@ -282,7 +278,7 @@ async function authorize(request, callback) {
request: request,
});
const sessionData = await getSessionAsync(sessionId);
const sessionData = await db.sessionStoreGet(sessionId);
request.session = sessionData;
let uid = 0;
if (sessionData && sessionData.passport && sessionData.passport.user) {

View File

@@ -2,7 +2,6 @@
const winston = require('winston');
const validator = require('validator');
const util = require('util');
const _ = require('lodash');
const db = require('../database');
const meta = require('../meta');
@@ -62,17 +61,10 @@ module.exports = function (User) {
]);
};
const getSessionFromStore = util.promisify(
(sid, callback) => db.sessionStore.get(sid, (err, sessObj) => callback(err, sessObj || null))
);
const sessionStoreDestroy = util.promisify(
(sid, callback) => db.sessionStore.destroy(sid, err => callback(err))
);
User.auth.getSessions = async function (uid, curSessionId) {
await cleanExpiredSessions(uid);
const sids = await db.getSortedSetRevRange(`uid:${uid}:sessions`, 0, 19);
let sessions = await Promise.all(sids.map(sid => getSessionFromStore(sid)));
let sessions = await Promise.all(sids.map(sid => db.sessionStoreGet(sid)));
sessions = sessions.map((sessObj, idx) => {
if (sessObj && sessObj.meta) {
sessObj.meta.current = curSessionId === sids[idx];
@@ -93,7 +85,7 @@ module.exports = function (User) {
const expiredSids = [];
await Promise.all(Object.keys(uuidMapping).map(async (uuid) => {
const sid = uuidMapping[uuid];
const sessionObj = await getSessionFromStore(sid);
const sessionObj = await db.sessionStoreGet(sid);
const expired = !sessionObj || !sessionObj.hasOwnProperty('passport') ||
!sessionObj.passport.hasOwnProperty('user') ||
parseInt(sessionObj.passport.user, 10) !== parseInt(uid, 10);
@@ -128,13 +120,13 @@ module.exports = function (User) {
User.auth.revokeSession = async function (sessionId, uid) {
winston.verbose(`[user.auth] Revoking session ${sessionId} for user ${uid}`);
const sessionObj = await getSessionFromStore(sessionId);
const sessionObj = await db.sessionStoreGet(sessionId);
if (sessionObj && sessionObj.meta && sessionObj.meta.uuid) {
await db.deleteObjectField(`uid:${uid}:sessionUUID:sessionId`, sessionObj.meta.uuid);
}
await Promise.all([
db.sortedSetRemove(`uid:${uid}:sessions`, sessionId),
sessionStoreDestroy(sessionId),
db.sessionStoreDestroy(sessionId),
]);
};
@@ -159,7 +151,7 @@ module.exports = function (User) {
await Promise.all([
db.deleteAll(sessionKeys.concat(sessionUUIDKeys)),
...sids.map(sid => sessionStoreDestroy(sid)),
...sids.map(sid => db.sessionStoreDestroy(sid)),
]);
}, { batch: 1000 });
};

View File

@@ -1,6 +1,6 @@
<div class="d-flex flex-column gap-4 topic-thumbs-view-modal">
<div class="d-flex justify-content-center align-items-center mb-5" style="height: 33vh; max-height: 33vh;">
<img component="topic/thumb/current" src="{src}" style="max-height: 33vh; width:100%;" />
<img component="topic/thumb/current" src="{src}" style="max-height: 33vh; max-width:100%;" />
</div>
{{{ if (thumbs.length != "1") }}}
<hr/>