From 6b5ee2401069703b0f254a1d795ac561699d837a Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Tue, 14 Jun 2022 09:08:06 +0200 Subject: [PATCH] :sparkles: Add team and project ids to update-file mutation for audit log --- backend/src/app/rpc/mutations/files.clj | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/backend/src/app/rpc/mutations/files.clj b/backend/src/app/rpc/mutations/files.clj index 796d0dd5aa..7bc10d6562 100644 --- a/backend/src/app/rpc/mutations/files.clj +++ b/backend/src/app/rpc/mutations/files.clj @@ -13,6 +13,7 @@ [app.common.uuid :as uuid] [app.config :as cf] [app.db :as db] + [app.loggers.audit :as audit] [app.metrics :as mtx] [app.rpc.permissions :as perms] [app.rpc.queries.files :as files] @@ -279,10 +280,14 @@ [{:keys [pool] :as cfg} {:keys [id profile-id] :as params}] (db/with-atomic [conn pool] (db/xact-lock! conn id) - (let [{:keys [id] :as file} (db/get-by-id conn :file id {:for-key-share true})] + (let [{:keys [id] :as file} (db/get-by-id conn :file id {:for-key-share true}) + team-id (retrieve-team-id conn (:project-id file))] (files/check-edition-permissions! conn profile-id id) - (update-file (assoc cfg :conn conn) - (assoc params :file file))))) + (with-meta + (update-file (assoc cfg :conn conn) + (assoc params :file file)) + {::audit/props {:project-id (:project-id file) + :team-id team-id}})))) (defn- take-snapshot? "Defines the rule when file `data` snapshot should be saved."