Skip to content

Commit

Permalink
feat[backend]: auto subscribe to topics on create
Browse files Browse the repository at this point in the history
  • Loading branch information
darmiel committed Oct 20, 2023
1 parent e604be7 commit 25caf06
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions backend/api/handlers/topic_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ func (h *TopicHandler) AddTopic(ctx *fiber.Ctx) error {
if err != nil {
return ctx.Status(fiber.StatusInternalServerError).JSON(presenter.ErrorResponse(err))
}

// subscribe to topic
if err = h.srv.SubscribeUser(topic.ID, u.UserID); err != nil {
h.logger.Warnf("cannot subscribe user %s (creator) to topic %d: %v", u.UserID, topic.ID, err)
}

return ctx.Status(fiber.StatusCreated).JSON(presenter.SuccessResponse("topic created", topic))
}

Expand Down

0 comments on commit 25caf06

Please sign in to comment.