Conflicts: - `Gemfile.lock`: Not a real conflict, upstream updated dependencies that were too close to glitch-soc-only ones in the file. - `app/controllers/oauth/authorized_applications_controller.rb`: Upstream changed the logic surrounding suspended accounts. Minor conflict due to glitch-soc's theming system. Ported upstream changes. - `app/controllers/settings/base_controller.rb`: Upstream refactored and changed the logic surrounding suspended accounts. Minor conflict due to glitch-soc's theming system. Ported upstream changes. - `app/controllers/settings/sessions_controller.rb`: Upstream refactored and changed the logic surrounding suspended accounts. Minor conflict due to glitch-soc's theming system. Ported upstream changes. - `app/models/user.rb`: Upstream refactored and changed the logic surrounding suspended accounts. Minor conflict due to glitch-soc not preventing moved accounts from logging in. Ported upstream changes while keeping the ability for moved accounts to log in. - `app/policies/status_policy.rb`: Upstream refactored and changed the logic surrounding suspended accounts. Minor conflict due to glitch-soc's local-only toots. Ported upstream changes. - `app/serializers/rest/account_serializer.rb`: Upstream refactored and changed the logic surrounding suspended accounts. Minor conflict due to glitch-soc's ability to hide followers count. Ported upstream changes. - `app/services/process_mentions_service.rb`: Upstream refactored and changed the logic surrounding suspended accounts. Minor conflict due to glitch-soc's local-only toots. Ported upstream changes. - `package.json`: Not a real conflict, upstream updated dependencies that were too close to glitch-soc-only ones in the file.
58 lines
1.6 KiB
Ruby
58 lines
1.6 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class TagFeed < PublicFeed
|
|
LIMIT_PER_MODE = 4
|
|
|
|
# @param [Tag] tag
|
|
# @param [Account] account
|
|
# @param [Hash] options
|
|
# @option [Enumerable<String>] :any
|
|
# @option [Enumerable<String>] :all
|
|
# @option [Enumerable<String>] :none
|
|
# @option [Boolean] :local
|
|
# @option [Boolean] :remote
|
|
# @option [Boolean] :only_media
|
|
def initialize(tag, account, options = {})
|
|
@tag = tag
|
|
@account = account
|
|
@options = options
|
|
end
|
|
|
|
# @param [Integer] limit
|
|
# @param [Integer] max_id
|
|
# @param [Integer] since_id
|
|
# @param [Integer] min_id
|
|
# @return [Array<Status>]
|
|
def get(limit, max_id = nil, since_id = nil, min_id = nil)
|
|
scope = public_scope
|
|
|
|
scope.merge!(without_local_only_scope) unless local_account?
|
|
scope.merge!(tagged_with_any_scope)
|
|
scope.merge!(tagged_with_all_scope)
|
|
scope.merge!(tagged_with_none_scope)
|
|
scope.merge!(local_only_scope) if local_only?
|
|
scope.merge!(remote_only_scope) if remote_only?
|
|
scope.merge!(account_filters_scope) if account?
|
|
scope.merge!(media_only_scope) if media_only?
|
|
|
|
scope.cache_ids.to_a_paginated_by_id(limit, max_id: max_id, since_id: since_id, min_id: min_id)
|
|
end
|
|
|
|
private
|
|
|
|
def tagged_with_any_scope
|
|
Status.group(:id).tagged_with(tags_for(Array(@tag.name) | Array(@options[:any])))
|
|
end
|
|
|
|
def tagged_with_all_scope
|
|
Status.group(:id).tagged_with_all(tags_for(@options[:all]))
|
|
end
|
|
|
|
def tagged_with_none_scope
|
|
Status.group(:id).tagged_with_none(tags_for(@options[:none]))
|
|
end
|
|
|
|
def tags_for(names)
|
|
Tag.matching_name(Array(names).take(LIMIT_PER_MODE)).pluck(:id) if names.present?
|
|
end
|
|
end
|