summaryrefslogtreecommitdiffstats
path: root/server/lib/log.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/log.js')
-rw-r--r--server/lib/log.js13
1 files changed, 9 insertions, 4 deletions
diff --git a/server/lib/log.js b/server/lib/log.js
index fede874..782c34f 100644
--- a/server/lib/log.js
+++ b/server/lib/log.js
@@ -2,7 +2,7 @@
const path = require('path')
var db = require(path.join(__appdir, 'lib', 'sequelize'))
-async function log ({ category, description, groupId, clientId, userId }) {
+async function log ({ category, description, clientId, userId, groupId, group, client, user }) {
const entry = db.log.build({
category,
description,
@@ -11,9 +11,14 @@ async function log ({ category, description, groupId, clientId, userId }) {
clientId,
userId
})
- if (groupId) entry.groupSnapshot = JSON.stringify(await db.group.findOne({ where: { id: groupId } }))
- if (clientId) entry.clientSnapshot = JSON.stringify(await db.client.findOne({ where: { id: clientId } }))
- if (userId) entry.userSnapshot = JSON.stringify(await db.user.findOne({ where: { id: userId } }))
+
+ if (group) entry.groupSnapshot = JSON.stringify(group)
+ else if (groupId) entry.groupSnapshot = JSON.stringify(await db.group.findOne({ where: { id: groupId } }))
+ if (client) entry.clientSnapshot = JSON.stringify(client)
+ else if (clientId) entry.clientSnapshot = JSON.stringify(await db.client.findOne({ where: { id: clientId } }))
+ if (user) entry.userSnapshot = JSON.stringify(user)
+ else if (userId) entry.userSnapshot = JSON.stringify(await db.user.findOne({ where: { id: userId } }))
+
await entry.save()
return entry
}