From 3c91dc64c9acf855a2bb11933d249b5dfa0a18f5 Mon Sep 17 00:00:00 2001 From: Patrick Britton Date: Wed, 4 Feb 2026 13:00:05 -0600 Subject: [PATCH] feat(notifications): make push messages more specific and include chosen reaction emoji --- go-backend/internal/handlers/post_handler.go | 1 + .../internal/services/notification_service.go | 21 ++++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/go-backend/internal/handlers/post_handler.go b/go-backend/internal/handlers/post_handler.go index 111e98a..1788a35 100644 --- a/go-backend/internal/handlers/post_handler.go +++ b/go-backend/internal/handlers/post_handler.go @@ -465,6 +465,7 @@ func (h *PostHandler) LikePost(c *gin.Context) { userIDStr.(string), postID, postType, + "❤️", ) } }() diff --git a/go-backend/internal/services/notification_service.go b/go-backend/internal/services/notification_service.go index 7ff4d2a..038c279 100644 --- a/go-backend/internal/services/notification_service.go +++ b/go-backend/internal/services/notification_service.go @@ -30,11 +30,15 @@ func NewNotificationService(notifRepo *repository.NotificationRepository, pushSv // ============================================================================ // NotifyLike sends a notification when someone likes a post -func (s *NotificationService) NotifyLike(ctx context.Context, postAuthorID, actorID, postID string, postType string) error { +func (s *NotificationService) NotifyLike(ctx context.Context, postAuthorID, actorID, postID string, postType string, emoji string) error { if postAuthorID == actorID { return nil // Don't notify self } + if emoji == "" { + emoji = "❤️" + } + return s.sendNotification(ctx, models.PushNotificationRequest{ UserID: uuid.MustParse(postAuthorID), Type: models.NotificationTypeLike, @@ -43,6 +47,9 @@ func (s *NotificationService) NotifyLike(ctx context.Context, postAuthorID, acto PostType: postType, GroupKey: fmt.Sprintf("like:%s", postID), // Group likes on same post Priority: models.PriorityNormal, + Metadata: map[string]interface{}{ + "emoji": emoji, + }, }) } @@ -322,28 +329,28 @@ func (s *NotificationService) buildPushPayload(req models.PushNotificationReques } // Extract optional emoji - emoji, _ := req.Metadata["emoji"].(string) + emoji := getString(req.Metadata, "emoji") switch req.Type { case models.NotificationTypeLike: if emoji != "" { title = fmt.Sprintf("%s %s", actorName, emoji) - body = fmt.Sprintf("%s reacted %s to your %s", actorName, emoji, s.formatPostType(req.PostType)) + body = fmt.Sprintf("%s %s 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" + title = fmt.Sprintf("%s 💬", actorName) body = fmt.Sprintf("%s commented on your %s", actorName, s.formatPostType(req.PostType)) case models.NotificationTypeReply: - title = "New Reply" + title = fmt.Sprintf("%s 💬", actorName) body = fmt.Sprintf("%s replied to your comment", actorName) case models.NotificationTypeMention: - title = "You Were Mentioned" + title = "Mentioned" body = fmt.Sprintf("%s mentioned you in a post", actorName) case models.NotificationTypeFollow: @@ -373,7 +380,7 @@ func (s *NotificationService) buildPushPayload(req models.PushNotificationReques body = fmt.Sprintf("%s saved your %s", actorName, s.formatPostType(req.PostType)) case models.NotificationTypeMessage: - title = "New Message" + title = fmt.Sprintf("%s ✉️", actorName) body = fmt.Sprintf("%s sent you a message", actorName) case models.NotificationTypeBeaconVouch: