From c8999a116ef71bef2cb28a783e4ba3d8e3cea6fa Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 24 Mar 2016 12:40:55 +0100 Subject: Sanitize remote html in atom feeds, API (not just UI), use cached mention relations on Status#mentions --- app/models/status.rb | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'app/models/status.rb') 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 -- cgit