summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2020-05-01 00:55:24 +0200
committerGitHub <noreply@github.com>2020-04-30 23:55:24 +0100
commite9e8638f1889daaff159427d48c7ef94e13ff707 (patch)
treea51898519f17f866747120706fe9a6ff445b580c /routers
parent4974b7c120102b49548197e58c7a58181ba52170 (diff)
downloadgitea-e9e8638f1889daaff159427d48c7ef94e13ff707.tar.gz
gitea-e9e8638f1889daaff159427d48c7ef94e13ff707.zip
Return issue subscription status from API subscribe (#10966)
* [API] issue subscription indicate by http status * CI.restart()
Diffstat (limited to 'routers')
-rw-r--r--routers/api/v1/repo/issue_subscription.go21
1 files changed, 19 insertions, 2 deletions
diff --git a/routers/api/v1/repo/issue_subscription.go b/routers/api/v1/repo/issue_subscription.go
index 999dda1738..dfccbde64e 100644
--- a/routers/api/v1/repo/issue_subscription.go
+++ b/routers/api/v1/repo/issue_subscription.go
@@ -45,8 +45,10 @@ func AddIssueSubscription(ctx *context.APIContext) {
// type: string
// required: true
// responses:
+ // "200":
+ // description: Already subscribed
// "201":
- // "$ref": "#/responses/empty"
+ // description: Successfully Subscribed
// "304":
// description: User can only subscribe itself if he is no admin
// "404":
@@ -87,8 +89,10 @@ func DelIssueSubscription(ctx *context.APIContext) {
// type: string
// required: true
// responses:
+ // "200":
+ // description: Already unsubscribed
// "201":
- // "$ref": "#/responses/empty"
+ // description: Successfully Unsubscribed
// "304":
// description: User can only subscribe itself if he is no admin
// "404":
@@ -126,6 +130,19 @@ func setIssueSubscription(ctx *context.APIContext, watch bool) {
return
}
+ current, err := models.CheckIssueWatch(user, issue)
+ if err != nil {
+ ctx.Error(http.StatusInternalServerError, "CheckIssueWatch", err)
+ return
+ }
+
+ // If watch state wont change
+ if current == watch {
+ ctx.Status(http.StatusOK)
+ return
+ }
+
+ // Update watch state
if err := models.CreateOrUpdateIssueWatch(user.ID, issue.ID, watch); err != nil {
ctx.Error(http.StatusInternalServerError, "CreateOrUpdateIssueWatch", err)
return