Skip to content

Commit

Permalink
fix: truncate output and details in deliveries to 250 characters
Browse files Browse the repository at this point in the history
closes #2831
  • Loading branch information
adamcooke committed Mar 1, 2024
1 parent 18ba714 commit 694240d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/postal/message_db/delivery.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ class Delivery
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
Expand Down

0 comments on commit 694240d

Please sign in to comment.