about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/status.rb13
-rw-r--r--app/models/user.rb1
2 files changed, 10 insertions, 4 deletions
diff --git a/app/models/status.rb b/app/models/status.rb
index 54023c24c..b94aad633 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -27,6 +27,7 @@
 #  deleted_at             :datetime
 #  edited                 :integer          default(0), not null
 #  nest_level             :integer          default(0), not null
+#  published              :boolean          default(TRUE), not null
 #
 
 class Status < ApplicationRecord
@@ -94,8 +95,8 @@ class Status < ApplicationRecord
   scope :with_accounts, ->(ids) { where(id: ids).includes(:account) }
   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 :with_public_visibility, -> { where(visibility: :public) }
-  scope :distributable, -> { where(visibility: [:public, :unlisted]) }
+  scope :with_public_visibility, -> { where(visibility: :public, published: true) }
+  scope :distributable, -> { where(visibility: [:public, :unlisted], published: true) }
   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 }) }
@@ -115,6 +116,10 @@ class Status < ApplicationRecord
 
   scope :not_local_only, -> { where(local_only: [false, nil]) }
 
+  scope :including_unpublished, -> { unscope(where: :published) }
+  scope :unpublished, -> { rewhere(published: false) }
+  scope :published, -> { where(published: true) }
+
   cache_associated :application,
                    :media_attachments,
                    :conversation,
@@ -394,7 +399,7 @@ class Status < ApplicationRecord
       visibility = user_signed_in || target_account.show_unlisted? ? [:public, :unlisted] : :public
 
       if account.nil?
-        where(visibility: visibility).not_local_only
+        where(visibility: visibility).not_local_only.published
       elsif target_account.blocking?(account) || (account.domain.present? && target_account.domain_blocking?(account.domain)) # get rid of blocked peeps
         none
       elsif account.id == target_account.id # author can see own stuff
@@ -404,7 +409,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) && (user_signed_in || target_account.show_unlisted?)
 
-        scope = left_outer_joins(:reblog)
+        scope = left_outer_joins(:reblog).published
 
         scope.where(visibility: visibility)
              .or(scope.where(id: account.mentions.select(:status_id)))
diff --git a/app/models/user.rb b/app/models/user.rb
index a05d98d88..8fe694ba1 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -114,6 +114,7 @@ class User < ApplicationRecord
            :expand_spoilers, :default_language, :aggregate_reblogs, :show_application,
            :advanced_layout, :use_blurhash, :use_pending_items, :trends, :crop_images,
            :default_content_type, :system_emoji_font,
+           :manual_publish,
            to: :settings, prefix: :setting, allow_nil: false
 
   attr_reader :invite_code, :sign_in_token_attempt