Skip to content

Commit

Permalink
Make invited PS users are added to the PS channel
Browse files Browse the repository at this point in the history
[Re #1611]
  • Loading branch information
lucassousaf committed Oct 23, 2023
1 parent 6be6995 commit 59b0ea4
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
8 changes: 6 additions & 2 deletions backend/src/gpml/service/chat.clj
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,12 @@
(tht/thread-transactions logger transactions context)))

(defn update-user-account
[{:keys [chat-adapter]} user-id updates]
(chat/update-user-account chat-adapter user-id updates))
[{:keys [chat-adapter]} chat-account-id updates]
(chat/update-user-account chat-adapter chat-account-id updates))

(defn delete-user-account
[{:keys [chat-adapter]} chat-account-id opts]
(chat/delete-user-account chat-adapter chat-account-id opts))

(defn get-user-joined-channels
[{:keys [chat-adapter]} chat-account-id]
Expand Down
33 changes: 32 additions & 1 deletion backend/src/gpml/service/plastic_strategy.clj
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,18 @@
:success? false
:reason (:reason result)
:error-details (:error-details result))))))}
{:txn-fn
(fn get-plastic-strategy
[{:keys [ps-team-member] :as context}]
(let [search-opts {:filters {:ids [(:plastic-strategy-id ps-team-member)]}}
result (db.ps/get-plastic-strategy (:spec db)
search-opts)]
(if (:success? result)
(assoc context :plastic-strategy (:plastic-strategy result))
(assoc context
:success? false
:reason :failed-to-get-plastic-strategy
:error-details {:result result}))))}
{:txn-fn
(fn assign-plastic-strategy-rbac-role
[{:keys [ps-team-member] :as context}]
Expand Down Expand Up @@ -190,9 +202,28 @@
[{:keys [ps-team-member] :as context}]
(let [result (srv.chat/create-user-account config (:id ps-team-member))]
(if (:success? result)
context
(assoc context :chat-account-id (get-in result [:chat-user-account :id]))
(assoc context
:reason :failed-to-create-chat-account
:error-details {:result result}))))
:rollback-fn
(fn rollback-create-chat-account
[{:keys [chat-account-id] :as context}]
(let [result (srv.chat/delete-user-account config chat-account-id {})]
(when-not (:success? result)
(log logger :error :failed-to-rollback-create-chat-account {:result result})))
context)}
{:txn-fn
(fn add-user-to-ps-channel
[{:keys [plastic-strategy chat-account-id] :as context}]
(let [result (srv.chat/add-user-to-private-channel config
chat-account-id
(:chat-channel-id plastic-strategy))]
(if (:success? result)
context
(assoc context
:success? false
:reason :failed-to-add-user-to-ps-channel
:error-details {:result result}))))}]
context {:success? true
:user-id user-id}]
Expand Down

0 comments on commit 59b0ea4

Please sign in to comment.