Skip to content

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

:art: Support sending notifications on Android https://github.com/siyuan-note/siyuan/issues/17114

Danielc5931e6da18b
diff --git a/kernel/api/notification.go b/kernel/api/notification.go
index e7211c2ccd..e1a040054d 100644
--- a/kernel/api/notification.go
+++ b/kernel/api/notification.go
@@ -40,14 +40,28 @@ func sendDeviceNotification(c *gin.Context) {
return
}
- title := arg["title"].(string)
- body := arg["body"].(string)
- evt := util.NewCmdResult("sendDeviceNotification", 0, util.PushModeSingleSelf)
- evt.Data = map[string]interface{}{
+ var title string
+ if nil != arg["title"] {
+ title = strings.TrimSpace(arg["title"].(string))
+ } else {
+ ret.Code = -1
+ ret.Msg = "title can't be empty"
+ return
+ }
+
+ var body string
+ if nil != arg["body"] {
+ body = strings.TrimSpace(arg["body"].(string))
+ } else {
+ ret.Code = -1
+ ret.Msg = "body can't be empty"
+ return
+ }
+
+ util.BroadcastByType("main", "sendDeviceNotification", 0, "", map[string]interface{}{
"title": title,
"body": body,
- }
- util.PushEvent(evt)
+ })
}
func pushMsg(c *gin.Context) {