From b2105de36f64cab816168e82cfa375cde6068081 Mon Sep 17 00:00:00 2001 From: erik Date: Tue, 26 Mar 2024 14:39:25 +0100 Subject: [PATCH] SendLikeActivity to api It might not be a good idea to start a possibly long lasting http call during a running DB transaction. I.E. in the case of failing transaction we already sent some data into the world which might not be valid. --- routers/api/v1/user/star.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/routers/api/v1/user/star.go b/routers/api/v1/user/star.go index d45b1e6488..aaae8cccd0 100644 --- a/routers/api/v1/user/star.go +++ b/routers/api/v1/user/star.go @@ -156,13 +156,21 @@ func Star(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" + userID := ctx.Doer.ID + repoID := ctx.Repo.Repository.ID + // TODO: why is this *context.APIContext passed, where a context.Context is expected? - err := repo_model.StarRepo(ctx, ctx.Doer.ID, ctx.Repo.Repository.ID, true) + err := repo_model.StarRepo(ctx, userID, repoID, true) if err != nil { ctx.Error(http.StatusInternalServerError, "StarRepo", err) return } + if err := repo_model.SendLikeActivities(ctx, userID, repoID); err != nil { + ctx.Error(http.StatusInternalServerError, "StarRepo", err) + return + } + ctx.Status(http.StatusNoContent) }