diff --git a/src/dispatch/incident/messaging.py b/src/dispatch/incident/messaging.py index c12165df0a55..a4c735576e5a 100644 --- a/src/dispatch/incident/messaging.py +++ b/src/dispatch/incident/messaging.py @@ -78,7 +78,7 @@ def send_welcome_ephemeral_message_to_participant( message_kwargs = { "name": incident.name, "title": incident.title, - "description": incident.description, + "description": f"{incident.description[:500]}...", "status": incident.status, "type": incident.incident_type.name, "type_description": incident.incident_type.description, @@ -138,7 +138,7 @@ def send_welcome_email_to_participant( message_kwargs = { "name": incident.name, "title": incident.title, - "description": incident.description, + "description": f"{incident.description[:500]}...", "status": incident.status, "type": incident.incident_type.name, "type_description": incident.incident_type.description, @@ -252,7 +252,7 @@ def send_incident_created_notifications(incident: Incident, db_session: SessionL notification_kwargs = { "name": incident.name, "title": incident.title, - "description": incident.description, + "description": f"{incident.description[:500]}...", "status": incident.status, "type": incident.incident_type.name, "type_description": incident.incident_type.description, @@ -663,7 +663,7 @@ def send_incident_resources_ephemeral_message_to_participant( message_kwargs = { "title": incident.title, - "description": incident.description, + "description": f"{incident.description[:500]}...", "commander_fullname": incident.commander.individual.name, "commander_team": incident.commander.team, "commander_weblink": incident.commander.individual.weblink, @@ -766,8 +766,8 @@ def send_incident_closed_information_review_reminder(incident: Incident, db_sess { "name": incident.name, "title": incident.title, - "description": f"{incident.description[:100]}", - "resolution": f"{incident.resolution[:100]}", + "description": f"{incident.description[:100]}...", + "resolution": f"{incident.resolution[:100]}...", "type": incident.incident_type.name, "priority": incident.incident_priority.name, "dispatch_ui_incident_url": f"{DISPATCH_UI_URL}/{incident.project.organization.name}/incidents/{incident.name}", diff --git a/src/dispatch/messaging/strings.py b/src/dispatch/messaging/strings.py index 24c30687ed98..194bf97dcf46 100644 --- a/src/dispatch/messaging/strings.py +++ b/src/dispatch/messaging/strings.py @@ -713,6 +713,10 @@ def render_message_template(message_template: List[dict], **kwargs): if d.get("text"): d["text"] = Template(d["text"]).render(**kwargs) + # NOTE: we truncate the string to 2500 characters + # to prevent hitting limits on SaaS integrations (e.g. Slack) + d["text"] = d["text"] if len(d["text"]) <= 2500 else d["text"][:2500] + # render a new button array given the template if d.get("buttons"): for button in d["buttons"]: