Skip to content

Commit deaf69c

Browse files
committed
subscribers return []user.APIFormat
1 parent 06daf4e commit deaf69c

File tree

3 files changed

+6
-13
lines changed

3 files changed

+6
-13
lines changed

modules/structs/issue.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,3 @@ type EditPriorityOption struct {
113113
// required:true
114114
Priority int `json:"priority"`
115115
}
116-
117-
// IssueWatchers list of subscribers of an issue
118-
type IssueWatchers struct {
119-
// required:true
120-
Subscribers []string `json:"subscribers"`
121-
}

routers/api/v1/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ func RegisterRoutes(m *macaron.Macaron) {
689689
m.Post("/stop", reqToken(), repo.StopIssueStopwatch)
690690
})
691691
m.Group("/subscriptions", func() {
692-
m.Get("", reqToken(), bind(api.IssueWatchers{}), repo.GetIssueWatchers)
692+
m.Get("", reqToken(), bind(api.User{}), repo.GetIssueWatchers)
693693
m.Put("/:user", reqToken(), repo.AddIssueSubscription)
694694
m.Delete("/:user", reqToken(), repo.DelIssueSubscription)
695695
})

routers/api/v1/repo/issue.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ func DelIssueSubscription(ctx *context.APIContext) {
744744
}
745745

746746
// GetIssueWatchers return subscribers of an issue
747-
func GetIssueWatchers(ctx *context.APIContext, form api.IssueWatchers) {
747+
func GetIssueWatchers(ctx *context.APIContext, form api.User) {
748748
// swagger:operation GET /repos/{owner}/{repo}/issues/{index}/subscriptions issue issueSubscriptions
749749
// ---
750750
// summary: Get users who subscribed on an issue.
@@ -785,21 +785,20 @@ func GetIssueWatchers(ctx *context.APIContext, form api.IssueWatchers) {
785785
return
786786
}
787787

788-
var subscribers []string
789-
790788
iw, err := models.GetIssueWatchers(issue.ID)
791789
if err != nil {
792790
ctx.Error(500, "GetIssueWatchers", err)
793791
return
794792
}
795793

796-
for _, s := range iw {
794+
subscribers := make([]*api.User, len(iw))
795+
for i, s := range iw {
797796
user, err := models.GetUserByID(s.UserID)
798797
if err != nil {
799798
continue
800799
}
801-
subscribers = append(subscribers, user.LoginName)
800+
subscribers[i] = user.APIFormat()
802801
}
803802

804-
ctx.JSON(200, api.IssueWatchers{Subscribers: subscribers})
803+
ctx.JSON(200, subscribers)
805804
}

0 commit comments

Comments
 (0)