feat(notifications): make push messages more specific and include chosen reaction emoji

This commit is contained in:
Patrick Britton 2026-02-04 13:00:05 -06:00
parent 0531e8f878
commit 3c91dc64c9
2 changed files with 15 additions and 7 deletions

View file

@ -465,6 +465,7 @@ func (h *PostHandler) LikePost(c *gin.Context) {
userIDStr.(string),
postID,
postType,
"❤️",
)
}
}()

View file

@ -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: