Skip to content

Commit fb3a6ab

Browse files
jolheiserzeripath
authored andcommitted
Only show sender if it makes sense (#9601)
Signed-off-by: jolheiser <[email protected]>
1 parent 07439d8 commit fb3a6ab

File tree

7 files changed

+71
-65
lines changed

7 files changed

+71
-65
lines changed

modules/webhook/dingtalk.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func getDingtalkPushPayload(p *api.PushPayload) (*DingtalkPayload, error) {
132132
}
133133

134134
func getDingtalkIssuesPayload(p *api.IssuePayload) (*DingtalkPayload, error) {
135-
text, issueTitle, attachmentText, _ := getIssuesPayloadInfo(p, noneLinkFormatter)
135+
text, issueTitle, attachmentText, _ := getIssuesPayloadInfo(p, noneLinkFormatter, true)
136136

137137
return &DingtalkPayload{
138138
MsgType: "actionCard",
@@ -148,7 +148,7 @@ func getDingtalkIssuesPayload(p *api.IssuePayload) (*DingtalkPayload, error) {
148148
}
149149

150150
func getDingtalkIssueCommentPayload(p *api.IssueCommentPayload) (*DingtalkPayload, error) {
151-
text, issueTitle, _ := getIssueCommentPayloadInfo(p, noneLinkFormatter)
151+
text, issueTitle, _ := getIssueCommentPayloadInfo(p, noneLinkFormatter, true)
152152

153153
return &DingtalkPayload{
154154
MsgType: "actionCard",
@@ -163,7 +163,7 @@ func getDingtalkIssueCommentPayload(p *api.IssueCommentPayload) (*DingtalkPayloa
163163
}
164164

165165
func getDingtalkPullRequestPayload(p *api.PullRequestPayload) (*DingtalkPayload, error) {
166-
text, issueTitle, attachmentText, _ := getPullRequestPayloadInfo(p, noneLinkFormatter)
166+
text, issueTitle, attachmentText, _ := getPullRequestPayloadInfo(p, noneLinkFormatter, true)
167167

168168
return &DingtalkPayload{
169169
MsgType: "actionCard",
@@ -236,7 +236,7 @@ func getDingtalkRepositoryPayload(p *api.RepositoryPayload) (*DingtalkPayload, e
236236
}
237237

238238
func getDingtalkReleasePayload(p *api.ReleasePayload) (*DingtalkPayload, error) {
239-
text, _ := getReleasePayloadInfo(p, noneLinkFormatter)
239+
text, _ := getReleasePayloadInfo(p, noneLinkFormatter, true)
240240

241241
return &DingtalkPayload{
242242
MsgType: "actionCard",

modules/webhook/discord.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ func getDiscordPushPayload(p *api.PushPayload, meta *DiscordMeta) (*DiscordPaylo
227227
}
228228

229229
func getDiscordIssuesPayload(p *api.IssuePayload, meta *DiscordMeta) (*DiscordPayload, error) {
230-
text, _, attachmentText, color := getIssuesPayloadInfo(p, noneLinkFormatter)
230+
text, _, attachmentText, color := getIssuesPayloadInfo(p, noneLinkFormatter, false)
231231

232232
return &DiscordPayload{
233233
Username: meta.Username,
@@ -249,7 +249,7 @@ func getDiscordIssuesPayload(p *api.IssuePayload, meta *DiscordMeta) (*DiscordPa
249249
}
250250

251251
func getDiscordIssueCommentPayload(p *api.IssueCommentPayload, discord *DiscordMeta) (*DiscordPayload, error) {
252-
text, _, color := getIssueCommentPayloadInfo(p, noneLinkFormatter)
252+
text, _, color := getIssueCommentPayloadInfo(p, noneLinkFormatter, false)
253253

254254
return &DiscordPayload{
255255
Username: discord.Username,
@@ -271,7 +271,7 @@ func getDiscordIssueCommentPayload(p *api.IssueCommentPayload, discord *DiscordM
271271
}
272272

273273
func getDiscordPullRequestPayload(p *api.PullRequestPayload, meta *DiscordMeta) (*DiscordPayload, error) {
274-
text, _, attachmentText, color := getPullRequestPayloadInfo(p, noneLinkFormatter)
274+
text, _, attachmentText, color := getPullRequestPayloadInfo(p, noneLinkFormatter, false)
275275

276276
return &DiscordPayload{
277277
Username: meta.Username,
@@ -368,7 +368,7 @@ func getDiscordRepositoryPayload(p *api.RepositoryPayload, meta *DiscordMeta) (*
368368
}
369369

370370
func getDiscordReleasePayload(p *api.ReleasePayload, meta *DiscordMeta) (*DiscordPayload, error) {
371-
text, color := getReleasePayloadInfo(p, noneLinkFormatter)
371+
text, color := getReleasePayloadInfo(p, noneLinkFormatter, false)
372372

373373
return &DiscordPayload{
374374
Username: meta.Username,

modules/webhook/general.go

Lines changed: 49 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ func htmlLinkFormatter(url string, text string) string {
2525
return fmt.Sprintf(`<a href="%s">%s</a>`, url, html.EscapeString(text))
2626
}
2727

28-
func getIssuesPayloadInfo(p *api.IssuePayload, linkFormatter linkFormatter) (string, string, string, int) {
29-
senderLink := linkFormatter(setting.AppURL+p.Sender.UserName, p.Sender.UserName)
28+
func getIssuesPayloadInfo(p *api.IssuePayload, linkFormatter linkFormatter, withSender bool) (string, string, string, int) {
3029
repoLink := linkFormatter(p.Repository.HTMLURL, p.Repository.FullName)
3130
issueTitle := fmt.Sprintf("#%d %s", p.Index, p.Issue.Title)
3231
titleLink := linkFormatter(fmt.Sprintf("%s/issues/%d", p.Repository.HTMLURL, p.Index), issueTitle)
@@ -35,34 +34,36 @@ func getIssuesPayloadInfo(p *api.IssuePayload, linkFormatter linkFormatter) (str
3534

3635
switch p.Action {
3736
case api.HookIssueOpened:
38-
text = fmt.Sprintf("[%s] Issue opened: %s by %s", repoLink, titleLink, senderLink)
37+
text = fmt.Sprintf("[%s] Issue opened: %s", repoLink, titleLink)
3938
color = orangeColor
4039
case api.HookIssueClosed:
41-
text = fmt.Sprintf("[%s] Issue closed: %s by %s", repoLink, titleLink, senderLink)
40+
text = fmt.Sprintf("[%s] Issue closed: %s", repoLink, titleLink)
4241
color = redColor
4342
case api.HookIssueReOpened:
44-
text = fmt.Sprintf("[%s] Issue re-opened: %s by %s", repoLink, titleLink, senderLink)
43+
text = fmt.Sprintf("[%s] Issue re-opened: %s", repoLink, titleLink)
4544
case api.HookIssueEdited:
46-
text = fmt.Sprintf("[%s] Issue edited: %s by %s", repoLink, titleLink, senderLink)
45+
text = fmt.Sprintf("[%s] Issue edited: %s", repoLink, titleLink)
4746
case api.HookIssueAssigned:
48-
text = fmt.Sprintf("[%s] Issue assigned to %s: %s by %s", repoLink,
49-
linkFormatter(setting.AppURL+p.Issue.Assignee.UserName, p.Issue.Assignee.UserName),
50-
titleLink, senderLink)
47+
text = fmt.Sprintf("[%s] Issue assigned to %s: %s", repoLink,
48+
linkFormatter(setting.AppURL+p.Issue.Assignee.UserName, p.Issue.Assignee.UserName), titleLink)
5149
color = greenColor
5250
case api.HookIssueUnassigned:
53-
text = fmt.Sprintf("[%s] Issue unassigned: %s by %s", repoLink, titleLink, senderLink)
51+
text = fmt.Sprintf("[%s] Issue unassigned: %s", repoLink, titleLink)
5452
case api.HookIssueLabelUpdated:
55-
text = fmt.Sprintf("[%s] Issue labels updated: %s by %s", repoLink, titleLink, senderLink)
53+
text = fmt.Sprintf("[%s] Issue labels updated: %s", repoLink, titleLink)
5654
case api.HookIssueLabelCleared:
57-
text = fmt.Sprintf("[%s] Issue labels cleared: %s by %s", repoLink, titleLink, senderLink)
55+
text = fmt.Sprintf("[%s] Issue labels cleared: %s", repoLink, titleLink)
5856
case api.HookIssueSynchronized:
59-
text = fmt.Sprintf("[%s] Issue synchronized: %s by %s", repoLink, titleLink, senderLink)
57+
text = fmt.Sprintf("[%s] Issue synchronized: %s", repoLink, titleLink)
6058
case api.HookIssueMilestoned:
6159
mileStoneLink := fmt.Sprintf("%s/milestone/%d", p.Repository.HTMLURL, p.Issue.Milestone.ID)
62-
text = fmt.Sprintf("[%s] Issue milestoned to %s: %s by %s", repoLink,
63-
linkFormatter(mileStoneLink, p.Issue.Milestone.Title), titleLink, senderLink)
60+
text = fmt.Sprintf("[%s] Issue milestoned to %s: %s", repoLink,
61+
linkFormatter(mileStoneLink, p.Issue.Milestone.Title), titleLink)
6462
case api.HookIssueDemilestoned:
65-
text = fmt.Sprintf("[%s] Issue milestone cleared: %s by %s", repoLink, titleLink, senderLink)
63+
text = fmt.Sprintf("[%s] Issue milestone cleared: %s", repoLink, titleLink)
64+
}
65+
if withSender {
66+
text += fmt.Sprintf(" by %s", linkFormatter(setting.AppURL+p.Sender.UserName, p.Sender.UserName))
6667
}
6768

6869
var attachmentText string
@@ -73,8 +74,7 @@ func getIssuesPayloadInfo(p *api.IssuePayload, linkFormatter linkFormatter) (str
7374
return text, issueTitle, attachmentText, color
7475
}
7576

76-
func getPullRequestPayloadInfo(p *api.PullRequestPayload, linkFormatter linkFormatter) (string, string, string, int) {
77-
senderLink := linkFormatter(setting.AppURL+p.Sender.UserName, p.Sender.UserName)
77+
func getPullRequestPayloadInfo(p *api.PullRequestPayload, linkFormatter linkFormatter, withSender bool) (string, string, string, int) {
7878
repoLink := linkFormatter(p.Repository.HTMLURL, p.Repository.FullName)
7979
issueTitle := fmt.Sprintf("#%d %s", p.Index, p.PullRequest.Title)
8080
titleLink := linkFormatter(p.PullRequest.URL, issueTitle)
@@ -83,43 +83,45 @@ func getPullRequestPayloadInfo(p *api.PullRequestPayload, linkFormatter linkForm
8383

8484
switch p.Action {
8585
case api.HookIssueOpened:
86-
text = fmt.Sprintf("[%s] Pull request %s opened by %s", repoLink, titleLink, senderLink)
86+
text = fmt.Sprintf("[%s] Pull request opened: %s", repoLink, titleLink)
8787
color = greenColor
8888
case api.HookIssueClosed:
8989
if p.PullRequest.HasMerged {
90-
text = fmt.Sprintf("[%s] Pull request %s merged by %s", repoLink, titleLink, senderLink)
90+
text = fmt.Sprintf("[%s] Pull request merged: %s", repoLink, titleLink)
9191
color = purpleColor
9292
} else {
93-
text = fmt.Sprintf("[%s] Pull request %s closed by %s", repoLink, titleLink, senderLink)
93+
text = fmt.Sprintf("[%s] Pull request closed: %s", repoLink, titleLink)
9494
color = redColor
9595
}
9696
case api.HookIssueReOpened:
97-
text = fmt.Sprintf("[%s] Pull request %s re-opened by %s", repoLink, titleLink, senderLink)
97+
text = fmt.Sprintf("[%s] Pull request re-opened: %s", repoLink, titleLink)
9898
case api.HookIssueEdited:
99-
text = fmt.Sprintf("[%s] Pull request %s edited by %s", repoLink, titleLink, senderLink)
99+
text = fmt.Sprintf("[%s] Pull request edited: %s", repoLink, titleLink)
100100
case api.HookIssueAssigned:
101101
list := make([]string, len(p.PullRequest.Assignees))
102102
for i, user := range p.PullRequest.Assignees {
103103
list[i] = linkFormatter(setting.AppURL+user.UserName, user.UserName)
104104
}
105-
text = fmt.Sprintf("[%s] Pull request %s assigned to %s by %s", repoLink,
106-
strings.Join(list, ", "),
107-
titleLink, senderLink)
105+
text = fmt.Sprintf("[%s] Pull request assigned: %s to %s", repoLink,
106+
strings.Join(list, ", "), titleLink)
108107
color = greenColor
109108
case api.HookIssueUnassigned:
110-
text = fmt.Sprintf("[%s] Pull request %s unassigned by %s", repoLink, titleLink, senderLink)
109+
text = fmt.Sprintf("[%s] Pull request unassigned: %s", repoLink, titleLink)
111110
case api.HookIssueLabelUpdated:
112-
text = fmt.Sprintf("[%s] Pull request %s labels updated by %s", repoLink, titleLink, senderLink)
111+
text = fmt.Sprintf("[%s] Pull request labels updated: %s", repoLink, titleLink)
113112
case api.HookIssueLabelCleared:
114-
text = fmt.Sprintf("[%s] Pull request %s labels cleared by %s", repoLink, titleLink, senderLink)
113+
text = fmt.Sprintf("[%s] Pull request labels cleared: %s", repoLink, titleLink)
115114
case api.HookIssueSynchronized:
116-
text = fmt.Sprintf("[%s] Pull request %s synchronized by %s", repoLink, titleLink, senderLink)
115+
text = fmt.Sprintf("[%s] Pull request synchronized: %s", repoLink, titleLink)
117116
case api.HookIssueMilestoned:
118117
mileStoneLink := fmt.Sprintf("%s/milestone/%d", p.Repository.HTMLURL, p.PullRequest.Milestone.ID)
119-
text = fmt.Sprintf("[%s] Pull request %s milestoned to %s by %s", repoLink,
120-
linkFormatter(mileStoneLink, p.PullRequest.Milestone.Title), titleLink, senderLink)
118+
text = fmt.Sprintf("[%s] Pull request milestoned: %s to %s", repoLink,
119+
linkFormatter(mileStoneLink, p.PullRequest.Milestone.Title), titleLink)
121120
case api.HookIssueDemilestoned:
122-
text = fmt.Sprintf("[%s] Pull request %s milestone cleared by %s", repoLink, titleLink, senderLink)
121+
text = fmt.Sprintf("[%s] Pull request milestone cleared: %s", repoLink, titleLink)
122+
}
123+
if withSender {
124+
text += fmt.Sprintf(" by %s", linkFormatter(setting.AppURL+p.Sender.UserName, p.Sender.UserName))
123125
}
124126

125127
var attachmentText string
@@ -130,28 +132,29 @@ func getPullRequestPayloadInfo(p *api.PullRequestPayload, linkFormatter linkForm
130132
return text, issueTitle, attachmentText, color
131133
}
132134

133-
func getReleasePayloadInfo(p *api.ReleasePayload, linkFormatter linkFormatter) (text string, color int) {
134-
senderLink := linkFormatter(setting.AppURL+p.Sender.UserName, p.Sender.UserName)
135+
func getReleasePayloadInfo(p *api.ReleasePayload, linkFormatter linkFormatter, withSender bool) (text string, color int) {
135136
repoLink := linkFormatter(p.Repository.HTMLURL, p.Repository.FullName)
136137
refLink := linkFormatter(p.Repository.HTMLURL+"/src/"+p.Release.TagName, p.Release.TagName)
137138

138139
switch p.Action {
139140
case api.HookReleasePublished:
140-
text = fmt.Sprintf("[%s] Release %s created by %s", repoLink, refLink, senderLink)
141+
text = fmt.Sprintf("[%s] Release created: %s", repoLink, refLink)
141142
color = greenColor
142143
case api.HookReleaseUpdated:
143-
text = fmt.Sprintf("[%s] Release %s updated by %s", repoLink, refLink, senderLink)
144+
text = fmt.Sprintf("[%s] Release updated: %s", repoLink, refLink)
144145
color = yellowColor
145146
case api.HookReleaseDeleted:
146-
text = fmt.Sprintf("[%s] Release %s deleted by %s", repoLink, refLink, senderLink)
147+
text = fmt.Sprintf("[%s] Release deleted: %s", repoLink, refLink)
147148
color = redColor
148149
}
150+
if withSender {
151+
text += fmt.Sprintf(" by %s", linkFormatter(setting.AppURL+p.Sender.UserName, p.Sender.UserName))
152+
}
149153

150154
return text, color
151155
}
152156

153-
func getIssueCommentPayloadInfo(p *api.IssueCommentPayload, linkFormatter linkFormatter) (string, string, int) {
154-
senderLink := linkFormatter(setting.AppURL+p.Sender.UserName, p.Sender.UserName)
157+
func getIssueCommentPayloadInfo(p *api.IssueCommentPayload, linkFormatter linkFormatter, withSender bool) (string, string, int) {
155158
repoLink := linkFormatter(p.Repository.HTMLURL, p.Repository.FullName)
156159
issueTitle := fmt.Sprintf("#%d %s", p.Issue.Index, p.Issue.Title)
157160

@@ -168,18 +171,21 @@ func getIssueCommentPayloadInfo(p *api.IssueCommentPayload, linkFormatter linkFo
168171

169172
switch p.Action {
170173
case api.HookIssueCommentCreated:
171-
text = fmt.Sprintf("[%s] New comment on %s %s by %s", repoLink, typ, titleLink, senderLink)
174+
text = fmt.Sprintf("[%s] New comment on %s %s", repoLink, typ, titleLink)
172175
if p.IsPull {
173176
color = greenColorLight
174177
} else {
175178
color = orangeColorLight
176179
}
177180
case api.HookIssueCommentEdited:
178-
text = fmt.Sprintf("[%s] Comment on %s %s edited by %s", repoLink, typ, titleLink, senderLink)
181+
text = fmt.Sprintf("[%s] Comment edited on %s %s", repoLink, typ, titleLink)
179182
case api.HookIssueCommentDeleted:
180-
text = fmt.Sprintf("[%s] Comment on %s %s deleted by %s", repoLink, typ, titleLink, senderLink)
183+
text = fmt.Sprintf("[%s] Comment deleted on %s %s", repoLink, typ, titleLink)
181184
color = redColor
182185
}
186+
if withSender {
187+
text += fmt.Sprintf(" by %s", linkFormatter(setting.AppURL+p.Sender.UserName, p.Sender.UserName))
188+
}
183189

184190
return text, issueTitle, color
185191
}

modules/webhook/msteams.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ func getMSTeamsPushPayload(p *api.PushPayload) (*MSTeamsPayload, error) {
266266
}
267267

268268
func getMSTeamsIssuesPayload(p *api.IssuePayload) (*MSTeamsPayload, error) {
269-
text, _, attachmentText, color := getIssuesPayloadInfo(p, noneLinkFormatter)
269+
text, _, attachmentText, color := getIssuesPayloadInfo(p, noneLinkFormatter, false)
270270

271271
return &MSTeamsPayload{
272272
Type: "MessageCard",
@@ -308,7 +308,7 @@ func getMSTeamsIssuesPayload(p *api.IssuePayload) (*MSTeamsPayload, error) {
308308
}
309309

310310
func getMSTeamsIssueCommentPayload(p *api.IssueCommentPayload) (*MSTeamsPayload, error) {
311-
text, _, color := getIssueCommentPayloadInfo(p, noneLinkFormatter)
311+
text, _, color := getIssueCommentPayloadInfo(p, noneLinkFormatter, false)
312312

313313
return &MSTeamsPayload{
314314
Type: "MessageCard",
@@ -350,7 +350,7 @@ func getMSTeamsIssueCommentPayload(p *api.IssueCommentPayload) (*MSTeamsPayload,
350350
}
351351

352352
func getMSTeamsPullRequestPayload(p *api.PullRequestPayload) (*MSTeamsPayload, error) {
353-
text, _, attachmentText, color := getPullRequestPayloadInfo(p, noneLinkFormatter)
353+
text, _, attachmentText, color := getPullRequestPayloadInfo(p, noneLinkFormatter, false)
354354

355355
return &MSTeamsPayload{
356356
Type: "MessageCard",
@@ -503,7 +503,7 @@ func getMSTeamsRepositoryPayload(p *api.RepositoryPayload) (*MSTeamsPayload, err
503503
}
504504

505505
func getMSTeamsReleasePayload(p *api.ReleasePayload) (*MSTeamsPayload, error) {
506-
text, color := getReleasePayloadInfo(p, noneLinkFormatter)
506+
text, color := getReleasePayloadInfo(p, noneLinkFormatter, false)
507507

508508
return &MSTeamsPayload{
509509
Type: "MessageCard",

modules/webhook/slack.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func getSlackForkPayload(p *api.ForkPayload, slack *SlackMeta) (*SlackPayload, e
144144
}
145145

146146
func getSlackIssuesPayload(p *api.IssuePayload, slack *SlackMeta) (*SlackPayload, error) {
147-
text, issueTitle, attachmentText, color := getIssuesPayloadInfo(p, SlackLinkFormatter)
147+
text, issueTitle, attachmentText, color := getIssuesPayloadInfo(p, SlackLinkFormatter, true)
148148

149149
pl := &SlackPayload{
150150
Channel: slack.Channel,
@@ -167,7 +167,7 @@ func getSlackIssuesPayload(p *api.IssuePayload, slack *SlackMeta) (*SlackPayload
167167
}
168168

169169
func getSlackIssueCommentPayload(p *api.IssueCommentPayload, slack *SlackMeta) (*SlackPayload, error) {
170-
text, issueTitle, color := getIssueCommentPayloadInfo(p, SlackLinkFormatter)
170+
text, issueTitle, color := getIssueCommentPayloadInfo(p, SlackLinkFormatter, true)
171171

172172
return &SlackPayload{
173173
Channel: slack.Channel,
@@ -184,7 +184,7 @@ func getSlackIssueCommentPayload(p *api.IssueCommentPayload, slack *SlackMeta) (
184184
}
185185

186186
func getSlackReleasePayload(p *api.ReleasePayload, slack *SlackMeta) (*SlackPayload, error) {
187-
text, _ := getReleasePayloadInfo(p, SlackLinkFormatter)
187+
text, _ := getReleasePayloadInfo(p, SlackLinkFormatter, true)
188188

189189
return &SlackPayload{
190190
Channel: slack.Channel,
@@ -239,7 +239,7 @@ func getSlackPushPayload(p *api.PushPayload, slack *SlackMeta) (*SlackPayload, e
239239
}
240240

241241
func getSlackPullRequestPayload(p *api.PullRequestPayload, slack *SlackMeta) (*SlackPayload, error) {
242-
text, issueTitle, attachmentText, color := getPullRequestPayloadInfo(p, SlackLinkFormatter)
242+
text, issueTitle, attachmentText, color := getPullRequestPayloadInfo(p, SlackLinkFormatter, true)
243243

244244
pl := &SlackPayload{
245245
Channel: slack.Channel,

modules/webhook/slack_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func TestSlackReleasePayload(t *testing.T) {
7070
require.Nil(t, err)
7171
require.NotNil(t, pl)
7272

73-
assert.Equal(t, "[<http://localhost:3000/test/repo|test/repo>] Release <http://localhost:3000/test/repo/src/v1.0|v1.0> created by <https://try.gitea.io/user1|user1>", pl.Text)
73+
assert.Equal(t, "[<http://localhost:3000/test/repo|test/repo>] Release created: <http://localhost:3000/test/repo/src/v1.0|v1.0> by <https://try.gitea.io/user1|user1>", pl.Text)
7474
}
7575

7676
func TestSlackPullRequestPayload(t *testing.T) {
@@ -84,5 +84,5 @@ func TestSlackPullRequestPayload(t *testing.T) {
8484
require.Nil(t, err)
8585
require.NotNil(t, pl)
8686

87-
assert.Equal(t, "[<http://localhost:3000/test/repo|test/repo>] Pull request <http://localhost:3000/test/repo/pulls/12|#2 Fix bug> opened by <https://try.gitea.io/user1|user1>", pl.Text)
87+
assert.Equal(t, "[<http://localhost:3000/test/repo|test/repo>] Pull request opened: <http://localhost:3000/test/repo/pulls/12|#2 Fix bug> by <https://try.gitea.io/user1|user1>", pl.Text)
8888
}

modules/webhook/telegram.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,23 +125,23 @@ func getTelegramPushPayload(p *api.PushPayload) (*TelegramPayload, error) {
125125
}
126126

127127
func getTelegramIssuesPayload(p *api.IssuePayload) (*TelegramPayload, error) {
128-
text, _, attachmentText, _ := getIssuesPayloadInfo(p, htmlLinkFormatter)
128+
text, _, attachmentText, _ := getIssuesPayloadInfo(p, htmlLinkFormatter, true)
129129

130130
return &TelegramPayload{
131131
Message: text + "\n\n" + attachmentText,
132132
}, nil
133133
}
134134

135135
func getTelegramIssueCommentPayload(p *api.IssueCommentPayload) (*TelegramPayload, error) {
136-
text, _, _ := getIssueCommentPayloadInfo(p, htmlLinkFormatter)
136+
text, _, _ := getIssueCommentPayloadInfo(p, htmlLinkFormatter, true)
137137

138138
return &TelegramPayload{
139139
Message: text + "\n" + p.Comment.Body,
140140
}, nil
141141
}
142142

143143
func getTelegramPullRequestPayload(p *api.PullRequestPayload) (*TelegramPayload, error) {
144-
text, _, attachmentText, _ := getPullRequestPayloadInfo(p, htmlLinkFormatter)
144+
text, _, attachmentText, _ := getPullRequestPayloadInfo(p, htmlLinkFormatter, true)
145145

146146
return &TelegramPayload{
147147
Message: text + "\n" + attachmentText,
@@ -166,7 +166,7 @@ func getTelegramRepositoryPayload(p *api.RepositoryPayload) (*TelegramPayload, e
166166
}
167167

168168
func getTelegramReleasePayload(p *api.ReleasePayload) (*TelegramPayload, error) {
169-
text, _ := getReleasePayloadInfo(p, htmlLinkFormatter)
169+
text, _ := getReleasePayloadInfo(p, htmlLinkFormatter, true)
170170

171171
return &TelegramPayload{
172172
Message: text + "\n",

0 commit comments

Comments
 (0)