An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Add internal kernel API `/api/riff/batchSetRiffCardsDueTime` https://github.com/siyuan-note/siyuan/issues/10423
Daniel285eb12b484f
diff --git a/kernel/api/riff.go b/kernel/api/riff.goindex 4278d65431..53b398b2dd 100644--- a/kernel/api/riff.go+++ b/kernel/api/riff.go@@ -27,6 +27,31 @@ import ("github.com/siyuan-note/siyuan/kernel/util")+func batchSetRiffCardsDueTime(c *gin.Context) {+ ret := gulu.Ret.NewResult()+ defer c.JSON(http.StatusOK, ret)++ arg, ok := util.JsonArg(c, ret)+ if !ok {+ return+ }++ var cardDues []*model.SetFlashcardDueTime+ for _, cardDueArg := range arg["cardDues"].([]interface{}) {+ cardDue := cardDueArg.(map[string]interface{})+ cardDues = append(cardDues, &model.SetFlashcardDueTime{+ ID: cardDue["id"].(string),+ Due: cardDue["due"].(string),+ })+ }++ err := model.SetFlashcardsDueTime(cardDues)+ if nil != err {+ ret.Code = -1+ ret.Msg = err.Error()+ }+}+func resetRiffCards(c *gin.Context) {ret := gulu.Ret.NewResult()defer c.JSON(http.StatusOK, ret)diff --git a/kernel/api/router.go b/kernel/api/router.goindex e675aecfbc..c71fc28b9b 100644--- a/kernel/api/router.go+++ b/kernel/api/router.go@@ -384,6 +384,7 @@ func ServeAPI(ginServer *gin.Engine) {ginServer.Handle("POST", "/api/riff/getTreeRiffCards", model.CheckAuth, getTreeRiffCards)ginServer.Handle("POST", "/api/riff/getNotebookRiffCards", model.CheckAuth, getNotebookRiffCards)ginServer.Handle("POST", "/api/riff/resetRiffCards", model.CheckAuth, model.CheckReadonly, resetRiffCards)+ ginServer.Handle("POST", "/api/riff/batchSetRiffCardsDueTime", model.CheckAuth, model.CheckReadonly, batchSetRiffCardsDueTime)ginServer.Handle("POST", "/api/notification/pushMsg", model.CheckAuth, pushMsg)ginServer.Handle("POST", "/api/notification/pushErrMsg", model.CheckAuth, pushErrMsg)diff --git a/kernel/go.mod b/kernel/go.modindex 597b7fe8f8..264d88e08d 100644--- a/kernel/go.mod+++ b/kernel/go.mod@@ -57,7 +57,7 @@ require (github.com/siyuan-note/filelock v0.0.0-20240128091141-94d7bb3e0772github.com/siyuan-note/httpclient v0.0.0-20240218075040-36250ac08e54github.com/siyuan-note/logging v0.0.0-20231208035918-61f884c854f0- github.com/siyuan-note/riff v0.0.0-20231226152006-8833f8b9a6c1+ github.com/siyuan-note/riff v0.0.0-20240224132914-ccd13f66ed24github.com/spf13/cast v1.6.0github.com/steambap/captcha v1.4.1github.com/studio-b12/gowebdav v0.9.0@@ -114,7 +114,7 @@ require (github.com/jmespath/go-jmespath v0.4.0 // indirectgithub.com/jolestar/go-commons-pool/v2 v2.1.2 // indirectgithub.com/juju/errors v1.0.0 // indirect- github.com/klauspost/compress v1.17.6 // indirect+ github.com/klauspost/compress v1.17.7 // indirectgithub.com/klauspost/cpuid/v2 v2.2.6 // indirectgithub.com/leodido/go-urn v1.4.0 // indirectgithub.com/levigross/exp-html v0.0.0-20120902181939-8df60c69a8f5 // indirect@@ -135,7 +135,7 @@ require (github.com/qiniu/go-sdk/v7 v7.19.0 // indirectgithub.com/quic-go/qpack v0.4.0 // indirectgithub.com/quic-go/quic-go v0.41.0 // indirect- github.com/refraction-networking/utls v1.6.2 // indirect+ github.com/refraction-networking/utls v1.6.3 // indirectgithub.com/restic/chunker v0.4.0 // indirectgithub.com/richardlehane/mscfb v1.0.4 // indirectgithub.com/richardlehane/msoleps v1.0.3 // indirect@@ -156,7 +156,7 @@ require (go.uber.org/mock v0.4.0 // indirectgolang.org/x/arch v0.7.0 // indirectgolang.org/x/crypto v0.19.0 // indirect- golang.org/x/exp v0.0.0-20240213143201-ec583247a57a // indirect+ golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirectgolang.org/x/net v0.21.0 // indirectgolang.org/x/sync v0.6.0 // indirectgolang.org/x/sys v0.17.0 // indirectdiff --git a/kernel/go.sum b/kernel/go.sumindex e0229d095d..8414fd3067 100644--- a/kernel/go.sum+++ b/kernel/go.sum@@ -221,8 +221,8 @@ github.com/juju/errors v1.0.0/go.mod h1:B5x9thDqx0wIMH3+aLIMP9HjItInYWObRovoCFM5github.com/juju/loggo v0.0.0-20190526231331-6e530bcce5d8/go.mod h1:vgyd7OREkbtVEN/8IXZe5Ooef3LQePvuBm9UWj6ZL8U=github.com/juju/testing v0.0.0-20191001232224-ce9dec17d28b/go.mod h1:63prj8cnj0tU0S9OHjGJn+b1h0ZghCndfnbQolrYTwA=github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=-github.com/klauspost/compress v1.17.6 h1:60eq2E/jlfwQXtvZEeBUYADs+BwKBWURIY+Gj2eRGjI=-github.com/klauspost/compress v1.17.6/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM=+github.com/klauspost/compress v1.17.7 h1:ehO88t2UGzQK66LMdE8tibEd1ErmzZjNEqWkjLAKQQg=+github.com/klauspost/compress v1.17.7/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=github.com/klauspost/cpuid/v2 v2.2.6 h1:ndNyv040zDGIDh8thGkXYjnFtiN02M1PVVF+JE/48xc=@@ -316,8 +316,8 @@ github.com/quic-go/quic-go v0.41.0 h1:aD8MmHfgqTURWNJy48IYFg2OnxwHT3JL7ahGs73lb4github.com/quic-go/quic-go v0.41.0/go.mod h1:qCkNjqczPEvgsOnxZ0eCD14lv+B2LHlFAB++CNOh9hA=github.com/radovskyb/watcher v1.0.7 h1:AYePLih6dpmS32vlHfhCeli8127LzkIgwJGcwwe8tUE=github.com/radovskyb/watcher v1.0.7/go.mod h1:78okwvY5wPdzcb1UYnip1pvrZNIVEIh/Cm+ZuvsUYIg=-github.com/refraction-networking/utls v1.6.2 h1:iTeeGY0o6nMNcGyirxkD5bFIsVctP5InGZ3E0HrzS7k=-github.com/refraction-networking/utls v1.6.2/go.mod h1:yil9+7qSl+gBwJqztoQseO6Pr3h62pQoY1lXiNR/FPs=+github.com/refraction-networking/utls v1.6.3 h1:MFOfRN35sSx6K5AZNIoESsBuBxS2LCgRilRIdHb6fDc=+github.com/refraction-networking/utls v1.6.3/go.mod h1:yil9+7qSl+gBwJqztoQseO6Pr3h62pQoY1lXiNR/FPs=github.com/restic/chunker v0.4.0 h1:YUPYCUn70MYP7VO4yllypp2SjmsRhRJaad3xKu1QFRw=github.com/restic/chunker v0.4.0/go.mod h1:z0cH2BejpW636LXw0R/BGyv+Ey8+m9QGiOanDHItzyw=github.com/richardlehane/mscfb v1.0.4 h1:WULscsljNPConisD5hR0+OyZjwK46Pfyr6mPu5ZawpM=@@ -364,8 +364,8 @@ github.com/siyuan-note/httpclient v0.0.0-20240218075040-36250ac08e54 h1:bQ90q5pHgithub.com/siyuan-note/httpclient v0.0.0-20240218075040-36250ac08e54/go.mod h1:3LyWEfBASVOxFGvvvhmt573BoFjKyp0fbDVh5klGNas=github.com/siyuan-note/logging v0.0.0-20231208035918-61f884c854f0 h1:+XjUr9UMXsczdO2bGA72p/k9wa2ShPb8ybi7CDBJ7HQ=github.com/siyuan-note/logging v0.0.0-20231208035918-61f884c854f0/go.mod h1:6mRFtAAvYPn3cDzqvyv+t8BVPGqpONDMMb5ywOhY1D4=-github.com/siyuan-note/riff v0.0.0-20231226152006-8833f8b9a6c1 h1:MziLTkbS4qTpeuANYEQQK5yQRSkdRXXNs+JKksbaMQk=-github.com/siyuan-note/riff v0.0.0-20231226152006-8833f8b9a6c1/go.mod h1:wLzj67jwt8PM+qWPGlC4V7m0fzkUlkwPKf9vLF6ru/k=+github.com/siyuan-note/riff v0.0.0-20240224132914-ccd13f66ed24 h1:x2JUCkUgKvUv6bRuso2LcFJEflOPfAuusaxlCV/K/Is=+github.com/siyuan-note/riff v0.0.0-20240224132914-ccd13f66ed24/go.mod h1:ztSkHxeyO4jHLst6Z2POcAOczTbGS1Kk2siHwpHKyP4=github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=github.com/smartystreets/goconvey v1.6.7 h1:I6tZjLXD2Q1kjvNbIzB1wvQBsXmKXiVrhpRE8ZjP5jY=@@ -445,8 +445,8 @@ golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQfgolang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo=golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=-golang.org/x/exp v0.0.0-20240213143201-ec583247a57a h1:HinSgX1tJRX3KsL//Gxynpw5CTOAIPhgL4W8PNiIpVE=-golang.org/x/exp v0.0.0-20240213143201-ec583247a57a/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc=+golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ=+golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc=golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=golang.org/x/image v0.11.0/go.mod h1:bglhjqbqVuEb9e9+eNR45Jfu7D+T4Qan+NhQk8Ck2P8=golang.org/x/image v0.15.0 h1:kOELfmgrmJlw4Cdb7g/QGuB3CvDrXbqEIww/pNtNBm8=diff --git a/kernel/model/flashcard.go b/kernel/model/flashcard.goindex 2ff66c32f7..8f9637c55c 100644--- a/kernel/model/flashcard.go+++ b/kernel/model/flashcard.go@@ -38,6 +38,46 @@ import ("github.com/siyuan-note/siyuan/kernel/util")+type SetFlashcardDueTime struct {+ ID string `json:"id"` // 卡片 ID+ Due string `json:"due"` // 下次复习时间,格式为 YYYYMMDDHHmmss+}++func SetFlashcardsDueTime(cardDues []*SetFlashcardDueTime) (err error) {+ // Add internal kernel API `/api/riff/batchSetRiffCardsDueTime` https://github.com/siyuan-note/siyuan/issues/10423++ deckLock.Lock()+ defer deckLock.Unlock()++ waitForSyncingStorages()++ deck := Decks[builtinDeckID]+ if nil == deck {+ return+ }++ for _, cardDue := range cardDues {+ card := deck.GetCard(cardDue.ID)+ if nil == card {+ continue+ }++ due, parseErr := time.Parse("20060102150405", cardDue.Due)+ if nil != parseErr {+ logging.LogErrorf("parse due time [%s] failed: %s", cardDue.Due, err)+ err = parseErr+ return+ }++ card.SetDue(due)+ }++ if err = deck.Save(); nil != err {+ logging.LogErrorf("save deck [%s] failed: %s", builtinDeckID, err)+ }+ return+}+func ResetFlashcards(typ, id, deckID string, blockIDs []string) {// Support resetting the learning progress of flashcards https://github.com/siyuan-note/siyuan/issues/9564