mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-06-25 14:00:02 +02:00
Fix discord webhook 400 status code when description limit is exceeded (#34084)
Fixes [#34027](https://github.com/go-gitea/gitea/issues/34027) Discord does not allow for description bigger than 2048 bytes. If the description is bigger than that it will throw 400 and the event won't appear in discord. To fix that, in the createPayload method we now slice the description to ensure it doesn’t exceed the limit. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> (cherry picked from commit 013b2686fe6d306c4fb800147207b099866683b9)
This commit is contained in:
parent
2c63e3c590
commit
bf65a783a6
4 changed files with 38 additions and 7 deletions
|
@ -54,3 +54,12 @@ func SplitTrimSpace(input, sep string) []string {
|
|||
|
||||
return stringList
|
||||
}
|
||||
|
||||
// TruncateRunes returns a truncated string with given rune limit,
|
||||
// it returns input string if its rune length doesn't exceed the limit.
|
||||
func TruncateRunes(str string, limit int) string {
|
||||
if utf8.RuneCountInString(str) < limit {
|
||||
return str
|
||||
}
|
||||
return string([]rune(str)[:limit])
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue