mirror of
https://github.com/go-gitea/gitea
synced 2024-12-25 01:54:26 +00:00
subscribers return []user.APIFormat
This commit is contained in:
parent
06daf4e863
commit
deaf69c801
@ -113,9 +113,3 @@ type EditPriorityOption struct {
|
|||||||
// required:true
|
// required:true
|
||||||
Priority int `json:"priority"`
|
Priority int `json:"priority"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// IssueWatchers list of subscribers of an issue
|
|
||||||
type IssueWatchers struct {
|
|
||||||
// required:true
|
|
||||||
Subscribers []string `json:"subscribers"`
|
|
||||||
}
|
|
||||||
|
@ -689,7 +689,7 @@ func RegisterRoutes(m *macaron.Macaron) {
|
|||||||
m.Post("/stop", reqToken(), repo.StopIssueStopwatch)
|
m.Post("/stop", reqToken(), repo.StopIssueStopwatch)
|
||||||
})
|
})
|
||||||
m.Group("/subscriptions", func() {
|
m.Group("/subscriptions", func() {
|
||||||
m.Get("", reqToken(), bind(api.IssueWatchers{}), repo.GetIssueWatchers)
|
m.Get("", reqToken(), bind(api.User{}), repo.GetIssueWatchers)
|
||||||
m.Put("/:user", reqToken(), repo.AddIssueSubscription)
|
m.Put("/:user", reqToken(), repo.AddIssueSubscription)
|
||||||
m.Delete("/:user", reqToken(), repo.DelIssueSubscription)
|
m.Delete("/:user", reqToken(), repo.DelIssueSubscription)
|
||||||
})
|
})
|
||||||
|
@ -744,7 +744,7 @@ func DelIssueSubscription(ctx *context.APIContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetIssueWatchers return subscribers of an issue
|
// GetIssueWatchers return subscribers of an issue
|
||||||
func GetIssueWatchers(ctx *context.APIContext, form api.IssueWatchers) {
|
func GetIssueWatchers(ctx *context.APIContext, form api.User) {
|
||||||
// swagger:operation GET /repos/{owner}/{repo}/issues/{index}/subscriptions issue issueSubscriptions
|
// swagger:operation GET /repos/{owner}/{repo}/issues/{index}/subscriptions issue issueSubscriptions
|
||||||
// ---
|
// ---
|
||||||
// summary: Get users who subscribed on an issue.
|
// summary: Get users who subscribed on an issue.
|
||||||
@ -785,21 +785,20 @@ func GetIssueWatchers(ctx *context.APIContext, form api.IssueWatchers) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var subscribers []string
|
|
||||||
|
|
||||||
iw, err := models.GetIssueWatchers(issue.ID)
|
iw, err := models.GetIssueWatchers(issue.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Error(500, "GetIssueWatchers", err)
|
ctx.Error(500, "GetIssueWatchers", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range iw {
|
subscribers := make([]*api.User, len(iw))
|
||||||
|
for i, s := range iw {
|
||||||
user, err := models.GetUserByID(s.UserID)
|
user, err := models.GetUserByID(s.UserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
subscribers = append(subscribers, user.LoginName)
|
subscribers[i] = user.APIFormat()
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.JSON(200, api.IssueWatchers{Subscribers: subscribers})
|
ctx.JSON(200, subscribers)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user