From 1c654ad7b5004ea7c8b5b4e424579bf9ac798803 Mon Sep 17 00:00:00 2001 From: Patrick Britton Date: Wed, 4 Feb 2026 11:35:58 -0600 Subject: [PATCH] feat: added notifications for post reactions --- go-backend/internal/handlers/post_handler.go | 52 ++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/go-backend/internal/handlers/post_handler.go b/go-backend/internal/handlers/post_handler.go index 7f3aab7..0ac877f 100644 --- a/go-backend/internal/handlers/post_handler.go +++ b/go-backend/internal/handlers/post_handler.go @@ -779,6 +779,58 @@ func (h *PostHandler) ToggleReaction(c *gin.Context) { return } + // Check if reaction was added (exists in myReactions) + reactionAdded := false + for _, r := range myReactions { + if r == emoji { + reactionAdded = true + break + } + } + + if reactionAdded { + go func() { + bgCtx := context.Background() + post, err := h.postRepo.GetPostByID(bgCtx, postID, userIDStr.(string)) + if err != nil || post.AuthorID.String() == userIDStr.(string) { + return // Don't notify self + } + + if h.notificationService != nil { + // Get actor details + actor, err := h.userRepo.GetProfileByID(bgCtx, userIDStr.(string)) + if err != nil { + return + } + + metadata := map[string]interface{}{ + "actor_name": actor.DisplayName, + "post_id": postID, + "emoji": emoji, + } + + // Using "like" type for now, or "quip_reaction" if quip + notifType := "like" + if post.VideoURL != nil && *post.VideoURL != "" { + notifType = "quip_reaction" + metadata["post_type"] = "quip" + } else { + metadata["post_type"] = "post" + } + + h.notificationService.CreateNotification( + bgCtx, + post.AuthorID.String(), + userIDStr.(string), + notifType, + &postID, + nil, + metadata, + ) + } + }() + } + c.JSON(http.StatusOK, gin.H{ "reactions": counts, "my_reactions": myReactions,