diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/models/status.rb | 21 | ||||
-rw-r--r-- | app/services/post_status_service.rb | 4 | ||||
-rw-r--r-- | app/workers/post_status_worker.rb | 2 |
3 files changed, 15 insertions, 12 deletions
diff --git a/app/models/status.rb b/app/models/status.rb index 1c1f533bf..19285057b 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -101,13 +101,14 @@ class Status < ApplicationRecord scope :local, -> { where(local: true).or(where(uri: nil)) } scope :network, -> { where(network: true) } scope :curated, -> { where(curated: true) } + scope :hidden, -> { where(hidden: true) } scope :without_replies, -> { where('statuses.reply = FALSE OR statuses.in_reply_to_account_id = statuses.account_id') } scope :without_reblogs, -> { where('statuses.reblog_of_id IS NULL') } scope :reblogs, -> { where('statuses.reblog_of_id IS NOT NULL') } # all reblogs - scope :with_public_visibility, -> { where(visibility: :public) } - scope :public_local_visibility, -> { where(visibility: [:public, :local]) } - scope :public_browsable, -> { where(visibility: [:public, :unlisted, :local]) } + scope :with_public_visibility, -> { where(visibility: :public, hidden: false) } + scope :public_local_visibility, -> { where(visibility: [:public, :local], hidden: false) } + scope :public_browsable, -> { where(visibility: [:public, :unlisted, :local], hidden: false) } scope :tagged_with, ->(tag) { joins(:statuses_tags).where(statuses_tags: { tag_id: tag }) } scope :excluding_silenced_accounts, -> { left_outer_joins(:account).where(accounts: { silenced_at: nil }) } scope :including_silenced_accounts, -> { left_outer_joins(:account).where.not(accounts: { silenced_at: nil }) } @@ -406,10 +407,11 @@ class Status < ApplicationRecord term = term.split(nil, 2)[1] query = account.statuses else + scope = Status.where(hidden: false) query = Status.where(account_id: account.id) - .or(Status.where(visibility: [:local, :public])) - .or(Status.where(account_id: account.following, visibility: [:private, :unlisted])) - .or(Status.where(id: account.mentions.select(:status_id))) + .or(scope.where(visibility: [:local, :public])) + .or(scope.where(account_id: account.following, visibility: [:private, :unlisted])) + .or(scope.where(id: account.mentions.select(:status_id))) end return none if term.blank? query = query.without_reblogs @@ -429,7 +431,7 @@ class Status < ApplicationRecord end def as_home_timeline(account, reblogs_only: false) - query = where(account: [account] + account.following, visibility: [:public, :unlisted, :local, :private]) + query = where(account: [account] + account.following, visibility: [:public, :unlisted, :local, :private], hidden: false) query = query.without_reblogs if !reblogs_only && account.present? && account&.user&.hide_boosts query = query.reblogs if reblogs_only query @@ -455,6 +457,7 @@ class Status < ApplicationRecord .limit(limit) .order('mentions.status_id DESC') .not_excluded_by_account(account) + .where(hidden: false) if max_id.present? query_from_me = query_from_me.where('statuses.id < ?', max_id) @@ -547,7 +550,7 @@ class Status < ApplicationRecord visibility = [:public, :unlisted, :local] if account.nil? - query = where(visibility: visibility).not_local_only + query = where(visibility: visibility, hidden: false).not_local_only target_account.replies ? query : query.without_replies elsif target_account.blocking?(account) # get rid of blocked peeps none @@ -556,7 +559,7 @@ class Status < ApplicationRecord else # followers can see followers-only stuff, but also things they are mentioned in. # non-followers can see everything that isn't private/direct, but can see stuff they are mentioned in. - scope = left_outer_joins(:reblog) + scope = left_outer_joins(:reblog).where(hidden: false) query = scope.where(visibility: visibility).or(scope.where(id: account.mentions.select(:status_id))) if account.following?(target_account) then diff --git a/app/services/post_status_service.rb b/app/services/post_status_service.rb index 3505dc536..a36a1b074 100644 --- a/app/services/post_status_service.rb +++ b/app/services/post_status_service.rb @@ -77,9 +77,8 @@ class PostStatusService < BaseService federate: @options[:federate], distribute: @options[:distribute], nocrawl: @options[:nocrawl], - delete_after: @delete_after.nil? ? nil : @delete_after + 1.minute, - defederate_after: @defederate_after.nil? ? nil : @defederate_after + 1.minute, reject_replies: @options[:noreplies] || false, + hidden: false, }.compact PostStatusWorker.perform_at(@delay_until, @status.id, opts) @@ -346,6 +345,7 @@ class PostStatusService < BaseService language: language_from_option(@options[:language]) || @account.user_default_language&.presence || 'en', application: @options[:application], content_type: @options[:content_type] || @account.user&.setting_default_content_type, + hidden: true, }.compact end diff --git a/app/workers/post_status_worker.rb b/app/workers/post_status_worker.rb index 49f1a2c6f..56ebb4453 100644 --- a/app/workers/post_status_worker.rb +++ b/app/workers/post_status_worker.rb @@ -13,7 +13,7 @@ class PostStatusWorker LinkCrawlWorker.perform_async(status.id) unless options[:nocrawl] || status.spoiler_text.present? DistributionWorker.perform_async(status.id) unless options[:distribute] == false - unless status.local_only? || options[:distribute] == false || options[:federate] == false + unless status.local_only? || options[:distribute] == false || options[:federate] == false || status.hidden? ActivityPub::DistributionWorker.perform_async(status.id) end |