diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/concerns/account_associations.rb | 3 | ||||
-rw-r--r-- | app/models/conversation.rb | 2 | ||||
-rw-r--r-- | app/models/status.rb | 33 | ||||
-rw-r--r-- | app/models/user.rb | 2 |
4 files changed, 7 insertions, 33 deletions
diff --git a/app/models/concerns/account_associations.rb b/app/models/concerns/account_associations.rb index 71947fc22..3b5e106fb 100644 --- a/app/models/concerns/account_associations.rb +++ b/app/models/concerns/account_associations.rb @@ -61,9 +61,6 @@ module AccountAssociations has_and_belongs_to_many :tags has_many :featured_tags, -> { includes(:tag) }, dependent: :destroy, inverse_of: :account - # Threads - has_many :threads, class_name: 'Conversation', inverse_of: :account, dependent: :nullify - # Domain permissions has_many :domain_permissions, class_name: 'AccountDomainPermission', inverse_of: :account, dependent: :destroy diff --git a/app/models/conversation.rb b/app/models/conversation.rb index e065c34c8..0b9792091 100644 --- a/app/models/conversation.rb +++ b/app/models/conversation.rb @@ -7,7 +7,6 @@ # uri :string # created_at :datetime not null # updated_at :datetime not null -# account_id :bigint(8) # public :boolean default(FALSE), not null # root :string # @@ -17,7 +16,6 @@ class Conversation < ApplicationRecord has_many :statuses has_many :mutes, class_name: 'ConversationMute', inverse_of: :conversation, dependent: :destroy - belongs_to :account, inverse_of: :threads, optional: true def local? uri.nil? diff --git a/app/models/status.rb b/app/models/status.rb index ba8b4ff2b..8c9a74902 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -29,7 +29,6 @@ # nest_level :integer default(0), not null # published :boolean default(TRUE), not null # title :text -# semiprivate :boolean default(FALSE), not null # original_text :text # footer :text # expires_at :datetime @@ -135,10 +134,8 @@ class Status < ApplicationRecord scope :including_unpublished, -> { unscope(where: :published) } scope :unpublished, -> { rewhere(published: false) } scope :published, -> { where(published: true) } - scope :without_semiprivate, -> { where(semiprivate: false) } scope :reblogs, -> { where('statuses.reblog_of_id IS NOT NULL') } scope :locally_reblogged, -> { where(id: Status.unscoped.local.reblogs.select(:reblog_of_id)) } - scope :conversations_by, ->(account) { joins(:conversation).where(conversations: { account: account }) } scope :mentioning_account, ->(account) { joins(:mentions).where(mentions: { account: account }) } scope :replies, -> { where(reply: true) } scope :expired, -> { published.where('statuses.expires_at IS NOT NULL AND statuses.expires_at < ?', Time.now.utc) } @@ -377,13 +374,6 @@ class Status < ApplicationRecord @private_permissions = domain_permissions.where(visibility: [:private, :direct, :limited]).exists? end - def should_be_semiprivate? - return @should_be_semiprivate if defined?(@should_be_semiprivate) - return @should_be_semiprivate = true if distributable? && (private_domain_permissions? || account.private_domain_permissions?) - - @should_be_semiprivate = !distributable? && (public_domain_permissions? || account.public_domain_permissions?) - end - def should_limit_visibility? less_private_than?(thread&.visibility) end @@ -408,7 +398,6 @@ class Status < ApplicationRecord after_create :set_poll_id after_save :set_domain_permissions, if: :local? - after_save :set_semiprivate, if: :local? after_save :set_conversation_root class << self @@ -552,7 +541,6 @@ class Status < ApplicationRecord return query if options[:without_category_filters] query = query.published unless options[:include_unpublished] - query = query.without_semiprivate unless options[:include_semiprivate] if options[:only_reblogs] query = query.joins(:reblog) @@ -576,12 +564,11 @@ class Status < ApplicationRecord query = query.without_reblogs end - query = if options[:include_replies] - query = query.replies if options[:only_replies] - query.conversations_by(target_account) - else - query.without_replies - end + if options[:include_replies] + query = query.replies if options[:only_replies] + else + query = query.without_replies + end end return query if options[:tag].blank? @@ -666,15 +653,11 @@ class Status < ApplicationRecord if reply? && !thread.nil? self.in_reply_to_account_id = carried_over_reply_to_account_id self.conversation_id = thread.conversation_id if conversation_id.nil? - elsif conversation_id.nil? - self.conversation = reply? ? Conversation.new(account_id: nil) : Conversation.new(account_id: account_id) - elsif !reply? && account_id != conversation.account_id - conversation.update!(account_id: account_id) end end def set_conversation_root - conversation.update!(root: uri, account_id: account_id) if !reply && conversation.root.blank? + conversation.update!(root: uri) if !reply && conversation.present? && conversation.root.blank? end def carried_over_reply_to_account_id @@ -711,10 +694,6 @@ class Status < ApplicationRecord end end - def set_semiprivate - update_column(:semiprivate, should_be_semiprivate?) if semiprivate != should_be_semiprivate? - end - def update_statistics return unless distributable? diff --git a/app/models/user.rb b/app/models/user.rb index bb7fd4da5..5f2edab57 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -123,7 +123,7 @@ class User < ApplicationRecord :style_css_profile_errors, :style_css_webapp, :style_css_webapp_errors, :style_wide_media, :publish_in, :unpublish_in, :unpublish_delete, :boost_every, :boost_jitter, - :boost_random, :filter_to_unknown, :filter_from_unknown, :unpublish_on_delete, + :boost_random, :filter_from_unknown, :unpublish_on_delete, :rss_disabled, to: :settings, prefix: :setting, allow_nil: false |