fix(notifications): use background context for async notifications
This commit is contained in:
parent
6e1ba291c0
commit
80d7d92ebd
|
|
@ -497,12 +497,13 @@ func (h *PostHandler) SavePost(c *gin.Context) {
|
||||||
|
|
||||||
// Send push notification to post author
|
// Send push notification to post author
|
||||||
go func() {
|
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) {
|
if err != nil || post.AuthorID.String() == userIDStr.(string) {
|
||||||
return // Don't notify self
|
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 {
|
if err != nil || h.notificationService == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -521,7 +522,7 @@ func (h *PostHandler) SavePost(c *gin.Context) {
|
||||||
"post_type": postType,
|
"post_type": postType,
|
||||||
}
|
}
|
||||||
h.notificationService.CreateNotification(
|
h.notificationService.CreateNotification(
|
||||||
c.Request.Context(),
|
context.Background(),
|
||||||
post.AuthorID.String(),
|
post.AuthorID.String(),
|
||||||
userIDStr.(string),
|
userIDStr.(string),
|
||||||
"save",
|
"save",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue