mirror of
https://github.com/penpot/penpot.git
synced 2026-04-25 11:18:36 +00:00
✨ Add the ability to upload organization profile image
* ✨ Upload org logo * 📎 Code review * 📎 Code review 2 * 📎 Code review 3
This commit is contained in:
parent
534701f04f
commit
b67394199b
@ -115,7 +115,8 @@
|
||||
[:slug ::sm/text]
|
||||
[:is-your-penpot :boolean]
|
||||
[:owner-id ::sm/uuid]
|
||||
[:avatar-bg-url [::sm/text]]])
|
||||
[:avatar-bg-url [::sm/text]]
|
||||
[:logo-id {:optional true} [:maybe ::sm/uuid]]])
|
||||
|
||||
(def ^:private schema:org-summary
|
||||
[:map
|
||||
@ -393,6 +394,8 @@
|
||||
:organization-slug (:slug org)
|
||||
:organization-owner-id (:owner-id org)
|
||||
:organization-avatar-bg-url (:avatar-bg-url org)
|
||||
:organization-custom-photo (when-let [logo-id (:logo-id org)]
|
||||
(str (cf/get :public-uri) "/assets/by-id/" logo-id))
|
||||
:is-default (or (:is-default team) (true? (:is-your-penpot org))))
|
||||
team))
|
||||
(catch Throwable cause
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
[app.common.types.team :refer [schema:team]]
|
||||
[app.config :as cf]
|
||||
[app.db :as db]
|
||||
[app.media :as media]
|
||||
[app.rpc :as-alias rpc]
|
||||
[app.rpc.commands.files :as files]
|
||||
[app.rpc.commands.nitrate :as cnit]
|
||||
@ -23,6 +24,7 @@
|
||||
[app.rpc.commands.teams-invitations :as ti]
|
||||
[app.rpc.doc :as doc]
|
||||
[app.rpc.notifications :as notifications]
|
||||
[app.storage :as sto]
|
||||
[app.util.services :as sv]))
|
||||
|
||||
|
||||
@ -81,6 +83,37 @@
|
||||
(->> (db/exec! cfg [sql:get-teams current-user-id])
|
||||
(map #(select-keys % [:id :name])))))
|
||||
|
||||
;; ---- API: upload-org-logo
|
||||
|
||||
(def ^:private schema:upload-org-logo
|
||||
[:map
|
||||
[:content media/schema:upload]
|
||||
[:organization-id ::sm/uuid]
|
||||
[:previous-id {:optional true} ::sm/uuid]])
|
||||
|
||||
(def ^:private schema:upload-org-logo-result
|
||||
[:map [:id ::sm/uuid]])
|
||||
|
||||
(sv/defmethod ::upload-org-logo
|
||||
"Store an organization logo in penpot storage and return its ID.
|
||||
Accepts an optional previous-id to mark the old logo for garbage
|
||||
collection when replacing an existing one."
|
||||
{::doc/added "2.16"
|
||||
::sm/params schema:upload-org-logo
|
||||
::sm/result schema:upload-org-logo-result}
|
||||
[{:keys [::sto/storage]} {:keys [content organization-id previous-id]}]
|
||||
(when previous-id
|
||||
(sto/touch-object! storage previous-id))
|
||||
(let [hash (sto/calculate-hash (:path content))
|
||||
data (-> (sto/content (:path content))
|
||||
(sto/wrap-with-hash hash))
|
||||
obj (sto/put-object! storage {::sto/content data
|
||||
::sto/deduplicate? true
|
||||
:bucket "organization"
|
||||
:content-type (:mtype content)
|
||||
:organization-id organization-id})]
|
||||
{:id (:id obj)}))
|
||||
|
||||
;; ---- API: notify-team-change
|
||||
|
||||
(def ^:private schema:notify-team-change
|
||||
|
||||
@ -44,6 +44,7 @@
|
||||
"file-object-thumbnail"
|
||||
"file-thumbnail"
|
||||
"profile"
|
||||
"organization"
|
||||
"tempfile"
|
||||
"file-data"
|
||||
"file-data-fragment"
|
||||
|
||||
@ -166,6 +166,7 @@
|
||||
"profile" (process-objects! conn has-profile-refs? bucket objects)
|
||||
"file-data" (process-objects! conn has-file-data-refs? bucket objects)
|
||||
"tempfile" (process-objects! conn (constantly false) bucket objects)
|
||||
"organization" (process-objects! conn (constantly false) bucket objects)
|
||||
(ex/raise :type :internal
|
||||
:code :unexpected-unknown-reference
|
||||
:hint (dm/fmt "unknown reference '%'" bucket))))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user