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",