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
This commit is contained in:
@@ -317,7 +317,7 @@ func (s *pushServiceImpl) pushViaJPush(ctx context.Context, device *model.Device
|
||||
}
|
||||
|
||||
payload := s.buildPayload(params)
|
||||
_, err := s.jpushClient.PushByRegistrationIDs([]string{device.PushToken}, payload.Notification, payload.TPC)
|
||||
_, err := s.jpushClient.PushByRegistrationIDs([]string{device.PushToken}, payload.Notification, payload.Classification, payload.TPC)
|
||||
if err != nil {
|
||||
return fmt.Errorf("jpush push failed: %w", err)
|
||||
}
|
||||
@@ -373,7 +373,7 @@ func (s *pushServiceImpl) pushViaJPushBatch(devices []*model.DeviceToken, params
|
||||
}
|
||||
|
||||
payload := s.buildPayload(params)
|
||||
_, err := s.jpushClient.PushByRegistrationIDs(regIDs, payload.Notification, payload.TPC)
|
||||
_, err := s.jpushClient.PushByRegistrationIDs(regIDs, payload.Notification, payload.Classification, payload.TPC)
|
||||
if err != nil {
|
||||
return fmt.Errorf("jpush batch push failed: %w", err)
|
||||
}
|
||||
@@ -819,7 +819,9 @@ func (s *pushServiceImpl) PushChatMessage(ctx context.Context, userID string, co
|
||||
largeIcon = groupAvatar
|
||||
}
|
||||
params := vendor.MessageParams{
|
||||
Scene: s.resolveChannelScene(message),
|
||||
// PushChatMessage 处理的是会话上下文内的消息(含群内通知),
|
||||
// 统一走 chat channel,保证会话内通知体验一致
|
||||
Scene: vendor.SceneChat,
|
||||
Title: title,
|
||||
Body: content,
|
||||
SenderName: sender.Name,
|
||||
@@ -831,7 +833,7 @@ func (s *pushServiceImpl) PushChatMessage(ctx context.Context, userID string, co
|
||||
Extra: extras,
|
||||
}
|
||||
payload := s.buildPayload(params)
|
||||
if _, pushErr := s.jpushClient.PushByRegistrationIDs(regIDs, payload.Notification, payload.TPC); pushErr != nil {
|
||||
if _, pushErr := s.jpushClient.PushByRegistrationIDs(regIDs, payload.Notification, payload.Classification, payload.TPC); pushErr != nil {
|
||||
zap.L().Error("jpush push chat message failed",
|
||||
zap.String("userID", userID),
|
||||
zap.String("conversationID", conversationID),
|
||||
@@ -932,6 +934,7 @@ func (s *pushServiceImpl) PushSystemNotification(ctx context.Context, userID str
|
||||
return ids
|
||||
}(),
|
||||
payload.Notification,
|
||||
payload.Classification,
|
||||
payload.TPC,
|
||||
)
|
||||
if pushErr == nil {
|
||||
|
||||
@@ -42,10 +42,10 @@ type UserService interface {
|
||||
ResetPasswordByEmail(ctx context.Context, email, verificationCode, newPassword string) error
|
||||
|
||||
// 关注相关
|
||||
GetFollowers(ctx context.Context, userID string, page, pageSize int) ([]*model.User, int64, error)
|
||||
GetFollowing(ctx context.Context, userID string, page, pageSize int) ([]*model.User, int64, error)
|
||||
GetFollowingList(ctx context.Context, userID string, page, pageSize string) ([]*model.User, error)
|
||||
GetFollowersList(ctx context.Context, userID string, page, pageSize string) ([]*model.User, error)
|
||||
GetFollowers(ctx context.Context, userID, keyword string, page, pageSize int) ([]*model.User, int64, error)
|
||||
GetFollowing(ctx context.Context, userID, keyword string, page, pageSize int) ([]*model.User, int64, error)
|
||||
GetFollowingList(ctx context.Context, userID, page, pageSize, keyword string) ([]*model.User, error)
|
||||
GetFollowersList(ctx context.Context, userID, page, pageSize, keyword string) ([]*model.User, error)
|
||||
FollowUser(ctx context.Context, followerID, followeeID string) error
|
||||
UnfollowUser(ctx context.Context, followerID, followeeID string) error
|
||||
GetMutualFollowStatus(ctx context.Context, currentUserID string, targetUserIDs []string) (map[string][2]bool, error)
|
||||
@@ -475,13 +475,13 @@ func (s *userServiceImpl) UpdateUser(ctx context.Context, user *model.User) erro
|
||||
}
|
||||
|
||||
// GetFollowers 获取粉丝
|
||||
func (s *userServiceImpl) GetFollowers(ctx context.Context, userID string, page, pageSize int) ([]*model.User, int64, error) {
|
||||
return s.userRepo.GetFollowers(userID, page, pageSize)
|
||||
func (s *userServiceImpl) GetFollowers(ctx context.Context, userID, keyword string, page, pageSize int) ([]*model.User, int64, error) {
|
||||
return s.userRepo.GetFollowers(userID, keyword, page, pageSize)
|
||||
}
|
||||
|
||||
// GetFollowing 获取关注
|
||||
func (s *userServiceImpl) GetFollowing(ctx context.Context, userID string, page, pageSize int) ([]*model.User, int64, error) {
|
||||
return s.userRepo.GetFollowing(userID, page, pageSize)
|
||||
func (s *userServiceImpl) GetFollowing(ctx context.Context, userID, keyword string, page, pageSize int) ([]*model.User, int64, error) {
|
||||
return s.userRepo.GetFollowing(userID, keyword, page, pageSize)
|
||||
}
|
||||
|
||||
// FollowUser 关注用户
|
||||
@@ -597,7 +597,7 @@ func (s *userServiceImpl) IsBlockedBatch(ctx context.Context, blockerID string,
|
||||
}
|
||||
|
||||
// GetFollowingList 获取关注列表(字符串参数版本)
|
||||
func (s *userServiceImpl) GetFollowingList(ctx context.Context, userID, page, pageSize string) ([]*model.User, error) {
|
||||
func (s *userServiceImpl) GetFollowingList(ctx context.Context, userID, page, pageSize, keyword string) ([]*model.User, error) {
|
||||
pageInt := 1
|
||||
pageSizeInt := 20
|
||||
if page != "" {
|
||||
@@ -615,12 +615,12 @@ func (s *userServiceImpl) GetFollowingList(ctx context.Context, userID, page, pa
|
||||
}
|
||||
}
|
||||
|
||||
users, _, err := s.userRepo.GetFollowing(userID, pageInt, pageSizeInt)
|
||||
users, _, err := s.userRepo.GetFollowing(userID, keyword, pageInt, pageSizeInt)
|
||||
return users, err
|
||||
}
|
||||
|
||||
// GetFollowersList 获取粉丝列表(字符串参数版本)
|
||||
func (s *userServiceImpl) GetFollowersList(ctx context.Context, userID, page, pageSize string) ([]*model.User, error) {
|
||||
func (s *userServiceImpl) GetFollowersList(ctx context.Context, userID, page, pageSize, keyword string) ([]*model.User, error) {
|
||||
pageInt := 1
|
||||
pageSizeInt := 20
|
||||
if page != "" {
|
||||
@@ -638,7 +638,7 @@ func (s *userServiceImpl) GetFollowersList(ctx context.Context, userID, page, pa
|
||||
}
|
||||
}
|
||||
|
||||
users, _, err := s.userRepo.GetFollowers(userID, pageInt, pageSizeInt)
|
||||
users, _, err := s.userRepo.GetFollowers(userID, keyword, pageInt, pageSizeInt)
|
||||
return users, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user