mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2025-02-07 07:52:08 +01:00
chore: update how the body limit is applied
This commit is contained in:
parent
8d45e52ab7
commit
791e11e0c8
@ -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")
|
||||||
|
Loading…
Reference in New Issue
Block a user