feat(push): include group information in chat message push notifications
Update the chat message push mechanism to include group ID and group avatar when sending messages in group conversations. This ensures that push notifications for group chats display the group's identity and icon rather than the sender's personal avatar. - Update `PushChatMessage` interface and implementation to accept `groupID` and `groupAvatar`. - Modify `chat_service.go` to extract group metadata and pass it to the push service. - Update `push_service.go` to include group details in the push payload extras and set the notification icon to the group avatar for group conversations.
This commit is contained in:
@@ -452,8 +452,12 @@ func (s *chatServiceImpl) SendMessage(ctx context.Context, senderID string, conv
|
||||
}
|
||||
convType := conv.Type
|
||||
convName := ""
|
||||
groupID := ""
|
||||
groupAvatar := ""
|
||||
if conv.Type == model.ConversationTypeGroup && conv.Group != nil {
|
||||
convName = conv.Group.Name
|
||||
groupID = conv.Group.ID
|
||||
groupAvatar = conv.Group.Avatar
|
||||
}
|
||||
allTargetIDs := make([]string, 0, len(participants))
|
||||
for _, p := range participants {
|
||||
@@ -469,9 +473,9 @@ func (s *chatServiceImpl) SendMessage(ctx context.Context, senderID string, conv
|
||||
offlineTargetIDs = allTargetIDs
|
||||
}
|
||||
if len(offlineTargetIDs) > 0 {
|
||||
go func(ids []string, sender ChatMessageSender) {
|
||||
go func(ids []string, sender ChatMessageSender, gid string, gavatar string) {
|
||||
for _, uid := range ids {
|
||||
if pushErr := s.pushSvc.PushChatMessage(context.Background(), uid, conversationID, &sender, convType, convName, message); pushErr != nil {
|
||||
if pushErr := s.pushSvc.PushChatMessage(context.Background(), uid, conversationID, &sender, convType, convName, message, gid, gavatar); pushErr != nil {
|
||||
zap.L().Debug("push chat message failed",
|
||||
zap.String("userID", uid),
|
||||
zap.String("conversationID", conversationID),
|
||||
@@ -479,7 +483,7 @@ func (s *chatServiceImpl) SendMessage(ctx context.Context, senderID string, conv
|
||||
)
|
||||
}
|
||||
}
|
||||
}(offlineTargetIDs, sender)
|
||||
}(offlineTargetIDs, sender, groupID, groupAvatar)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user