chore: update how the body limit is applied

This commit is contained in:
Sekwah 2024-12-11 04:29:27 +00:00
parent 8d45e52ab7
commit 791e11e0c8
No known key found for this signature in database

View File

@ -40,17 +40,15 @@ task discordupload {
"${getReleaseChangelog()}\n" "${getReleaseChangelog()}\n"
if (content.length() > maxLength) { if (content.length() > maxLength) {
def afterMessage = "[See more on GitHub](https://github.com/sekwah41/Advanced-Portals/releases)" def afterMessage = "[See more on GitHub](<https://github.com/sekwah41/Advanced-Portals/releases>)"
def truncatedContent = content.take(maxLength - afterMessage.length() - 1) def truncatedContent = content.replaceAll(/(http[s]?:\/\/[^\s)]+)/, '<$1>').take(maxLength - afterMessage.length() - 1)
def lastFullLine = truncatedContent.lastIndexOf("\n") def lastFullLine = truncatedContent.lastIndexOf("\n")
content = "${truncatedContent.take(lastFullLine)}\n" + content = "${truncatedContent.take(lastFullLine)}\n"
"${afterMessage}" content += afterMessage
} }
content = content.replaceAll(/(http[s]?:\/\/[^\s)]+)/, '<$1>')
builder.addTextBody("content", content, ContentType.create("text/plain", "UTF-8")) builder.addTextBody("content", content, ContentType.create("text/plain", "UTF-8"))
} }
@ -63,7 +61,15 @@ task discordupload {
response.getEntity() response.getEntity()
if(response.getStatusLine().getStatusCode() != 200) { if(response.getStatusLine().getStatusCode() != 200) {
throw new RuntimeException("Failed to post build to discord") println("Failed to post build to Discord.")
println("Status Code: " + response.getStatusLine().getStatusCode())
println("Reason Phrase: " + response.getStatusLine().getReasonPhrase())
String responseContent = response.getEntity() != null ?
org.apache.http.util.EntityUtils.toString(response.getEntity()) : "No content"
println("Response Content: " + responseContent)
throw new RuntimeException("Failed to post build to Discord")
} }
println("Posted build") println("Posted build")