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/17796

Daniel587f8bcd04bf
diff --git a/kernel/api/block.go b/kernel/api/block.go
index 84f9bbda95..93860bf1d7 100644
--- a/kernel/api/block.go
+++ b/kernel/api/block.go
@@ -300,11 +300,28 @@ func setBlockReminder(c *gin.Context) {
id := arg["id"].(string)
timed := arg["timed"].(string) // yyyyMMddHHmmss
- var content string
- if nil != arg["content"] {
- content = arg["content"].(string)
+ err := model.SetBlockReminder(id, timed)
+ if err != nil {
+ ret.Code = -1
+ ret.Msg = err.Error()
+ ret.Data = map[string]any{"closeTimeout": 7000}
+ return
+ }
+}
+
+func setCloudReminder(c *gin.Context) {
+ ret := gulu.Ret.NewResult()
+ defer c.JSON(http.StatusOK, ret)
+
+ arg, ok := util.JsonArg(c, ret)
+ if !ok {
+ return
}
- err := model.SetBlockReminder(id, content, timed)
+
+ id := arg["id"].(string)
+ timed := arg["timed"].(string) // yyyyMMddHHmmss
+ content := arg["content"].(string)
+ err := model.SetCloudReminder(id, content, timed)
if err != nil {
ret.Code = -1
ret.Msg = err.Error()
diff --git a/kernel/api/router.go b/kernel/api/router.go
index 086cd54167..04933a150a 100644
--- a/kernel/api/router.go
+++ b/kernel/api/router.go
@@ -284,6 +284,7 @@ func ServeAPI(ginServer *gin.Engine) {
ginServer.Handle("POST", "/api/attr/batchGetBlockAttrs", model.CheckAuth, batchGetBlockAttrs)
ginServer.Handle("POST", "/api/cloud/getCloudSpace", model.CheckAuth, model.CheckAdminRole, getCloudSpace)
+ ginServer.Handle("POST", "/api/cloud/setCloudReminder", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, setCloudReminder)
ginServer.Handle("POST", "/api/sync/setSyncEnable", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, setSyncEnable)
ginServer.Handle("POST", "/api/sync/setSyncInterval", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, setSyncInterval)
diff --git a/kernel/model/blockial.go b/kernel/model/blockial.go
index cd069de79d..246c04b216 100644
--- a/kernel/model/blockial.go
+++ b/kernel/model/blockial.go
@@ -35,7 +35,40 @@ import (
"github.com/siyuan-note/siyuan/kernel/util"
)
-func SetBlockReminder(id, customContent, timed string) (err error) {
+func SetCloudReminder(id, content, timed string) (err error) {
+ if !IsSubscriber() {
+ if "ios" == util.Container {
+ return errors.New(Conf.Language(122))
+ }
+ return errors.New(Conf.Language(29))
+ }
+
+ var timedMills int64
+ if "0" != timed {
+ t, e := dateparse.ParseIn(timed, time.Now().Location())
+ if nil != e {
+ return e
+ }
+ timedMills = t.UnixMilli()
+ }
+
+ content = strings.TrimSpace(content)
+ err = SetCloudBlockReminder(id, content, timedMills)
+ if err != nil {
+ return
+ }
+
+ if "0" == timed {
+ util.PushMsg(fmt.Sprintf(Conf.Language(109), content), 3000)
+ } else {
+ util.PushMsg(fmt.Sprintf(Conf.Language(101), time.UnixMilli(timedMills).Format("2006-01-02 15:04")), 5000)
+ }
+
+ IncSync()
+ return
+}
+
+func SetBlockReminder(id, timed string) (err error) {
if !IsSubscriber() {
if "ios" == util.Container {
return errors.New(Conf.Language(122))
@@ -69,15 +102,9 @@ func SetBlockReminder(id, customContent, timed string) (err error) {
node = treenode.FirstLeafBlock(node)
}
- var content string
- customContent = strings.TrimSpace(customContent)
- if "" == customContent {
- content = sql.NodeStaticContent(node, nil, false, false, false)
- content = gulu.Str.SubStr(content, 128)
- content = strings.ReplaceAll(content, editor.Zwsp, "")
- } else {
- content = customContent
- }
+ content := sql.NodeStaticContent(node, nil, false, false, false)
+ content = gulu.Str.SubStr(content, 128)
+ content = strings.ReplaceAll(content, editor.Zwsp, "")
err = SetCloudBlockReminder(id, content, timedMills)
if err != nil {
return