Merge branch 'kb_development' into kb_migration

This commit is contained in:
KMY 2023-08-09 08:53:06 +09:00
commit 6cfe78d51c
22 changed files with 541 additions and 32 deletions

View file

@ -40,7 +40,7 @@ class CustomEmoji < ApplicationRecord
belongs_to :category, class_name: 'CustomEmojiCategory', optional: true
has_one :local_counterpart, -> { where(domain: nil) }, class_name: 'CustomEmoji', primary_key: :shortcode, foreign_key: :shortcode, inverse_of: false
has_many :emoji_reactions, inverse_of: :custom_emoji
has_many :emoji_reactions, inverse_of: :custom_emoji, dependent: :destroy
has_attached_file :image, styles: { static: { format: 'png', convert_options: '-coalesce +profile "!icc,*" +set modify-date +set create-date' } }, validate_media_type: false

View file

@ -19,13 +19,12 @@ class PublicFeed
# @param [Integer] min_id
# @return [Array<Status>]
def get(limit, max_id = nil, since_id = nil, min_id = nil)
scope = public_scope
scope = local_only? ? public_scope : global_timeline_only_scope
scope.merge!(without_replies_scope) unless with_replies?
scope.merge!(without_reblogs_scope) unless with_reblogs?
scope.merge!(local_only_scope) if local_only?
scope.merge!(remote_only_scope) if remote_only? || hide_local_users?
scope.merge!(global_timeline_only_scope) if global_timeline?
scope.merge!(account_filters_scope) if account?
scope.merge!(media_only_scope) if media_only?
scope.merge!(language_scope) if account&.chosen_languages.present?
@ -58,10 +57,6 @@ class PublicFeed
@account.nil? && Setting.hide_local_users_for_anonymous
end
def global_timeline?
!options[:remote] && !options[:local]
end
def account?
account.present?
end
@ -74,6 +69,10 @@ class PublicFeed
Status.with_public_visibility.joins(:account).merge(Account.without_suspended.without_silenced)
end
def global_timeline_only_scope
Status.with_global_timeline_visibility.joins(:account).merge(Account.without_suspended.without_silenced)
end
def public_search_scope
Status.with_public_search_visibility.joins(:account).merge(Account.without_suspended.without_silenced)
end
@ -86,10 +85,6 @@ class PublicFeed
Status.remote
end
def global_timeline_only_scope
Status.with_global_timeline_visibility.joins(:account).merge(Account.without_suspended.without_silenced)
end
def without_replies_scope
Status.without_replies
end
@ -107,7 +102,7 @@ class PublicFeed
end
def anonymous_scope
Status.where(visibility: [:public, :public_unlisted])
local_only? ? Status.where(visibility: [:public, :public_unlisted]) : Status.where(visibility: :public)
end
def account_filters_scope

View file

@ -106,7 +106,9 @@ class Trends::Statuses < Trends::Base
private
def eligible?(status)
(status.searchability.nil? || status.public_searchability?) && (status.public_visibility? || status.public_unlisted_visibility?) && status.account.discoverable? && !status.account.silenced? && status.spoiler_text.blank? && (!status.sensitive? || status.media_attachments.none?) && !status.reply? && valid_locale?(status.language)
(status.searchability.nil? || status.public_searchability?) && (status.public_visibility? || status.public_unlisted_visibility?) &&
status.account.discoverable? && !status.account.silenced? && status.spoiler_text.blank? && (!status.sensitive? || status.media_attachments.none?) &&
!status.reply? && valid_locale?(status.language)
end
def calculate_scores(statuses, at_time)