about summary refs log tree commit diff
path: root/app/models/status.rb
diff options
context:
space:
mode:
authorDavid Yip <yipdw@member.fsf.org>2017-10-16 01:29:02 -0500
committerDavid Yip <yipdw@member.fsf.org>2017-10-16 01:29:02 -0500
commit6cd5b3bbe5a11fcf25bbefba2803f2ae840f39fc (patch)
tree4bb60f4493fb70cada728a373f74c18b87e8f95d /app/models/status.rb
parentf72ad67a3967230afd63a9e2d84a2a69331c4787 (diff)
parent894da3dcca781e27ce9c5130f1021526ac8a6887 (diff)
Merge remote-tracking branch 'origin/master' into gs-master
Diffstat (limited to 'app/models/status.rb')
-rw-r--r--app/models/status.rb12
1 files changed, 7 insertions, 5 deletions
diff --git a/app/models/status.rb b/app/models/status.rb
index 107ccface..30d53f298 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -134,7 +134,7 @@ class Status < ApplicationRecord
     CustomEmoji.from_text([spoiler_text, text].join(' '), account.domain)
   end
 
-  after_create :store_uri, if: :local?
+  after_create_commit :store_uri, if: :local?
 
   around_create Mastodon::Snowflake::Callbacks
 
@@ -194,7 +194,11 @@ class Status < ApplicationRecord
         account_ids << item.reblog.account_id if item.reblog?
       end
 
-      accounts = Account.where(id: account_ids.uniq).map { |a| [a.id, a] }.to_h
+      account_ids.uniq!
+
+      return if account_ids.empty?
+
+      accounts = Account.where(id: account_ids).map { |a| [a.id, a] }.to_h
 
       cached_items.each do |item|
         item.account = accounts[item.account_id]
@@ -216,9 +220,7 @@ class Status < ApplicationRecord
         # non-followers can see everything that isn't private/direct, but can see stuff they are mentioned in.
         visibility.push(:private) if account.following?(target_account)
 
-        joins("LEFT OUTER JOIN mentions ON statuses.id = mentions.status_id AND mentions.account_id = #{account.id}")
-          .where(arel_table[:visibility].in(visibility).or(Mention.arel_table[:id].not_eq(nil)))
-          .order(visibility: :desc)
+        where(visibility: visibility).or(where(id: account.mentions.select(:status_id)))
       end
     end