mirror of
https://github.com/ZettaIO/restic-compose-backup.git
synced 2025-11-23 16:02:29 +00:00
Truncate field sizes in discord webhook
This commit is contained in:
@@ -30,11 +30,14 @@ class DiscordWebhookAlert(BaseAlert):
|
|||||||
def send(self, subject: str = None, body: str = None, alert_type: str = None):
|
def send(self, subject: str = None, body: str = None, alert_type: str = None):
|
||||||
"""Send basic webhook request. Max embed size is 6000"""
|
"""Send basic webhook request. Max embed size is 6000"""
|
||||||
logger.info("Triggering discord webhook")
|
logger.info("Triggering discord webhook")
|
||||||
|
# NOTE: The title size is 2048
|
||||||
|
# The max description size is 2048
|
||||||
|
# Total embed size limit is 6000 characters (per embed)
|
||||||
data = {
|
data = {
|
||||||
'embeds': [
|
'embeds': [
|
||||||
{
|
{
|
||||||
'title': subject,
|
'title': subject[-256:],
|
||||||
'description': body[:5000],
|
'description': body[-2048:] if body else "",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user