about summary refs log tree commit diff
path: root/app/models/status.rb
diff options
context:
space:
mode:
authorDavid Yip <yipdw@member.fsf.org>2018-06-07 05:13:49 -0500
committerDavid Yip <yipdw@member.fsf.org>2018-06-07 05:13:49 -0500
commit8142bd2553e7819722fdfc401e06cb10eeddd230 (patch)
treed771e65a58d3c69ba1c08c3fc145f24b5b806274 /app/models/status.rb
parentf8d50a40701f344ea7c2a0e5475bbcbc727ef930 (diff)
parent2304d52599bfd3a907931971a94b9b68f229ab0a (diff)
Merge remote-tracking branch 'tootsuite/master' into merge-upstream
  Conflicts:
 	app/models/status.rb

The conflict in the Status model was due to
https://github.com/tootsuite/mastodon/commit/5bf500338478f819a65d25636a0af61a482972d3.
It was resolved by accepting tootsuite's changes.
Diffstat (limited to 'app/models/status.rb')
-rw-r--r--app/models/status.rb13
1 files changed, 6 insertions, 7 deletions
diff --git a/app/models/status.rb b/app/models/status.rb
index 69fae2eb6..c0e241ddd 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -55,7 +55,7 @@ class Status < ApplicationRecord
   has_many :reblogs, foreign_key: 'reblog_of_id', class_name: 'Status', inverse_of: :reblog, dependent: :destroy
   has_many :replies, foreign_key: 'in_reply_to_id', class_name: 'Status', inverse_of: :thread
   has_many :mentions, dependent: :destroy
-  has_many :media_attachments, dependent: :destroy
+  has_many :media_attachments, dependent: :nullify
 
   has_and_belongs_to_many :tags
   has_and_belongs_to_many :preview_cards
@@ -194,7 +194,6 @@ class Status < ApplicationRecord
   before_validation :set_reblog
   before_validation :set_visibility
   before_validation :set_conversation
-  before_validation :set_sensitivity
   before_validation :set_local
 
   class << self
@@ -317,7 +316,11 @@ 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)
 
-        where(visibility: visibility).or(where(id: account.mentions.select(:status_id)))
+        scope = left_outer_joins(:reblog)
+
+        scope.where(visibility: visibility)
+             .or(scope.where(id: account.mentions.select(:status_id)))
+             .merge(scope.where(reblog_of_id: nil).or(scope.where.not(reblogs_statuses: { account_id: account.excluded_from_timeline_account_ids })))
       end
     end
 
@@ -388,10 +391,6 @@ class Status < ApplicationRecord
     self.sensitive  = false if sensitive.nil?
   end
 
-  def set_sensitivity
-    self.sensitive = sensitive || spoiler_text.present?
-  end
-
   def set_locality
     if account.domain.nil? && !attribute_changed?(:local_only)
       self.local_only = marked_local_only?