refactor: remove sockets.reqFromSocket

This commit is contained in:
Barış Soner Uşaklı
2020-10-16 21:05:00 -04:00
parent 8fd3c04480
commit bc880ee0ca
7 changed files with 41 additions and 67 deletions

View File

@@ -3,6 +3,7 @@
const posts = require('../../posts');
const user = require('../../user');
const privileges = require('../../privileges');
const apiHelpers = require('../../api/helpers');
const websockets = require('..');
module.exports = function (SocketPosts) {
@@ -55,7 +56,7 @@ module.exports = function (SocketPosts) {
throw new Error('[[error:no-privileges]]');
}
const edit = await posts.diffs.restore(data.pid, data.since, socket.uid, websockets.reqFromSocket(socket));
const edit = await posts.diffs.restore(data.pid, data.since, socket.uid, apiHelpers.buildReqObject(socket));
websockets.in('topic_' + edit.topic.tid).emit('event:post_edited', edit);
};
};

View File

@@ -8,6 +8,7 @@ const groups = require('../../groups');
const events = require('../../events');
const meta = require('../../meta');
const utils = require('../../utils');
const apiHelpers = require('../../api/helpers');
const websockets = require('../index');
module.exports = function (SocketPosts) {
@@ -34,7 +35,7 @@ module.exports = function (SocketPosts) {
}
data.uid = socket.uid;
data.req = websockets.reqFromSocket(socket);
data.req = apiHelpers.buildReqObject(socket);
const editResult = await posts.edit(data);
if (editResult.topic.renamed) {