aboutsummaryrefslogtreecommitdiffstats
path: root/routers/repo
diff options
context:
space:
mode:
Diffstat (limited to 'routers/repo')
-rw-r--r--routers/repo/issue.go47
-rw-r--r--routers/repo/pull.go4
2 files changed, 51 insertions, 0 deletions
diff --git a/routers/repo/issue.go b/routers/repo/issue.go
index eec0b7fd96..b999f2f51b 100644
--- a/routers/repo/issue.go
+++ b/routers/repo/issue.go
@@ -274,6 +274,11 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
return
}
+ handleTeamMentions(ctx)
+ if ctx.Written() {
+ return
+ }
+
labels, err := models.GetLabelsByRepoID(repo.ID, "", models.ListOptions{})
if err != nil {
ctx.ServerError("GetLabelsByRepoID", err)
@@ -410,6 +415,11 @@ func RetrieveRepoMilestonesAndAssignees(ctx *context.Context, repo *models.Repos
ctx.ServerError("GetAssignees", err)
return
}
+
+ handleTeamMentions(ctx)
+ if ctx.Written() {
+ return
+ }
}
func retrieveProjects(ctx *context.Context, repo *models.Repository) {
@@ -2445,3 +2455,40 @@ func combineLabelComments(issue *models.Issue) {
i--
}
}
+
+// get all teams that current user can mention
+func handleTeamMentions(ctx *context.Context) {
+ if ctx.User == nil || !ctx.Repo.Owner.IsOrganization() {
+ return
+ }
+
+ isAdmin := false
+ var err error
+ // Admin has super access.
+ if ctx.User.IsAdmin {
+ isAdmin = true
+ } else {
+ isAdmin, err = ctx.Repo.Owner.IsOwnedBy(ctx.User.ID)
+ if err != nil {
+ ctx.ServerError("IsOwnedBy", err)
+ return
+ }
+ }
+
+ if isAdmin {
+ if err := ctx.Repo.Owner.GetTeams(&models.SearchTeamOptions{}); err != nil {
+ ctx.ServerError("GetTeams", err)
+ return
+ }
+ } else {
+ ctx.Repo.Owner.Teams, err = ctx.Repo.Owner.GetUserTeams(ctx.User.ID)
+ if err != nil {
+ ctx.ServerError("GetUserTeams", err)
+ return
+ }
+ }
+
+ ctx.Data["MentionableTeams"] = ctx.Repo.Owner.Teams
+ ctx.Data["MentionableTeamsOrg"] = ctx.Repo.Owner.Name
+ ctx.Data["MentionableTeamsOrgAvator"] = ctx.Repo.Owner.RelAvatarLink()
+}
diff --git a/routers/repo/pull.go b/routers/repo/pull.go
index 901a668632..442379c43b 100644
--- a/routers/repo/pull.go
+++ b/routers/repo/pull.go
@@ -684,6 +684,10 @@ func ViewPullFiles(ctx *context.Context) {
ctx.ServerError("GetAssignees", err)
return
}
+ handleTeamMentions(ctx)
+ if ctx.Written() {
+ return
+ }
ctx.Data["CurrentReview"], err = models.GetCurrentReview(ctx.User, issue)
if err != nil && !models.IsErrReviewNotExist(err) {
ctx.ServerError("GetCurrentReview", err)