From baece7eb3a6c4cd928b5fce315359e97d0c3da9d Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Mon, 27 Mar 2023 17:56:08 +0800 Subject: [PATCH] getui update --- config/config.yaml | 7 +++++ internal/push/getui/push.go | 60 +++++++++++++++++++++---------------- pkg/common/config/config.go | 11 +++++++ 3 files changed, 52 insertions(+), 26 deletions(-) diff --git a/config/config.yaml b/config/config.yaml index 0dfb24242..0cb2fd46f 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -236,6 +236,13 @@ push: enable: # true or false (bool) channelID: "" channelName: "" + channel: + HW: + category: + XM: + channelID: + OPPO: + channelID: fcm: #firebase cloud message 消息推送 serviceAccount: #帐号文件,此处需要改修配置,并且这个文件放在 config目录下 enable: false diff --git a/internal/push/getui/push.go b/internal/push/getui/push.go index 0c337dba8..0fc8ce5aa 100644 --- a/internal/push/getui/push.go +++ b/internal/push/getui/push.go @@ -117,18 +117,35 @@ type Notification struct { } type Options struct { - HW struct { - DefaultSound bool `json:"/message/android/notification/default_sound"` - ChannelID string `json:"/message/android/notification/channel_id"` - Sound string `json:"/message/android/notification/sound"` - Importance string `json:"/message/android/notification/importance"` - } `json:"HW"` - XM struct { - ChannelID string `json:"/extra.channel_id"` - } `json:"XM"` - VV struct { - Classification int `json:"/classification"` - } `json:"VV"` + HW *HW `json:"HW"` + XM *XM `json:"XM"` + VV *VV `json:"VV"` + OP *OP `json:"OP"` + HO *HO `json:"HO"` +} + +type HW struct { + Category string `json:"/message/android/category"` + DefaultSound bool `json:"/message/android/notification/default_sound"` + ChannelID string `json:"/message/android/notification/channel_id"` + Sound string `json:"/message/android/notification/sound"` + Importance string `json:"/message/android/notification/importance"` +} + +type XM struct { + ChannelID string `json:"/extra.channel_id"` +} + +type VV struct { + Classification int `json:"/classification"` +} + +type OP struct { + ChannelID string `json:"/channel_id"` +} + +type HO struct { + Importance string `json:"/android/notification/importance"` } type PushResp struct { @@ -280,20 +297,11 @@ func (pushReq *PushReq) setPushChannel(title string, body string) { ClickType: "startapp", } pushReq.PushChannel.Android.Ups.Options = Options{ - HW: struct { - DefaultSound bool `json:"/message/android/notification/default_sound"` - ChannelID string `json:"/message/android/notification/channel_id"` - Sound string `json:"/message/android/notification/sound"` - Importance string `json:"/message/android/notification/importance"` - }{ChannelID: "RingRing4", Sound: "/raw/ring001", Importance: "NORMAL"}, - XM: struct { - ChannelID string `json:"/extra.channel_id"` - }{ChannelID: "high_system"}, - VV: struct { - Classification int "json:\"/classification\"" - }{ - Classification: 1, - }, + HW: &HW{Category: config.Config.Push.Getui.Channel.HW.Category, ChannelID: "RingRing4", Sound: "/raw/ring001", Importance: "NORMAL"}, + HO: &HO{Importance: "NORMAL"}, + XM: &XM{ChannelID: config.Config.Push.Getui.Channel.XM.ChannelID}, + OP: &OP{ChannelID: config.Config.Push.Getui.Channel.OPPO.ChannelID}, + VV: &VV{Classification: 1}, } } diff --git a/pkg/common/config/config.go b/pkg/common/config/config.go index 90be70fc7..eb939ac6d 100644 --- a/pkg/common/config/config.go +++ b/pkg/common/config/config.go @@ -210,6 +210,17 @@ type config struct { MasterSecret string `yaml:"masterSecret"` ChannelID string `yaml:"channelID"` ChannelName string `yaml:"channelName"` + Channel struct { + HW struct { + Category string `yaml:"category"` + } `yaml:"HW"` + XM struct { + ChannelID string `yaml:"channelID"` + } `yaml:"XM"` + OPPO struct { + ChannelID string `yaml:"channelID"` + } `yaml:"OPPO"` + } `yaml:"channel"` } Fcm struct { ServiceAccount string `yaml:"serviceAccount"`