Files
backend/internal/config/jpush.go
lafay 821e066446
All checks were successful
Build Backend / build (push) Successful in 3m4s
Build Backend / build-docker (push) Successful in 1m15s
feat(jpush): add vendor-specific message classification support for push notifications
- 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
2026-06-18 19:41:32 +08:00

84 lines
4.5 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package config
type JPushConfig struct {
Enabled bool `mapstructure:"enabled"`
AppKey string `mapstructure:"app_key"`
MasterSecret string `mapstructure:"master_secret"`
Production bool `mapstructure:"production"`
// Channel 厂商通道 channel_id 配置
// 通过 options.third_party_channel 下发到各厂商(小米/华为/OPPO 等)
Channel ChannelConfig `mapstructure:"channel"`
}
// ChannelConfig 厂商通道 channel_id 配置
// 区分「系统消息」与「私聊/群聊消息」两类 channel
type ChannelConfig struct {
// System 系统消息/通知默认 channel_id未单独配置 Vendor 时各厂商共用
System string `mapstructure:"system"`
// Chat 私聊/群聊消息默认 channel_id未单独配置 Vendor 时各厂商共用
Chat string `mapstructure:"chat"`
// Vendor 各厂商 channel_id 覆盖配置(留空则回退到 System/Chat
Vendor VendorChannel `mapstructure:"vendor"`
// iOS APNs 通知场景区分配置(按 thread-id 分组)
IOS IOSChannelConfig `mapstructure:"ios"`
}
// IOSChannelConfig iOS APNs 通知场景区分配置
// iOS 走 APNs 无 channel_id 概念,通过 thread-id 实现通知分组
type IOSChannelConfig struct {
// ChatThreadID 私聊/群聊消息通知分组 thread-id
ChatThreadID string `mapstructure:"chat_thread_id"`
// SystemThreadID 系统消息/通知分组 thread-id
SystemThreadID string `mapstructure:"system_thread_id"`
}
// VendorChannel 各厂商通道 channel_id 覆盖
// 每个厂商区分 System系统消息与 Chat私聊消息两个 channel_id
type VendorChannel struct {
Xiaomi VendorChannelID `mapstructure:"xiaomi"`
Huawei VendorChannelID `mapstructure:"huawei"`
OPPO VendorChannelID `mapstructure:"oppo"`
VIVO VendorChannelID `mapstructure:"vivo"`
Meizu VendorChannelID `mapstructure:"meizu"`
Honor VendorChannelID `mapstructure:"honor"`
FCM VendorChannelID `mapstructure:"fcm"`
}
// VendorChannelID 单个厂商的两类 channel 配置
// 每个 channel 可携带厂商私有模板配置(如小米 mi_template_id、OPPO private_msg_template_id
type VendorChannelID struct {
// channel_id
System string `mapstructure:"system"`
Chat string `mapstructure:"chat"`
// 小米消息模板(可选,配置后私信消息下发时携带 channel_id 及 mi_template_id
// 见:小米关于消息模板推送新规的更新通知
MiSystemTemplateID string `mapstructure:"mi_system_template_id"` // 系统消息模板 id
MiChatTemplateID string `mapstructure:"mi_chat_template_id"` // 私聊消息模板 id
// OPPO 私信模板(可选,仅 OPPO 厂商,配置后下发私信时携带)
// 见OPUSH 私信模版校验能力接入说明
OppoSystemPrivateTemplateID string `mapstructure:"oppo_system_private_template_id"` // 系统消息私信模板 id
OppoChatPrivateTemplateID string `mapstructure:"oppo_chat_private_template_id"` // 私聊消息私信模板 id
// OPPO 消息分类可选2024.11.20 新规)
// category 消息场景标识,使用 notify_level 时必传notify_level 提醒等级
// 取值category 如 IM/ACCOUNTnotify_level 1=通知栏, 2=通知栏+锁屏, 16=通知栏+锁屏+横幅+震动+铃声
OppoSystemCategory string `mapstructure:"oppo_system_category"` // 系统消息 category如 ACCOUNT
OppoChatCategory string `mapstructure:"oppo_chat_category"` // 私聊消息 category如 IM
OppoSystemNotifyLevel int `mapstructure:"oppo_system_notify_level"` // 系统消息提醒等级(如 2
OppoChatNotifyLevel int `mapstructure:"oppo_chat_notify_level"` // 私聊消息提醒等级(如 16
// 荣耀通知栏消息智能分类可选importance 字段)
// 取值:"NORMAL"=服务与通讯,"LOW"=资讯营销
// 注classification 优先级更高,会覆盖 importance 设置的值
HonorSystemImportance string `mapstructure:"honor_system_importance"` // 系统消息 importance如 LOW
HonorChatImportance string `mapstructure:"honor_chat_importance"` // 私聊消息 importance如 NORMAL
// vivo 厂商消息场景标识可选category 字段)
// 用于标识消息类型确定提醒方式classification=1 时 category 必须为系统消息类
// 不携带 category 会默认按运营消息下发,受频控限制
VivoSystemCategory string `mapstructure:"vivo_system_category"` // 系统消息 category如 ACCOUNT 账号动态)
VivoChatCategory string `mapstructure:"vivo_chat_category"` // 私聊消息 category如 IM 即时通讯)
}