about summary refs log tree commit diff
path: root/app/models/account_warning.rb
diff options
context:
space:
mode:
authorJeong Arm <kjwonmail@gmail.com>2023-01-21 18:22:22 +0900
committerGitHub <noreply@github.com>2023-01-21 10:22:22 +0100
commita1abda39dd96c9415b46b799ce969cf7a5a1492a (patch)
tree27dcd70619f29c2915c76a91c0ed76a44e709025 /app/models/account_warning.rb
parent8180f7ba194678a2c3c4fa6635b4d0191206ee60 (diff)
Fix Account Strike causing PG not null validation error (#23178)
Diffstat (limited to 'app/models/account_warning.rb')
-rw-r--r--app/models/account_warning.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/app/models/account_warning.rb b/app/models/account_warning.rb
index 961a078b9..a181cd18d 100644
--- a/app/models/account_warning.rb
+++ b/app/models/account_warning.rb
@@ -26,6 +26,8 @@ class AccountWarning < ApplicationRecord
     suspend:                    4_000,
   }, _suffix: :action
 
+  before_validation :before_validate
+
   belongs_to :account, inverse_of: :account_warnings
   belongs_to :target_account, class_name: 'Account', inverse_of: :strikes
   belongs_to :report, optional: true
@@ -47,4 +49,10 @@ class AccountWarning < ApplicationRecord
   def to_log_human_identifier
     target_account.acct
   end
+
+  private
+
+  def before_validate
+    self.text = '' if text.blank?
+  end
 end