about summary refs log tree commit diff
path: root/app/models/status.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-03-24 12:40:55 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-03-24 12:43:55 +0100
commitc8999a116ef71bef2cb28a783e4ba3d8e3cea6fa (patch)
tree5de675d578d4e3b10ccbbcee12858f1c8a7c0eb0 /app/models/status.rb
parent7cd3de3494834abfefc405b958da9898780fcb40 (diff)
Sanitize remote html in atom feeds, API (not just UI), use cached mention
relations on Status#mentions
Diffstat (limited to 'app/models/status.rb')
-rw-r--r--app/models/status.rb21
1 files changed, 7 insertions, 14 deletions
diff --git a/app/models/status.rb b/app/models/status.rb
index 2462d6b7d..b1965f176 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -60,22 +60,15 @@ class Status < ActiveRecord::Base
   end
 
   def mentions
-    m = []
-
-    m << thread.account if reply?
-    m << reblog.account if reblog?
-
-    unless reblog?
-      self.text.scan(Account::MENTION_RE).each do |match|
-        uri = match.first
-        username, domain = uri.split('@')
-        account = Account.find_by(username: username, domain: domain)
-
-        m << account unless account.nil?
-      end
+    if @mentions.nil?
+      @mentions = []
+      @mentions << thread.account if reply?
+      @mentions << reblog.account if reblog?
+      self.mentioned_accounts.each { |mention| @mentions << mention.account } unless reblog?
+      @mentions = @mentions.uniq
     end
 
-    m.uniq
+    @mentions
   end
 
   def ancestors