0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-02 12:28:54 -05:00

Increase default deletion delay.

This commit is contained in:
Andrey Antukh 2021-02-10 16:48:13 +01:00 committed by Alonso Torres
parent d6f3efb358
commit 2e438385f3
8 changed files with 29 additions and 25 deletions

View file

@ -245,5 +245,5 @@
(def config (read-config env)) (def config (read-config env))
(def test-config (read-test-config env)) (def test-config (read-test-config env))
(def default-deletion-delay (def deletion-delay
(dt/duration {:hours 48})) (dt/duration {:days 7}))

View file

@ -52,7 +52,7 @@
;; Schedule deletion of the demo profile ;; Schedule deletion of the demo profile
(tasks/submit! conn {:name "delete-profile" (tasks/submit! conn {:name "delete-profile"
:delay cfg/default-deletion-delay :delay cfg/deletion-delay
:props {:profile-id id}}) :props {:profile-id id}})
{:email email {:email email

View file

@ -129,7 +129,7 @@
;; Schedule object deletion ;; Schedule object deletion
(tasks/submit! conn {:name "delete-object" (tasks/submit! conn {:name "delete-object"
:delay cfg/default-deletion-delay :delay cfg/deletion-delay
:props {:id id :type :file}}) :props {:id id :type :file}})
(mark-file-deleted conn params))) (mark-file-deleted conn params)))

View file

@ -472,7 +472,7 @@
;; Schedule a complete deletion of profile ;; Schedule a complete deletion of profile
(tasks/submit! conn {:name "delete-profile" (tasks/submit! conn {:name "delete-profile"
:delay (dt/duration {:hours 48}) :delay cfg/deletion-delay
:props {:profile-id profile-id}}) :props {:profile-id profile-id}})
(db/update! conn :profile (db/update! conn :profile

View file

@ -16,6 +16,7 @@
[app.rpc.queries.projects :as proj] [app.rpc.queries.projects :as proj]
[app.tasks :as tasks] [app.tasks :as tasks]
[app.util.services :as sv] [app.util.services :as sv]
[app.util.time :as dt]
[clojure.spec.alpha :as s])) [clojure.spec.alpha :as s]))
;; --- Helpers & Specs ;; --- Helpers & Specs
@ -113,8 +114,6 @@
;; --- Mutation: Delete Project ;; --- Mutation: Delete Project
(declare mark-project-deleted)
(s/def ::delete-project (s/def ::delete-project
(s/keys :req-un [::id ::profile-id])) (s/keys :req-un [::id ::profile-id]))
@ -125,18 +124,10 @@
;; Schedule object deletion ;; Schedule object deletion
(tasks/submit! conn {:name "delete-object" (tasks/submit! conn {:name "delete-object"
:delay cfg/default-deletion-delay :delay cfg/deletion-delay
:props {:id id :type :project}}) :props {:id id :type :project}})
(mark-project-deleted conn params))) (db/update! conn :project
{:deleted-at (dt/now)}
(def ^:private sql:mark-project-deleted {:id id})
"update project nil))
set deleted_at = clock_timestamp()
where id = ?
returning id")
(defn mark-project-deleted
[conn {:keys [id] :as params}]
(db/exec! conn [sql:mark-project-deleted id])
nil)

View file

@ -13,6 +13,7 @@
[app.common.exceptions :as ex] [app.common.exceptions :as ex]
[app.common.spec :as us] [app.common.spec :as us]
[app.common.uuid :as uuid] [app.common.uuid :as uuid]
[app.config :as cfg]
[app.db :as db] [app.db :as db]
[app.emails :as emails] [app.emails :as emails]
[app.media :as media] [app.media :as media]
@ -20,6 +21,7 @@
[app.rpc.queries.profile :as profile] [app.rpc.queries.profile :as profile]
[app.rpc.queries.teams :as teams] [app.rpc.queries.teams :as teams]
[app.storage :as sto] [app.storage :as sto]
[app.tasks :as tasks]
[app.util.services :as sv] [app.util.services :as sv]
[app.util.time :as dt] [app.util.time :as dt]
[clojure.spec.alpha :as s] [clojure.spec.alpha :as s]
@ -133,7 +135,14 @@
(ex/raise :type :validation (ex/raise :type :validation
:code :only-owner-can-delete-team)) :code :only-owner-can-delete-team))
(db/delete! conn :team {:id id}) ;; Schedule object deletion
(tasks/submit! conn {:name "delete-object"
:delay cfg/deletion-delay
:props {:id id :type :team}})
(db/update! conn :team
{:deleted-at (dt/now)}
{:id id})
nil))) nil)))

View file

@ -7,8 +7,6 @@
;; ;;
;; Copyright (c) 2020 UXBOX Labs SL ;; Copyright (c) 2020 UXBOX Labs SL
;; TODO: session
(ns app.rpc.mutations.verify-token (ns app.rpc.mutations.verify-token
(:require (:require
[app.common.exceptions :as ex] [app.common.exceptions :as ex]

View file

@ -42,11 +42,12 @@
(db/with-atomic [conn pool] (db/with-atomic [conn pool]
(handle-deletion conn props))) (handle-deletion conn props)))
(defmulti handle-deletion (fn [_ props] (:type props))) (defmulti handle-deletion
(fn [_ props] (:type props)))
(defmethod handle-deletion :default (defmethod handle-deletion :default
[_conn {:keys [type]}] [_conn {:keys [type]}]
(log/warn "no handler found for" type)) (log/warnf "no handler found for %s" type))
(defmethod handle-deletion :file (defmethod handle-deletion :file
[conn {:keys [id] :as props}] [conn {:keys [id] :as props}]
@ -57,3 +58,8 @@
[conn {:keys [id] :as props}] [conn {:keys [id] :as props}]
(let [sql "delete from project where id=? and deleted_at is not null"] (let [sql "delete from project where id=? and deleted_at is not null"]
(db/exec-one! conn [sql id]))) (db/exec-one! conn [sql id])))
(defmethod handle-deletion :team
[conn {:keys [id] :as props}]
(let [sql "delete from team where id=? and deleted_at is not null"]
(db/exec-one! conn [sql id])))