Skip to content

Commit 8876d34

Browse files
committed
limit discord description size
1 parent bf9500b commit 8876d34

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

services/webhook/discord.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ var (
101101
redColor = color("ff3232")
102102
)
103103

104+
const discordDescriptionBytesLimit = 2048
105+
104106
type discordConvertor struct {
105107
Username string
106108
AvatarURL string
@@ -307,6 +309,9 @@ func parseHookPullRequestEventType(event webhook_module.HookEventType) (string,
307309
}
308310

309311
func (d discordConvertor) createPayload(s *api.User, title, text, url string, color int) DiscordPayload {
312+
if len(text) > discordDescriptionBytesLimit {
313+
text = text[:discordDescriptionBytesLimit]
314+
}
310315
return DiscordPayload{
311316
Username: d.Username,
312317
AvatarURL: d.AvatarURL,

0 commit comments

Comments
 (0)