fix: #9395, pass all data from client to Topics.reply (#9396)

* fix: #9395, pass all data from client to Topics.reply

so plugins can set custom fields
refactor and use setDefaultPostData

* fix: circular json error

* refactor: change params
This commit is contained in:
Barış Soner Uşaklı
2021-03-15 15:34:05 -04:00
committed by GitHub
parent 33fbfdfe40
commit a8f7b24452
5 changed files with 15 additions and 23 deletions

View File

@@ -10,6 +10,13 @@ const socketHelpers = require('../socket.io/helpers');
const websockets = require('../socket.io');
const events = require('../events');
exports.setDefaultPostData = function (reqOrSocket, data) {
data.uid = reqOrSocket.uid;
data.req = exports.buildReqObject(reqOrSocket, { ...data });
data.timestamp = Date.now();
data.fromQueue = false;
};
// creates a slimmed down version of the request object
exports.buildReqObject = (req, payload) => {
req = req || {};