Skip to content

Commit 5a4c1f9

Browse files
committed
chore: 优化推送描述
1 parent ce62813 commit 5a4c1f9

File tree

4 files changed

+13
-16
lines changed

4 files changed

+13
-16
lines changed

cmd/common/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,12 @@ func syncNoticeTask() error {
174174

175175
// 进行消息推送
176176
if ok := umeng.EnqueueAsync(func() error {
177-
err = umeng.SendAndroidGroupcastWithUrl("教务处通知", info.Title, "", info.URL, constants.UmengJwchNoticeTag)
177+
err = umeng.SendAndroidGroupcastWithUrl("教务处通知", info.Title, "", info.URL, constants.UmengJwchNoticeTag, "教务处")
178178
if err != nil {
179179
logger.Errorf("notice sync task: failed to send notice to Android: %v", err)
180180
}
181181

182-
err = umeng.SendIOSGroupcast("教务处通知", "", info.Title, constants.UmengJwchNoticeTag)
182+
err = umeng.SendIOSGroupcast("教务处通知", "", info.Title, constants.UmengJwchNoticeTag, "教务处")
183183
if err != nil {
184184
logger.Errorf("notice sync task: failed to send notice to IOS: %v", err)
185185
}

internal/academic/service/get_scores.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,11 @@ func (s *AcademicService) handleScoreChange(stuID string, scores []*jwch.Mark) (
201201
}
202202

203203
func (s *AcademicService) sendNotifications(courseName, tag string) (err error) {
204-
err = umeng.SendAndroidGroupcastWithGoApp(fmt.Sprintf("%v成绩更新啦", courseName), "", "", tag)
204+
err = umeng.SendAndroidGroupcastWithGoApp(fmt.Sprintf("%v成绩更新啦", courseName), "", "", tag, fmt.Sprintf("成绩更新%v", tag[:12]))
205205
if err != nil {
206206
logger.Errorf("task queue: failed to send notice to Android: %v", err)
207207
}
208-
err = umeng.SendIOSGroupcast(fmt.Sprintf("%v成绩更新啦", courseName), "", "", tag)
208+
err = umeng.SendIOSGroupcast(fmt.Sprintf("%v成绩更新啦", courseName), "", "", tag, fmt.Sprintf("成绩更新%v", tag[:12]))
209209
if err != nil {
210210
logger.Errorf("task queue: failed to send notice to IOS: %v", err)
211211
}

internal/course/service/get_course_list.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,17 +194,15 @@ func (s *CourseService) handleCourseUpdate(term string, newCourses []*kitexModel
194194
}
195195

196196
func (s *CourseService) sendNotifications(courseName, tag string) (err error) {
197-
err = umeng.SendAndroidGroupcastWithGoApp(fmt.Sprintf("[调课] %v", courseName), "", "", tag)
197+
err = umeng.SendAndroidGroupcastWithGoApp(fmt.Sprintf("[调课] %v", courseName), "", "", tag, fmt.Sprintf("调课%v", tag[:12]))
198198
if err != nil {
199199
logger.Errorf("service.sendNotifications: Send course updated message to Android failed: %v", err)
200-
return err
201200
}
202-
203-
err = umeng.SendIOSGroupcast(fmt.Sprintf("[调课] %v", courseName), "", "", tag)
201+
err = umeng.SendIOSGroupcast(fmt.Sprintf("[调课] %v", courseName), "", "", tag, fmt.Sprintf("调课%v", tag[:12]))
204202
if err != nil {
205203
logger.Errorf("service.sendNotifications: Send course updated message to IOS failed: %v", err)
206-
return err
207204
}
205+
logger.Infof("service.sendNotifications: Send course updated message, tag:%v", tag)
208206
return nil
209207
}
210208

pkg/umeng/groupcast.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func getChannelProperties() AndroidChannelProperties {
4646
}
4747
}
4848

49-
func SendAndroidGroupcastWithGoApp(title, text, ticker, tag string) error {
49+
func SendAndroidGroupcastWithGoApp(title, text, ticker, tag, description string) error {
5050
message := AndroidGroupcastMessage{
5151
AppKey: config.Umeng.Android.AppKey,
5252
Timestamp: fmt.Sprintf("%d", time.Now().Unix()),
@@ -71,7 +71,7 @@ func SendAndroidGroupcastWithGoApp(title, text, ticker, tag string) error {
7171
ExpireTime: time.Now().Add(constants.UmengMessageExpireTime).Format("2006-01-02 15:04:05"),
7272
NotificationClosedFilter: true,
7373
},
74-
Description: "Android-广播通知",
74+
Description: description,
7575
Category: 0,
7676
ChannelProperties: getChannelProperties(),
7777
}
@@ -80,7 +80,7 @@ func SendAndroidGroupcastWithGoApp(title, text, ticker, tag string) error {
8080
}
8181

8282
// Android广播函数
83-
func SendAndroidGroupcastWithUrl(title, text, ticker, url, tag string) error {
83+
func SendAndroidGroupcastWithUrl(title, text, ticker, url, tag, description string) error {
8484
message := AndroidGroupcastMessage{
8585
AppKey: config.Umeng.Android.AppKey,
8686
Timestamp: fmt.Sprintf("%d", time.Now().Unix()),
@@ -106,7 +106,7 @@ func SendAndroidGroupcastWithUrl(title, text, ticker, url, tag string) error {
106106
ExpireTime: time.Now().Add(constants.UmengMessageExpireTime).Format("2006-01-02 15:04:05"),
107107
NotificationClosedFilter: true,
108108
},
109-
Description: "Android-广播通知",
109+
Description: description,
110110
Category: 0,
111111
ChannelProperties: getChannelProperties(),
112112
}
@@ -115,7 +115,7 @@ func SendAndroidGroupcastWithUrl(title, text, ticker, url, tag string) error {
115115
}
116116

117117
// iOS广播函数
118-
func SendIOSGroupcast(title, subtitle, body, tag string) error {
118+
func SendIOSGroupcast(title, subtitle, body, tag, description string) error {
119119
message := IOSGroupcastMessage{
120120
AppKey: config.Umeng.IOS.AppKey,
121121
Timestamp: fmt.Sprintf("%d", time.Now().Unix()),
@@ -141,7 +141,7 @@ func SendIOSGroupcast(title, subtitle, body, tag string) error {
141141
Policy: IOSPolicy{
142142
ExpireTime: time.Now().Add(constants.UmengMessageExpireTime).Format("2006-01-02 15:04:05"),
143143
},
144-
Description: "iOS-广播通知",
144+
Description: description,
145145
}
146146

147147
return sendGroupcast(config.Umeng.IOS.AppMasterSecret, message)
@@ -184,7 +184,6 @@ func sendGroupcast(appMasterSecret string, message interface{}) error {
184184
return errno.Errorf(errno.InternalServiceErrorCode, "umeng.sendGroupcast : Groupcast failed: %s (%s)", response.Data.ErrorMsg, response.Data.ErrorCode)
185185
}
186186

187-
logger.Infof("Groupcast sent successfully! MsgID: %s\n", response.Data.MsgID)
188187
return nil
189188
}
190189

0 commit comments

Comments
 (0)