From 29b86b3276b341922d0b9ae894eb6eee708ee399 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 Mar 2022 15:58:29 -0400 Subject: [PATCH] refactor: :trollface: --- src/socket.io/posts.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/socket.io/posts.js b/src/socket.io/posts.js index 05341be0ae..6b257ca525 100644 --- a/src/socket.io/posts.js +++ b/src/socket.io/posts.js @@ -122,22 +122,23 @@ SocketPosts.reject = async function (socket, data) { }; async function logQueueEvent(socket, result, type) { - await events.log({ + const eventData = { type: `post-queue-${result.type}-${type}`, uid: socket.uid, ip: socket.ip, content: result.data.content, targetUid: result.uid, - ...(result.type === 'topic' ? - { - cid: result.data.cid, - title: result.data.title, - } : - { - tid: result.data.tid, - }), - ...(result.pid ? { pid: result.pid } : {}), - }); + }; + if (result.type === 'topic') { + eventData.cid = result.data.cid; + eventData.title = result.data.title; + } else { + eventData.tid = result.data.tid; + } + if (result.pid) { + eventData.pid = result.pid; + } + await events.log(eventData); } SocketPosts.notify = async function (socket, data) {