feat(jpush): add vendor-specific message classification support for push notifications
All checks were successful
Build Backend / build (push) Successful in 3m4s
Build Backend / build-docker (push) Successful in 1m15s

- Add OPPO category/notify_level support (2024.11.20 regulation: category required when notify_level present)
- Add Honor importance field (NORMAL=service/LOW=marketing) for notification classification
- Add vivo category field (IM/ACCOUNT) for message scenario identification
- Set Xiaomi channel/template defaults in code (system=153609, chat=153608, templates P10761/M10289)
- Add classification option to JPush push payloads (0=operation, 1=system)
- Update xiaomi template keywords mapping to match actual template placeholders
- Add keyword search support for GetFollowers and GetFollowing endpoints
- Bind new config fields to environment variables for OPPO/Honor/vivo
This commit is contained in:
lafay
2026-06-18 19:41:32 +08:00
parent 5b83f98fb8
commit 821e066446
13 changed files with 637 additions and 66 deletions

View File

@@ -47,12 +47,24 @@ type MessageParams struct {
Extra map[string]any
}
// 消息分类常量(对应 JPush options.classification
const (
// ClassificationOperation 运营消息0营销/公告类,受厂商限速
ClassificationOperation = 0
// ClassificationSystem 系统消息1即时聊天/系统通知/互动通知,高优先级及时送达
// 注:聊天即时消息也归为系统消息,避免被厂商运营消息限速影响送达
ClassificationSystem = 1
)
// PushPayload 工厂统一产物client 据此组装最终推送 payload
type PushPayload struct {
// Notification 含 android + ios由 TextRenderer 产出
Notification *jpush.Notification
// TPC 各厂商私有字段options.third_party_channel由 PrivateConverter 产出
TPC *jpush.ThirdPartyChannel
// Classification 消息分类options.classification0=运营消息1=系统消息
// 聊天和系统通知统一用 1避免厂商运营消息限速
Classification int
}
// TextRenderer 通用文本渲染器(基础层)
@@ -124,7 +136,16 @@ func (f *Factory) Build(params MessageParams, cfg config.ChannelConfig) *PushPay
}
return &PushPayload{
Notification: notification,
TPC: tpc.Normalize(),
Notification: notification,
TPC: tpc.Normalize(),
Classification: resolveClassification(params.Scene),
}
}
// resolveClassification 根据场景映射 JPush options.classification
// 聊天即时消息与系统通知统一归为系统消息1避免厂商运营消息限速影响送达
// 未来若引入营销/公告推送可扩展为运营消息0
func resolveClassification(scene string) int {
// system 与 chat 场景均使用系统消息分类
return ClassificationSystem
}