fix(notifications): use background context for async notifications

This commit is contained in:
Patrick Britton 2026-02-04 12:35:00 -06:00
parent 6e1ba291c0
commit 80d7d92ebd

View file

@ -497,12 +497,13 @@ func (h *PostHandler) SavePost(c *gin.Context) {
// Send push notification to post author
go func() {
post, err := h.postRepo.GetPostByID(c.Request.Context(), postID, userIDStr.(string))
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
}
actor, err := h.userRepo.GetProfileByID(c.Request.Context(), userIDStr.(string))
actor, err := h.userRepo.GetProfileByID(bgCtx, userIDStr.(string))
if err != nil || h.notificationService == nil {
return
}
@ -521,7 +522,7 @@ func (h *PostHandler) SavePost(c *gin.Context) {
"post_type": postType,
}
h.notificationService.CreateNotification(
c.Request.Context(),
context.Background(),
post.AuthorID.String(),
userIDStr.(string),
"save",