Merge remote-tracking branch 'origin/kb_development' into kb_migration
This commit is contained in:
commit
94cd200097
50 changed files with 801 additions and 66 deletions
|
@ -51,6 +51,7 @@
|
|||
# reviewed_at :datetime
|
||||
# requested_review_at :datetime
|
||||
# group_allow_private_message :boolean
|
||||
# searchability :integer default("private"), not null
|
||||
#
|
||||
|
||||
class Account < ApplicationRecord
|
||||
|
@ -82,6 +83,7 @@ class Account < ApplicationRecord
|
|||
|
||||
enum protocol: { ostatus: 0, activitypub: 1 }
|
||||
enum suspension_origin: { local: 0, remote: 1 }, _prefix: true
|
||||
enum searchability: { public: 0, unlisted: 1, private: 2, direct: 3, limited: 4, public_unlisted: 10 }, _suffix: :searchability
|
||||
|
||||
validates :username, presence: true
|
||||
validates_with UniqueUsernameValidator, if: -> { will_save_change_to_username? }
|
||||
|
|
|
@ -237,6 +237,10 @@ module AccountInteractions
|
|||
status.proper.favourites.where(account: self).exists?
|
||||
end
|
||||
|
||||
def emoji_reactioned?(status)
|
||||
status.proper.emoji_reactions.where(account: self).exists?
|
||||
end
|
||||
|
||||
def bookmarked?(status)
|
||||
status.proper.bookmarks.where(account: self).exists?
|
||||
end
|
||||
|
|
|
@ -107,6 +107,10 @@ module HasUserSettings
|
|||
settings['default_privacy'] || (account.locked? ? 'private' : 'public')
|
||||
end
|
||||
|
||||
def setting_default_searchability
|
||||
settings['default_searchability'] || 'private'
|
||||
end
|
||||
|
||||
def allows_report_emails?
|
||||
settings['notification_emails.report']
|
||||
end
|
||||
|
|
|
@ -29,6 +29,7 @@ class PublicFeed
|
|||
scope.merge!(account_filters_scope) if account?
|
||||
scope.merge!(media_only_scope) if media_only?
|
||||
scope.merge!(language_scope) if account&.chosen_languages.present?
|
||||
scope.merge!(public_searchable_scope) if local_only? && !account?
|
||||
|
||||
scope.cache_ids.to_a_paginated_by_id(limit, max_id: max_id, since_id: since_id, min_id: min_id)
|
||||
end
|
||||
|
@ -97,6 +98,10 @@ class PublicFeed
|
|||
Status.where(language: account.chosen_languages)
|
||||
end
|
||||
|
||||
def public_searchable_scope
|
||||
Status.where(searchability: 'public').or(Status.where(searchability: nil).merge(Account.where(searchability: 'public')))
|
||||
end
|
||||
|
||||
def account_filters_scope
|
||||
Status.not_excluded_by_account(account).tap do |scope|
|
||||
scope.merge!(Status.not_domain_blocked_by_account(account)) unless local_only?
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
# edited_at :datetime
|
||||
# trendable :boolean
|
||||
# ordered_media_attachment_ids :bigint(8) is an Array
|
||||
# searchability :integer
|
||||
#
|
||||
|
||||
require 'ostruct'
|
||||
|
@ -52,6 +53,7 @@ class Status < ApplicationRecord
|
|||
update_index('statuses', :proper)
|
||||
|
||||
enum visibility: { public: 0, unlisted: 1, private: 2, direct: 3, limited: 4, public_unlisted: 10 }, _suffix: :visibility
|
||||
enum searchability: { public: 0, unlisted: 1, private: 2, direct: 3, limited: 4, public_unlisted: 10 }, _suffix: :searchability
|
||||
|
||||
belongs_to :application, class_name: 'Doorkeeper::Application', optional: true
|
||||
|
||||
|
@ -115,6 +117,7 @@ class Status < ApplicationRecord
|
|||
scope :tagged_with_none, lambda { |tag_ids|
|
||||
where('NOT EXISTS (SELECT * FROM statuses_tags forbidden WHERE forbidden.status_id = statuses.id AND forbidden.tag_id IN (?))', tag_ids)
|
||||
}
|
||||
scope :unset_searchability, -> { where(searchability: nil, reblog_of_id: nil) }
|
||||
|
||||
after_create_commit :trigger_create_webhooks
|
||||
after_update_commit :trigger_update_webhooks
|
||||
|
@ -252,6 +255,11 @@ class Status < ApplicationRecord
|
|||
ordered_media_attachments.any?
|
||||
end
|
||||
|
||||
def expired?
|
||||
false
|
||||
# !expired_at.nil?
|
||||
end
|
||||
|
||||
def with_preview_card?
|
||||
preview_cards.any?
|
||||
end
|
||||
|
@ -346,6 +354,15 @@ class Status < ApplicationRecord
|
|||
attributes['trendable'].nil? && account.requires_review_notification?
|
||||
end
|
||||
|
||||
def compute_searchability
|
||||
# Fedibird code
|
||||
#searchability || Status.searchabilities.invert.fetch([Account.searchabilities[account.searchability], Status.visibilities[visibility] || 0].max, nil) || 'direct'
|
||||
# Reactions only (generic: direct)
|
||||
return searchability if searchability
|
||||
return account.searchability if account.local? && account.searchability
|
||||
'private'
|
||||
end
|
||||
|
||||
after_create_commit :increment_counter_caches
|
||||
after_destroy_commit :decrement_counter_caches
|
||||
|
||||
|
@ -355,6 +372,7 @@ class Status < ApplicationRecord
|
|||
before_validation :prepare_contents, if: :local?
|
||||
before_validation :set_reblog
|
||||
before_validation :set_visibility
|
||||
before_validation :set_searchability
|
||||
before_validation :set_conversation
|
||||
before_validation :set_local
|
||||
|
||||
|
@ -367,6 +385,10 @@ class Status < ApplicationRecord
|
|||
visibilities.keys - %w(direct limited)
|
||||
end
|
||||
|
||||
def selectable_searchabilities
|
||||
searchabilities.keys - %w(public_unlisted limited)
|
||||
end
|
||||
|
||||
def favourites_map(status_ids, account_id)
|
||||
Favourite.select('status_id').where(status_id: status_ids).where(account_id: account_id).each_with_object({}) { |f, h| h[f.status_id] = true }
|
||||
end
|
||||
|
@ -535,6 +557,12 @@ class Status < ApplicationRecord
|
|||
self.sensitive = false if sensitive.nil?
|
||||
end
|
||||
|
||||
def set_searchability
|
||||
return if searchability.nil?
|
||||
|
||||
self.searchability = [Status.searchabilities[searchability], Status.visibilities[visibility == 'public_unlisted' ? 'public' : visibility]].max
|
||||
end
|
||||
|
||||
def set_conversation
|
||||
self.thread = thread.reblog if thread&.reblog?
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ class UserSettings
|
|||
setting :default_language, default: nil
|
||||
setting :default_sensitive, default: false
|
||||
setting :default_privacy, default: nil
|
||||
setting :default_searchability, default: :private,
|
||||
|
||||
namespace :web do
|
||||
setting :crop_images, default: true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue