From 06c285bad21e4344fca7397ec618f5655042c65b Mon Sep 17 00:00:00 2001 From: Saumya Pandey Date: Fri, 12 Mar 2021 02:27:34 +0530 Subject: [PATCH] Add collections.move event --- server/api/collections.js | 4 +++- server/events.js | 8 ++++++++ server/models/Event.js | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/server/api/collections.js b/server/api/collections.js index 7088343966..2750376530 100644 --- a/server/api/collections.js +++ b/server/api/collections.js @@ -658,6 +658,8 @@ router.post("collections.move", auth(), async (ctx) => { const collection = await Collection.findByPk(id); authorize(user, "move", collection); + const previousIndex = collection.index; + await collection.update({ index }); removeIndexCollisions(user.teamId); @@ -667,7 +669,7 @@ router.post("collections.move", auth(), async (ctx) => { collectionId: collection.id, teamId: collection.teamId, actorId: user.id, - data: { name: collection.name }, + data: { previousIndex, currentIndex: collection.index }, ip: ctx.request.ip, }); diff --git a/server/events.js b/server/events.js index a3d72d9e91..e152e3e4ef 100644 --- a/server/events.js +++ b/server/events.js @@ -135,6 +135,14 @@ export type CollectionEvent = actorId: string, data: { name: string, groupId: string }, ip: string, + } + | { + name: "collections.move", + collectionId: string, + teamId: string, + actorId: string, + data: { previousIndex: string, currentIndex: string }, + ip: string, }; export type GroupEvent = diff --git a/server/models/Event.js b/server/models/Event.js index cefc857ac1..353dc1dd4a 100644 --- a/server/models/Event.js +++ b/server/models/Event.js @@ -73,6 +73,7 @@ Event.AUDIT_EVENTS = [ "api_keys.delete", "collections.create", "collections.update", + "collections.move", "collections.add_user", "collections.remove_user", "collections.add_group",