mirror of
1
Fork 0

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.
This commit is contained in:
erik 2024-03-26 14:39:25 +01:00
parent bbe5096307
commit b2105de36f
1 changed files with 9 additions and 1 deletions

View File

@ -156,13 +156,21 @@ func Star(ctx *context.APIContext) {
// "404": // "404":
// "$ref": "#/responses/notFound" // "$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? // 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 { if err != nil {
ctx.Error(http.StatusInternalServerError, "StarRepo", err) ctx.Error(http.StatusInternalServerError, "StarRepo", err)
return return
} }
if err := repo_model.SendLikeActivities(ctx, userID, repoID); err != nil {
ctx.Error(http.StatusInternalServerError, "StarRepo", err)
return
}
ctx.Status(http.StatusNoContent) ctx.Status(http.StatusNoContent)
} }