Просмотр исходного кода

enhance(sync): add IRemoteControlAPI

rcmerci 3 лет назад
Родитель
Сommit
a0f072b974
1 измененных файлов с 20 добавлено и 0 удалено
  1. 20 0
      src/main/frontend/fs/sync.cljs

+ 20 - 0
src/main/frontend/fs/sync.cljs

@@ -728,6 +728,12 @@
   (<get-graph-encrypt-keys [this graph-uuid])
   (<upload-graph-encrypt-keys [this graph-uuid public-key encrypted-private-key]))
 
+
+(defprotocol IRemoteControlAPI
+  "api functions provided for outside the sync process"
+  (<delete-remote-files-control [this graph-uuid filepaths])
+  )
+
 (defprotocol IToken
   (<get-token [this]))
 
@@ -1360,6 +1366,20 @@
                                                       :public-key            public-key
                                                       :encrypted-private-key encrypted-private-key})))))
 
+(extend-type RemoteAPI
+  IRemoteControlAPI
+  (<delete-remote-files-control [this graph-uuid filepaths]
+    (user/<wrap-ensure-id&access-token
+     (let [current-txid (:TXId (<! (<get-remote-graph this nil graph-uuid)))
+           files (<! (<encrypt-fnames rsapi graph-uuid filepaths))]
+       (<! (.<request this "delete_files" {:GraphUUID graph-uuid :TXId current-txid :Files files}))))))
+
+(comment
+  (declare remoteapi)
+  (<delete-remote-files-control remoteapi (second @graphs-txid) ["pages/aa.md"])
+
+  )
+
 (def remoteapi (->RemoteAPI nil))