Fix Comment permission checking

This commit is contained in:
Anthony Wang 2022-09-23 17:30:44 +00:00
parent 379b9a7dce
commit f9d9019720
Signed by: a
GPG key ID: 42A5B952E6DD8D38
2 changed files with 4 additions and 4 deletions

View file

@ -27,7 +27,7 @@ func Comment(ctx context.Context, note *ap.Note) error {
contextSplit := strings.Split(context.String(), "/")
username := contextSplit[3]
reponame := contextSplit[4]
repo, _ := repo_model.GetRepositoryByOwnerAndName(username, reponame)
repo, _ := repo_model.GetRepositoryByOwnerAndNameCtx(ctx, username, reponame)
idx, _ := strconv.ParseInt(contextSplit[len(contextSplit)-1], 10, 64)
issue, _ := issues.GetIssueByIndex(repo.ID, idx)

View file

@ -50,17 +50,17 @@ func Ticket(ctx *context.APIContext) {
repo, err := repo_model.GetRepositoryByOwnerAndNameCtx(ctx, ctx.ContextUser.Name, ctx.Repo.Repository.Name)
if err != nil {
ctx.ServerError("Couldn't get repo", err)
ctx.ServerError("GetRepositoryByOwnerAndNameCtx", err)
return
}
index, err := strconv.ParseInt(ctx.Params("id"), 10, 64)
if err != nil {
ctx.ServerError("ID must be an integer", err)
ctx.ServerError("ParseInt", err)
return
}
issue, err := issues_model.GetIssueByIndex(repo.ID, index)
if err != nil {
ctx.ServerError("Couldn't get issue", err)
ctx.ServerError("GetIssueByIndex", err)
return
}