Browse Source

enhance(rtc): grant access api support emails (2)

rcmerci 2 years ago
parent
commit
850ed26411

+ 2 - 1
src/main/frontend/db/rtc/const.cljs

@@ -152,7 +152,8 @@
       [:req-id :string]
       [:action :string]
       [:graph-uuid :uuid]
-      [:target-user-uuids [:sequential :uuid]]]]
+      [:target-user-uuids {:optional true} [:sequential :uuid]]
+      [:target-user-emails {:optional true} [:sequential :string]]]]
     ["query-block-content-versions"
      [:map
       [:req-id :string]

+ 8 - 8
src/main/frontend/db/rtc/core.cljs

@@ -639,15 +639,15 @@
   [state graph-uuid & {:keys [target-user-uuids target-user-emails]}]
   (go
     (let [r (with-sub-data-from-ws state
-              (<! (ws/<send! state {:req-id (get-req-id)
-                                    :action "grant-access"
-                                    :graph-uuid graph-uuid
-                                    :target-user-uuids target-user-uuids
-                                    :target-user-emails target-user-emails}))
-
+              (<! (ws/<send! state (cond-> {:req-id (get-req-id)
+                                            :action "grant-access"
+                                            :graph-uuid graph-uuid}
+                                     target-user-uuids (assoc :target-user-uuids target-user-uuids)
+                                     target-user-emails (assoc :target-user-emails target-user-emails))))
               (<! (get-result-ch)))]
-      (when-let [ex-message (:ex-message r)]
-        (prn ::<grant-graph-access-to-others ex-message (:ex-data r))))))
+      (if-let [ex-message (:ex-message r)]
+        (prn ::<grant-graph-access-to-others ex-message (:ex-data r))
+        (prn ::<grant-graph-access-to-others :succ)))))
 
 (defn <toggle-auto-push-client-ops
   [state]

+ 2 - 2
src/main/frontend/db/rtc/debug_ui.cljs

@@ -146,8 +146,8 @@
                                     (when-let [graph-uuid @(::graph-uuid state)]
                                       (<! (rtc-core/<grant-graph-access-to-others
                                            s graph-uuid
-                                           :target-user-uuids [user-uuid]
-                                           :target-user-emails [user-email]))))))})
+                                           :target-user-uuids (some-> user-uuid vector)
+                                           :target-user-emails (some-> user-email vector)))))))})
 
         [:input.form-input.my-2
          {:on-change (fn [e] (reset! (::grant-access-to-user state) (util/evalue e)))