summaryrefslogtreecommitdiffstats
path: root/routers/repo/issue.go
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2020-04-21 15:48:53 +0200
committerGitHub <noreply@github.com>2020-04-21 14:48:53 +0100
commitbb4261a5ed678235fadef279fe1ba1505993a406 (patch)
treee3134123a4ccd273ddf5cd93701fef6db21d593b /routers/repo/issue.go
parent33176e8d27eeb47c6d63fbd24bf11ac9e5c60acd (diff)
downloadgitea-bb4261a5ed678235fadef279fe1ba1505993a406.tar.gz
gitea-bb4261a5ed678235fadef279fe1ba1505993a406.zip
Add issue subscription check to API (#10967)
close #10962 Adds `GET /api/v1​/repos​/{owner}​/{repo}​/issues​/{index}​/subscriptions​/check` -> return a `WachInfo`
Diffstat (limited to 'routers/repo/issue.go')
-rw-r--r--routers/repo/issue.go16
1 files changed, 5 insertions, 11 deletions
diff --git a/routers/repo/issue.go b/routers/repo/issue.go
index a7fda4e769..7bce95c9c5 100644
--- a/routers/repo/issue.go
+++ b/routers/repo/issue.go
@@ -749,21 +749,15 @@ func ViewIssue(ctx *context.Context) {
ctx.Data["Title"] = fmt.Sprintf("#%d - %s", issue.Index, issue.Title)
- var iw *models.IssueWatch
- var exists bool
+ iw := new(models.IssueWatch)
if ctx.User != nil {
- iw, exists, err = models.GetIssueWatch(ctx.User.ID, issue.ID)
+ iw.UserID = ctx.User.ID
+ iw.IssueID = issue.ID
+ iw.IsWatching, err = models.CheckIssueWatch(ctx.User, issue)
if err != nil {
- ctx.ServerError("GetIssueWatch", err)
+ ctx.InternalServerError(err)
return
}
- if !exists {
- iw = &models.IssueWatch{
- UserID: ctx.User.ID,
- IssueID: issue.ID,
- IsWatching: models.IsWatching(ctx.User.ID, ctx.Repo.Repository.ID) || models.IsUserParticipantsOfIssue(ctx.User, issue),
- }
- }
}
ctx.Data["IssueWatch"] = iw