From 694240ddcdef1df9b32888de8fb743d2dee86462 Mon Sep 17 00:00:00 2001 From: Adam Cooke Date: Fri, 1 Mar 2024 13:14:48 +0000 Subject: [PATCH] fix: truncate output and details in deliveries to 250 characters closes #2831 --- lib/postal/message_db/delivery.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/postal/message_db/delivery.rb b/lib/postal/message_db/delivery.rb index dfe90cd..98f5ec9 100644 --- a/lib/postal/message_db/delivery.rb +++ b/lib/postal/message_db/delivery.rb @@ -7,7 +7,14 @@ module Postal def self.create(message, attributes = {}) attributes = message.database.stringify_keys(attributes) attributes = attributes.merge("message_id" => message.id, "timestamp" => Time.now.to_f) + + # Ensure that output and details don't overflow their columns. We don't need + # these values to store more than 250 characters. + attributes["output"] = attributes["output"][0, 250] if attributes["output"] + attributes["details"] = attributes["details"][0, 250] if attributes["details"] + id = message.database.insert("deliveries", attributes) + delivery = Delivery.new(message, attributes.merge("id" => id)) delivery.update_statistics delivery.send_webhooks