feat(notifications): improve reaction notification titles with emojis
This commit is contained in:
parent
23bf5a15b4
commit
0531e8f878
|
|
@ -321,10 +321,18 @@ func (s *NotificationService) buildPushPayload(req models.PushNotificationReques
|
|||
}
|
||||
}
|
||||
|
||||
// Extract optional emoji
|
||||
emoji, _ := req.Metadata["emoji"].(string)
|
||||
|
||||
switch req.Type {
|
||||
case models.NotificationTypeLike:
|
||||
title = "New Like"
|
||||
body = fmt.Sprintf("%s liked your %s", actorName, s.formatPostType(req.PostType))
|
||||
if emoji != "" {
|
||||
title = fmt.Sprintf("%s %s", actorName, emoji)
|
||||
body = fmt.Sprintf("%s reacted %s to your %s", actorName, emoji, s.formatPostType(req.PostType))
|
||||
} else {
|
||||
title = "New Like"
|
||||
body = fmt.Sprintf("%s liked your %s", actorName, s.formatPostType(req.PostType))
|
||||
}
|
||||
|
||||
case models.NotificationTypeComment:
|
||||
title = "New Comment"
|
||||
|
|
@ -366,7 +374,7 @@ func (s *NotificationService) buildPushPayload(req models.PushNotificationReques
|
|||
|
||||
case models.NotificationTypeMessage:
|
||||
title = "New Message"
|
||||
body = "You have a new message"
|
||||
body = fmt.Sprintf("%s sent you a message", actorName)
|
||||
|
||||
case models.NotificationTypeBeaconVouch:
|
||||
title = "Beacon Vouched"
|
||||
|
|
@ -379,8 +387,13 @@ func (s *NotificationService) buildPushPayload(req models.PushNotificationReques
|
|||
data["beacon_id"] = req.PostID.String()
|
||||
|
||||
case models.NotificationTypeQuipReaction:
|
||||
title = "New Reaction"
|
||||
body = fmt.Sprintf("%s reacted to your quip", actorName)
|
||||
if emoji != "" {
|
||||
title = fmt.Sprintf("%s %s", actorName, emoji)
|
||||
body = fmt.Sprintf("%s reacted %s to your quip", actorName, emoji)
|
||||
} else {
|
||||
title = "New Reaction"
|
||||
body = fmt.Sprintf("%s reacted to your quip", actorName)
|
||||
}
|
||||
|
||||
default:
|
||||
title = "Sojorn"
|
||||
|
|
@ -429,8 +442,8 @@ func (s *NotificationService) formatPostType(postType string) string {
|
|||
|
||||
// CreateNotification is the legacy method for backwards compatibility
|
||||
func (s *NotificationService) CreateNotification(ctx context.Context, userID, actorID, notificationType string, postID *string, commentID *string, metadata map[string]interface{}) error {
|
||||
actorName, _ := metadata["actor_name"].(string)
|
||||
postType, _ := metadata["post_type"].(string)
|
||||
actorName := getString(metadata, "actor_name")
|
||||
postType := getString(metadata, "post_type")
|
||||
|
||||
req := models.PushNotificationRequest{
|
||||
UserID: uuid.MustParse(userID),
|
||||
|
|
@ -479,6 +492,9 @@ func getString(m map[string]interface{}, key string) string {
|
|||
if str, ok := val.(string); ok {
|
||||
return str
|
||||
}
|
||||
if sPtr, ok := val.(*string); ok && sPtr != nil {
|
||||
return *sPtr
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue