feat(notifications): improve reaction notification titles with emojis

This commit is contained in:
Patrick Britton 2026-02-04 12:57:44 -06:00
parent 23bf5a15b4
commit 0531e8f878

View file

@ -321,10 +321,18 @@ func (s *NotificationService) buildPushPayload(req models.PushNotificationReques
} }
} }
// Extract optional emoji
emoji, _ := req.Metadata["emoji"].(string)
switch req.Type { switch req.Type {
case models.NotificationTypeLike: case models.NotificationTypeLike:
title = "New Like" if emoji != "" {
body = fmt.Sprintf("%s liked your %s", actorName, s.formatPostType(req.PostType)) 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: case models.NotificationTypeComment:
title = "New Comment" title = "New Comment"
@ -366,7 +374,7 @@ func (s *NotificationService) buildPushPayload(req models.PushNotificationReques
case models.NotificationTypeMessage: case models.NotificationTypeMessage:
title = "New Message" title = "New Message"
body = "You have a new message" body = fmt.Sprintf("%s sent you a message", actorName)
case models.NotificationTypeBeaconVouch: case models.NotificationTypeBeaconVouch:
title = "Beacon Vouched" title = "Beacon Vouched"
@ -379,8 +387,13 @@ func (s *NotificationService) buildPushPayload(req models.PushNotificationReques
data["beacon_id"] = req.PostID.String() data["beacon_id"] = req.PostID.String()
case models.NotificationTypeQuipReaction: case models.NotificationTypeQuipReaction:
title = "New Reaction" if emoji != "" {
body = fmt.Sprintf("%s reacted to your quip", actorName) 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: default:
title = "Sojorn" title = "Sojorn"
@ -429,8 +442,8 @@ func (s *NotificationService) formatPostType(postType string) string {
// CreateNotification is the legacy method for backwards compatibility // 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 { 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) actorName := getString(metadata, "actor_name")
postType, _ := metadata["post_type"].(string) postType := getString(metadata, "post_type")
req := models.PushNotificationRequest{ req := models.PushNotificationRequest{
UserID: uuid.MustParse(userID), UserID: uuid.MustParse(userID),
@ -479,6 +492,9 @@ func getString(m map[string]interface{}, key string) string {
if str, ok := val.(string); ok { if str, ok := val.(string); ok {
return str return str
} }
if sPtr, ok := val.(*string); ok && sPtr != nil {
return *sPtr
}
} }
return "" return ""
} }