Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: 云端收集箱文档内添加刷新按钮 https://github.com/siyuan-note/siyuan/issues/6306

Liang Ding487cca891b4b
diff --git a/kernel/api/inbox.go b/kernel/api/inbox.go
index 78d40f8b37..81b42c6019 100644
--- a/kernel/api/inbox.go
+++ b/kernel/api/inbox.go
@@ -48,6 +48,25 @@ func removeShorthands(c *gin.Context) {
}
}
+func getShorthand(c *gin.Context) {
+ ret := gulu.Ret.NewResult()
+ defer c.JSON(http.StatusOK, ret)
+
+ arg, ok := util.JsonArg(c, ret)
+ if !ok {
+ return
+ }
+
+ id := arg["id"].(string)
+ data, err := model.GetCloudShorthand(id)
+ if nil != err {
+ ret.Code = 1
+ ret.Msg = err.Error()
+ return
+ }
+ ret.Data = data
+}
+
func getShorthands(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
diff --git a/kernel/api/router.go b/kernel/api/router.go
index 5c7db0d5b8..fff2d28cc7 100644
--- a/kernel/api/router.go
+++ b/kernel/api/router.go
@@ -182,6 +182,7 @@ func ServeAPI(ginServer *gin.Engine) {
ginServer.Handle("POST", "/api/sync/getBootSync", model.CheckAuth, getBootSync)
ginServer.Handle("POST", "/api/inbox/getShorthands", model.CheckAuth, getShorthands)
+ ginServer.Handle("POST", "/api/inbox/getShorthand", model.CheckAuth, getShorthand)
ginServer.Handle("POST", "/api/inbox/removeShorthands", model.CheckAuth, removeShorthands)
ginServer.Handle("POST", "/api/extension/copy", model.CheckAuth, extensionCopy)
diff --git a/kernel/model/liandi.go b/kernel/model/liandi.go
index 6f1031c384..d316982918 100644
--- a/kernel/model/liandi.go
+++ b/kernel/model/liandi.go
@@ -357,6 +357,37 @@ func RemoveCloudShorthands(ids []string) (err error) {
return
}
+func GetCloudShorthand(id string) (result map[string]interface{}, err error) {
+ result = map[string]interface{}{}
+ request := httpclient.NewCloudRequest()
+ resp, err := request.
+ SetResult(&result).
+ SetCookies(&http.Cookie{Name: "symphony", Value: Conf.User.UserToken}).
+ Post(util.AliyunServer + "/apis/siyuan/inbox/getCloudShorthand?id=" + id)
+ if nil != err {
+ logging.LogErrorf("get cloud shorthand failed: %s", err)
+ err = ErrFailedToConnectCloudServer
+ return
+ }
+
+ if 401 == resp.StatusCode {
+ err = errors.New(Conf.Language(31))
+ return
+ }
+
+ code := result["code"].(float64)
+ if 0 != code {
+ logging.LogErrorf("get cloud shorthand failed: %s", result["msg"])
+ err = errors.New(result["msg"].(string))
+ return
+ }
+ shorthand := result["data"].(map[string]interface{})
+ t, _ := strconv.ParseInt(id, 10, 64)
+ hCreated := util.Millisecond2Time(t)
+ shorthand["hCreated"] = hCreated.Format("2006-01-02 15:04")
+ return
+}
+
func GetCloudShorthands(page int) (result map[string]interface{}, err error) {
result = map[string]interface{}{}
request := httpclient.NewCloudRequest()