From 785ab53f8c88c8a9079702d124d5b028f8b45d05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marina=20L=C3=B3pez?= Date: Tue, 16 Jun 2026 15:21:13 +0200 Subject: [PATCH] :sparkles: Cancel subscription when user deletes account --- backend/src/app/nitrate.clj | 17 +++-------------- backend/src/app/rpc/commands/profile.clj | 7 ++++--- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/backend/src/app/nitrate.clj b/backend/src/app/nitrate.clj index 03eb5a4131..d4343b8195 100644 --- a/backend/src/app/nitrate.clj +++ b/backend/src/app/nitrate.clj @@ -301,14 +301,14 @@ org)) orgs))) -(defn- delete-owned-orgs-api +(defn- cleanup-deleted-penpot-user-api [cfg {:keys [profile-id] :as params}] (let [baseuri (cf/get :nitrate-backend-uri)] (request-to-nitrate cfg :post (str baseuri "/api/users/" profile-id - "/delete-owned-organizations") + "/cleanup-after-deletion") nil params))) (defn- set-team-org-api @@ -352,16 +352,6 @@ "/remove-user") nil params))) -(defn- remove-profile-from-all-orgs-api - [cfg {:keys [profile-id] :as params}] - (let [baseuri (cf/get :nitrate-backend-uri)] - (request-to-nitrate cfg :post - (str baseuri - "/api/users/" - profile-id - "/remove-organizations") - nil params))) - (defn- remove-team-from-org-api [cfg {:keys [team-id organization-id] :as params}] (let [baseuri (cf/get :nitrate-backend-uri) @@ -469,10 +459,9 @@ :get-owned-orgs (partial get-owned-orgs-api cfg) :get-owned-orgs-summary (partial get-owned-orgs-summary-api cfg) :get-org-members (partial get-org-members-api cfg) - :delete-owned-orgs (partial delete-owned-orgs-api cfg) + :cleanup-deleted-penpot-user (partial cleanup-deleted-penpot-user-api cfg) :add-profile-to-org (partial add-profile-to-org-api cfg) :remove-profile-from-org (partial remove-profile-from-org-api cfg) - :remove-profile-from-all-orgs (partial remove-profile-from-all-orgs-api cfg) :get-org-permissions (partial get-org-permissions-api cfg) :delete-team (partial delete-team-api cfg) :remove-team-from-org (partial remove-team-from-org-api cfg) diff --git a/backend/src/app/rpc/commands/profile.clj b/backend/src/app/rpc/commands/profile.clj index ba1af4a362..ab20bafdbf 100644 --- a/backend/src/app/rpc/commands/profile.clj +++ b/backend/src/app/rpc/commands/profile.clj @@ -496,10 +496,11 @@ ;; (during delete-owned-orgs) and ::notify-organization-deletion. ;; Both preserve org teams unchanged and only prefix or delete ;; imported "Your Penpot" teams according to whether they still have files. + ;; Let Nitrate clean up the data associated with the deleted Penpot user: + ;; owned organizations, remaining memberships, and subscription cancellation. (when (contains? cf/flags :nitrate) - (nitrate/call cfg :delete-owned-orgs {:profile-id profile-id}) - ;; Remove the user from any remaining org memberships. - (nitrate/call cfg :remove-profile-from-all-orgs {:profile-id profile-id})) + (nitrate/call cfg :cleanup-deleted-penpot-user + {:profile-id profile-id})) ;; Schedule cascade deletion to a worker (wrk/submit! {::db/conn conn