Merge branch 'main' into glitch-soc/merge-upstream

Conflicts:
- `app/models/custom_emoji.rb`:
  Not a real conflict, just upstream changing a line too close to
  a glitch-soc-specific validation.
  Applied upstream changes.
- `app/models/public_feed.rb`:
  Not a real conflict, just upstream changing a line too close to
  a glitch-soc-specific parameter documentation.
  Applied upstream changes.
This commit is contained in:
Claire
2022-11-10 09:36:47 +01:00
178 changed files with 3274 additions and 1869 deletions

View File

@@ -3,6 +3,8 @@
class AccountSearchService < BaseService
attr_reader :query, :limit, :offset, :options, :account
MENTION_ONLY_RE = /\A#{Account::MENTION_RE}\z/i
# Min. number of characters to look for non-exact matches
MIN_QUERY_LENGTH = 5
@@ -180,7 +182,7 @@ class AccountSearchService < BaseService
end
def username_complete?
query.include?('@') && "@#{query}".match?(/\A#{Account::MENTION_RE}\Z/)
query.include?('@') && "@#{query}".match?(MENTION_ONLY_RE)
end
def likely_acct?

View File

@@ -56,7 +56,7 @@ class ActivityPub::FetchRemoteActorService < BaseService
@username, @domain = split_acct(webfinger.subject)
unless confirmed_username.casecmp(@username).zero? && confirmed_domain.casecmp(@domain).zero?
raise Webfinger::RedirectError, "Too many webfinger redirects for URI #{uri} (stopped at #{@username}@#{@domain})"
raise Webfinger::RedirectError, "Too many webfinger redirects for URI #{@uri} (stopped at #{@username}@#{@domain})"
end
raise Error, "Webfinger response for #{@username}@#{@domain} does not loop back to #{@uri}" if webfinger.link('self', 'href') != @uri

View File

@@ -40,7 +40,7 @@ class ActivityPub::ProcessAccountService < BaseService
unless @options[:only_key] || @account.suspended?
check_featured_collection! if @account.featured_collection_url.present?
check_featured_tags_collection! if @json['featuredTags'].present?
check_links! unless @account.fields.empty?
check_links! if @account.fields.any?(&:requires_verification?)
end
@account

View File

@@ -8,7 +8,7 @@ class ReportService < BaseService
@target_account = target_account
@status_ids = options.delete(:status_ids).presence || []
@comment = options.delete(:comment).presence || ''
@category = options.delete(:category).presence || 'other'
@category = options[:rule_ids].present? ? 'violation' : (options.delete(:category).presence || 'other')
@rule_ids = options.delete(:rule_ids).presence
@options = options

View File

@@ -4,6 +4,8 @@ class ResolveURLService < BaseService
include JsonLdHelper
include Authorization
USERNAME_STATUS_RE = %r{/@(?<username>#{Account::USERNAME_RE})/(?<status_id>[0-9]+)\Z}
def call(url, on_behalf_of: nil)
@url = url
@on_behalf_of = on_behalf_of
@@ -43,7 +45,7 @@ class ResolveURLService < BaseService
# We don't have an index on `url`, so try guessing the `uri` from `url`
parsed_url = Addressable::URI.parse(@url)
parsed_url.path.match(%r{/@(?<username>#{Account::USERNAME_RE})/(?<status_id>[0-9]+)\Z}) do |matched|
parsed_url.path.match(USERNAME_STATUS_RE) do |matched|
parsed_url.path = "/users/#{matched[:username]}/statuses/#{matched[:status_id]}"
scope = scope.or(Status.where(uri: parsed_url.to_s, url: @url))
end

View File

@@ -28,7 +28,7 @@ class UpdateAccountService < BaseService
end
def check_links(account)
VerifyAccountLinksWorker.perform_async(account.id)
VerifyAccountLinksWorker.perform_async(account.id) if account.fields.any?(&:requires_verification?)
end
def process_hashtags(account)