Compare commits

...

8 Commits

Author SHA1 Message Date
Barış Soner Uşaklı
89af582951 fix: xss on flags page via ban reason 2021-09-17 11:55:49 -04:00
Barış Soner Uşaklı
9410a73aaa feat: als (#9749)
* feat: als

* fix: up test timeout

* fix: don't overwrite caller if it already exists

* fix: up test timeout for psql
2021-08-30 10:28:30 -04:00
Renovate Bot
b2652ae697 fix(deps): update dependency nodebb-plugin-markdown to v8.14.1 2021-07-07 16:09:50 -04:00
Misty (Bot)
9f90bdcd59 chore: incrementing version number - v1.17.2 2021-07-07 18:44:40 +00:00
Misty (Bot)
b002d25421 Merge commit '8e0561f2264c46e54c08c6ddd0bc8a7e5511d3d3' into v1.17.x 2021-07-07 18:44:27 +00:00
Misty (Bot)
902da54029 chore: incrementing version number - v1.17.1 2021-05-26 15:40:53 +00:00
Misty (Bot)
7c0da8fcbb Merge commit '925883bf4c586dfce1ddf7948158be714acda1ed' into v1.17.x 2021-05-26 15:40:45 +00:00
Misty (Bot)
6b4ef46ead chore: incrementing version number - v1.17.0 2021-04-22 00:37:31 +00:00
8 changed files with 23 additions and 7 deletions

View File

@@ -2,7 +2,7 @@
"name": "nodebb",
"license": "GPL-3.0",
"description": "NodeBB Forum",
"version": "1.17.1",
"version": "1.17.2",
"homepage": "http://www.nodebb.org",
"repository": {
"type": "git",
@@ -88,7 +88,7 @@
"nodebb-plugin-dbsearch": "5.0.2",
"nodebb-plugin-emoji": "^3.5.0",
"nodebb-plugin-emoji-android": "2.0.5",
"nodebb-plugin-markdown": "8.14.0",
"nodebb-plugin-markdown": "8.14.1",
"nodebb-plugin-mentions": "2.13.11",
"nodebb-plugin-spam-be-gone": "0.7.9",
"nodebb-rewards-essentials": "0.1.5",
@@ -182,4 +182,4 @@
"url": "https://github.com/barisusakli"
}
]
}
}

7
src/als.js Normal file
View File

@@ -0,0 +1,7 @@
'use strict';
const { AsyncLocalStorage } = require('async_hooks');
const asyncLocalStorage = new AsyncLocalStorage();
module.exports = asyncLocalStorage;

View File

@@ -776,7 +776,7 @@ async function mergeBanHistory(history, targetUid, uids) {
meta: [
{
key: '[[user:banned]]',
value: cur.reason,
value: validator.escape(String(cur.reason)),
labelClass: 'danger',
},
{

View File

@@ -96,6 +96,10 @@ Hooks.fire = async function (hook, params) {
winston.warn(`[plugins] Unknown hookType: ${hookType}, hook : ${hook}`);
return;
}
if (params && typeof params === 'object' && !params.hasOwnProperty('caller')) {
const als = require('../als');
params.caller = als.getStore();
}
const result = await hookTypeToMethod[hookType](hook, hookList, params);
if (hook !== 'action:plugins.firehook' && hook !== 'filter:plugins.firehook') {

View File

@@ -73,7 +73,8 @@ function onConnection(socket) {
onConnect(socket);
socket.onAny((event, ...args) => {
const payload = { data: [event].concat(args) };
onMessage(socket, payload);
const als = require('../als');
als.run({ uid: socket.uid }, onMessage, socket, payload);
});
socket.on('disconnect', () => {

View File

@@ -171,6 +171,10 @@ function setupExpressApp(app) {
app.use(middleware.addHeaders);
app.use(middleware.processRender);
auth.initialize(app, middleware);
const als = require('./als');
app.use((req, res, next) => {
als.run({ uid: req.uid }, next);
});
app.use(middleware.autoLocale); // must be added after auth middlewares are added
const toobusy = require('toobusy-js');

View File

@@ -334,7 +334,7 @@ describe('Sorted Set methods', () => {
});
it('should work with big arrays (length > 100) ', async function () {
this.timeout(50000);
this.timeout(100000);
const keys = [];
for (let i = 0; i < 400; i++) {
/* eslint-disable no-await-in-loop */

View File

@@ -359,7 +359,7 @@ describe('Notifications', () => {
assert(nids.includes(nid));
done();
});
}, 1500);
}, 3000);
});
});
});