mirror of
https://github.com/penpot/penpot.git
synced 2026-05-09 18:18:07 +00:00
41 lines
1.4 KiB
Clojure
41 lines
1.4 KiB
Clojure
;; This Source Code Form is subject to the terms of the Mozilla Public
|
|
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
;;
|
|
;; Copyright (c) KALEIDOS INC
|
|
|
|
(ns app.srepl.binfile
|
|
(:require
|
|
[app.binfile.v2 :as binfile.v2]
|
|
[app.db :as db]
|
|
[app.main :as main]
|
|
[cuerdas.core :as str]))
|
|
|
|
(defn export-team!
|
|
[team-id]
|
|
(let [team-id (if (string? team-id)
|
|
(parse-uuid team-id)
|
|
team-id)]
|
|
(binfile.v2/export-team! main/system team-id)))
|
|
|
|
(defn import-team!
|
|
[path & {:keys [owner rollback?] :or {rollback? true}}]
|
|
(db/tx-run! (assoc main/system ::db/rollback rollback?)
|
|
(fn [cfg]
|
|
(let [team (binfile.v2/import-team! cfg path)
|
|
owner (cond
|
|
(string? owner)
|
|
(db/get* cfg :profile {:email (str/lower owner)})
|
|
(uuid? owner)
|
|
(db/get* cfg :profile {:id owner}))]
|
|
|
|
(when owner
|
|
(db/insert! cfg :team-profile-rel
|
|
{:team-id (:id team)
|
|
:profile-id (:id owner)
|
|
:is-admin true
|
|
:is-owner true
|
|
:can-edit true}))
|
|
|
|
team))))
|