Skip to content

Commit b94428c

Browse files
committed
feat: fix some problem
1 parent 9015f52 commit b94428c

9 files changed

Lines changed: 16 additions & 71 deletions

File tree

cmd/common/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,8 @@ func syncNoticeTask(ctx context.Context) error {
218218
deeplink := constants.UmengJwchNoticeDeeplink + "?url=" + url.QueryEscape(info.URL)
219219
umeng.PushByType(
220220
constants.UmengPushTypeTeaching,
221-
constants.UmengJwchNotificationTitle,
221+
"教务处通知",
222+
info.Title,
222223
[]string{info.Title},
223224
"",
224225
constants.UmengJwchNoticeTag,

config/config.example.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ vendors:
103103
channel_category: '' # 华为消息分类,需在华为后台申请自分类权益后配置,例如 SERVICE
104104
harmony:
105105
channel_category: 'SUBSCRIPTION' # 鸿蒙消息分类,需在友盟/华为后台申请自分类后配置,例如 SERVICE
106-
# 这里的华为配置指的是老版本手机未升级到纯血鸿蒙系统的通知配置,这个跟纯血鸿蒙系统的通知不是一套的
106+
# 这里的华为配置指的原本版本的卓易通fuu,而后面新增的鸿蒙配置则指鸿蒙福uu
107107

108108
friend:
109109
max-nums : 3 # 兜底默认值,优先读取数据库 friend_config 表中 config_key='max_num' 的记录

internal/academic/service/get_scores.go

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

203203
func (s *AcademicService) sendNotifications(courseName, tag string) (err error) {
204204
// 这个函数由于放在 task queue 上跑,所以 logger 没有加 crx,防止把 trace 语义弄脏
205-
title := constants.UmengGradeNotificationTitle
205+
title := "成绩更新啦"
206+
text := courseName + "成绩已更新"
206207
description := fmt.Sprintf("成绩更新%v", tag[:12])
207-
umeng.PushByType(constants.UmengPushTypeScore, title, []string{courseName}, "", tag, description, constants.UmengGradeDeeplink)
208+
umeng.PushByType(constants.UmengPushTypeScore, title, text, []string{courseName}, "", tag, description, constants.UmengGradeDeeplink)
208209

209210
logger.Infof("task queue: send notice to app, tag:%v", tag)
210211
return nil

internal/academic/service/get_scores_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -649,8 +649,8 @@ func TestAcademicService_sendNotifications(t *testing.T) {
649649
umengAndroidPatch := mockey.Mock(umeng.SendAndroidGroupcastWithGoApp).To(
650650
func(pushType, title, text, ticker, gotTag, description, deeplink string, keywords []string) error {
651651
So(pushType, ShouldEqual, constants.UmengPushTypeScore)
652-
So(title, ShouldEqual, constants.UmengGradeNotificationTitle)
653-
So(text, ShouldEqual, courseName+constants.UmengGradeNotificationBodySuffix)
652+
So(title, ShouldEqual, "成绩更新啦")
653+
So(text, ShouldEqual, courseName+"成绩已更新")
654654
So(gotTag, ShouldEqual, tag)
655655
So(description, ShouldEqual, fmt.Sprintf("成绩更新%v", tag[:12]))
656656
So(deeplink, ShouldEqual, constants.UmengGradeDeeplink)

internal/course/service/get_course_list.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,10 @@ func (s *CourseService) updateExamSnapshot(id int64, examInfo, examInfoSHA256 st
262262
func (s *CourseService) sendExamNotification(change courseExamChange) {
263263
// 与成绩通知一致,推送失败仅由 Umeng 任务队列统一记录,不影响业务快照。
264264
// 这里直接不返回错误了,直接打印错误日志,因为就是安卓跟iOS都直推送一次,如果错过就直接算了
265-
title := constants.UmengExamNotificationTitle
265+
title := "考试更新啦"
266+
text := change.Exam.Name + "考试已更新"
266267
description := fmt.Sprintf("考试信息更新%v", change.Tag[:12])
267-
umeng.PushByType(constants.UmengPushTypeExam, title, []string{change.Exam.Name}, "", change.Tag, description, constants.UmengExamRoomDeeplink)
268+
umeng.PushByType(constants.UmengPushTypeExam, title, text, []string{change.Exam.Name}, "", change.Tag, description, constants.UmengExamRoomDeeplink)
268269
}
269270

270271
func (s *CourseService) GetCourseListYjsy(req *course.CourseListRequest, loginData *kitexModel.LoginData) ([]*kitexModel.Course, error) {

pkg/constants/umeng.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,5 @@ const (
4545
)
4646

4747
const (
48-
UmengXiaomiTemplateKeyword = "keywords1" // 小米模板的参数占位符
49-
UmengGradeNotificationTitle = "成绩更新啦"
50-
UmengGradeNotificationBodySuffix = "成绩已更新"
51-
UmengExamNotificationTitle = "考试更新啦"
52-
UmengExamNotificationBodySuffix = "考试已更新"
53-
UmengJwchNotificationTitle = "教务处通知"
48+
UmengXiaomiTemplateKeyword = "keywords1" // 小米模板的参数占位符
5449
)

pkg/umeng/groupcast.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,9 @@ func getChannelProperties(title, content string) AndroidChannelProperties {
5757
}
5858
}
5959

60-
// getXiaomiNoticeProperties 按推送类型从小米模板注册表与配置中选取模板
60+
// getXiaomiNoticeProperties 按推送类型从配置中选取小米模板
6161
// 模板参数直接取调用方透传的 keywords[0],不做字符串反解
6262
func getXiaomiNoticeProperties(pushType string, keywords []string, notice config.XiaomiNotice) (string, *XiaomiExtraProperties) {
63-
_, ok := xiaomiTemplateKinds[pushType]
64-
if !ok {
65-
return "", nil
66-
}
6763
template, ok := notice[pushType]
6864
if !ok {
6965
return "", nil
@@ -90,9 +86,8 @@ func getXiaomiNoticeProperties(pushType string, keywords []string, notice config
9086
}
9187

9288
// PushByType 按推送类型同时下发安卓、iOS 与鸿蒙推送,任一端失败仅记录日志,不影响业务(尽力而为)。
93-
// keywords 为模板参数(透传,不做字符串反解),例如成绩通知传 []string{courseName},正文由注册表拼装
94-
func PushByType(pushType, title string, keywords []string, ticker, tag, description, deeplink string) {
95-
text := buildPushText(pushType, keywords)
89+
// text 由调用方按推送类型拼装好传入;keywords 为模板参数(透传复用,不做字符串反解),例如成绩通知传 []string{courseName}
90+
func PushByType(pushType, title, text string, keywords []string, ticker, tag, description, deeplink string) {
9691
if err := SendAndroidGroupcastWithGoApp(pushType, title, text, ticker, tag, description, deeplink, keywords); err != nil {
9792
logger.Errorf("umeng.PushByType: %s failed to send Android groupcast: %v", pushType, err)
9893
}

pkg/umeng/groupcast_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func TestPushByType(t *testing.T) {
7878
defer harmonyPatch.UnPatch()
7979

8080
// PushByType 为尽力而为,三端失败仅记录日志,不应 panic
81-
PushByType(tt.pushType, "title", []string{"text"}, "ticker", "tag", "description", "deeplink")
81+
PushByType(tt.pushType, "title", "text", []string{"text"}, "ticker", "tag", "description", "deeplink")
8282

8383
assert.Equal(t, tt.pushType, androidPushType)
8484
assert.True(t, iosCalled)

pkg/umeng/xiaomi_template.go

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)