mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-31 11:52:10 +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:
parent
33176e8d27
commit
bb4261a5ed
8 changed files with 205 additions and 20 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue