mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Add issue subscription check to API (#10967)
close #10962 Adds `GET /api/v1/repos/{owner}/{repo}/issues/{index}/subscriptions/check` -> return a `WachInfo`
This commit is contained in:
@@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user