about summary refs log tree commit diff
path: root/app/models/account.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-07-14 19:47:53 +0200
committerGitHub <noreply@github.com>2017-07-14 19:47:53 +0200
commite2685ccc81f04e1a63a97af80686bf85027418a6 (patch)
tree20e9847c734a11f7a80d31eb8104bc84bbffa9a1 /app/models/account.rb
parentc42092ba7ad1cbf78ca8463b6525ec2b7efbdd92 (diff)
Fix #4149, fix #1199 - Store emojis as unicode (#4189)
- Use unicode when selecting emoji through picker
- Convert shortcodes to unicode when storing text input server-side
- Do not convert shortcodes in JS anymore
Diffstat (limited to 'app/models/account.rb')
-rw-r--r--app/models/account.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/app/models/account.rb b/app/models/account.rb
index 2b54cee5f..7243cb1a5 100644
--- a/app/models/account.rb
+++ b/app/models/account.rb
@@ -47,6 +47,7 @@ class Account < ApplicationRecord
   include AccountInteractions
   include Attachmentable
   include Remotable
+  include EmojiHelper
 
   # Local users
   has_one :user, inverse_of: :account
@@ -240,9 +241,18 @@ class Account < ApplicationRecord
 
   before_create :generate_keys
   before_validation :normalize_domain
+  before_validation :prepare_contents, if: :local?
 
   private
 
+  def prepare_contents
+    display_name&.strip!
+    note&.strip!
+
+    self.display_name = emojify(display_name)
+    self.note         = emojify(note)
+  end
+
   def generate_keys
     return unless local?