summaryrefslogtreecommitdiffstats
path: root/modules/markup/html.go
diff options
context:
space:
mode:
authora1012112796 <1012112796@qq.com>2020-12-21 23:39:28 +0800
committerGitHub <noreply@github.com>2020-12-21 16:39:28 +0100
commit34df4e5df558e7ec648efe083696687be6f8c8a8 (patch)
tree883e619552a901b4a7437e8574e7307b47c1ac1d /modules/markup/html.go
parent1b1adab26cbe86d77ee0e9a35b18d4765b371e26 (diff)
downloadgitea-34df4e5df558e7ec648efe083696687be6f8c8a8.tar.gz
gitea-34df4e5df558e7ec648efe083696687be6f8c8a8.zip
Add mentionable teams to tributeValues and change team mention rules to gh's style (#13198)
* Add mentionable teams to tributeValues Signed-off-by: a1012112796 <1012112796@qq.com> * Apply suggestions from code review Co-authored-by: silverwind <me@silverwind.io> * Change team mention rules to gh's style * use org's avator as team avator in ui Signed-off-by: a1012112796 <1012112796@qq.com> * Update modules/markup/html.go * Update models/issue.go Co-authored-by: Lauris BH <lauris@nix.lv> * Update models/issue.go * fix a small nit and update test code Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'modules/markup/html.go')
-rw-r--r--modules/markup/html.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/modules/markup/html.go b/modules/markup/html.go
index 586343fae1..7ac23d0503 100644
--- a/modules/markup/html.go
+++ b/modules/markup/html.go
@@ -596,11 +596,15 @@ func mentionProcessor(ctx *postProcessCtx, node *html.Node) {
mention := node.Data[loc.Start:loc.End]
var teams string
teams, ok := ctx.metas["teams"]
- if ok && strings.Contains(teams, ","+strings.ToLower(mention[1:])+",") {
- replaceContent(node, loc.Start, loc.End, createLink(util.URLJoin(setting.AppURL, "org", ctx.metas["org"], "teams", mention[1:]), mention, "mention"))
- } else {
- replaceContent(node, loc.Start, loc.End, createLink(util.URLJoin(setting.AppURL, mention[1:]), mention, "mention"))
+ // team mention should follow @orgName/teamName style
+ if ok && strings.Contains(mention, "/") {
+ mentionOrgAndTeam := strings.Split(mention, "/")
+ if mentionOrgAndTeam[0][1:] == ctx.metas["org"] && strings.Contains(teams, ","+strings.ToLower(mentionOrgAndTeam[1])+",") {
+ replaceContent(node, loc.Start, loc.End, createLink(util.URLJoin(setting.AppURL, "org", ctx.metas["org"], "teams", mentionOrgAndTeam[1]), mention, "mention"))
+ }
+ return
}
+ replaceContent(node, loc.Start, loc.End, createLink(util.URLJoin(setting.AppURL, mention[1:]), mention, "mention"))
}
func shortLinkProcessor(ctx *postProcessCtx, node *html.Node) {