From f07ae1fc752a5f1a3040876cf6b06b70e12bd4c9 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Sun, 1 Mar 2026 09:44:35 +0800 Subject: [PATCH] :art: Support sending notifications on Android https://github.com/siyuan-note/siyuan/issues/17114 Signed-off-by: Daniel <845765@qq.com> --- kernel/api/notification.go | 23 +++++++++++++++++++++++ kernel/api/router.go | 1 + 2 files changed, 24 insertions(+) diff --git a/kernel/api/notification.go b/kernel/api/notification.go index 704107680..8dad637d8 100644 --- a/kernel/api/notification.go +++ b/kernel/api/notification.go @@ -25,6 +25,29 @@ import ( "github.com/siyuan-note/siyuan/kernel/util" ) +func sendDeviceNotification(c *gin.Context) { + ret := gulu.Ret.NewResult() + defer c.JSON(http.StatusOK, ret) + + arg, ok := util.JsonArg(c, ret) + if !ok { + return + } + + if util.ContainerAndroid != util.Container { + ret.Code = -1 + ret.Msg = "Just support Android" + return + } + + payload := arg["payload"].(string) + evt := util.NewCmdResult("sendDeviceNotification", 0, util.PushModeSingleSelf) + evt.Data = map[string]interface{}{ + "payload": payload, + } + util.PushEvent(evt) +} + func pushMsg(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 ffa717939..f3d031f93 100644 --- a/kernel/api/router.go +++ b/kernel/api/router.go @@ -458,6 +458,7 @@ func ServeAPI(ginServer *gin.Engine) { ginServer.Handle("POST", "/api/notification/pushMsg", model.CheckAuth, model.CheckAdminRole, pushMsg) ginServer.Handle("POST", "/api/notification/pushErrMsg", model.CheckAuth, model.CheckAdminRole, pushErrMsg) + ginServer.Handle("POST", "/api/notification/sendDeviceNotification", model.CheckAuth, model.CheckAdminRole, sendDeviceNotification) ginServer.Handle("POST", "/api/snippet/getSnippet", model.CheckAuth, getSnippet) ginServer.Handle("POST", "/api/snippet/setSnippet", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, setSnippet)