about summary refs log tree commit diff
path: root/app/services
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-11-10 09:36:47 +0100
committerClaire <claire.github-309c@sitedethib.com>2022-11-10 09:36:47 +0100
commitc118918520c3c5b1d60451e9692c45f7bd7e32e4 (patch)
treed192e63c8f2599c44189fbb3bc33b481e22fe28b /app/services
parentb2a25d446a9f4368ad9d1240b9da30bc33942da5 (diff)
parent8fdbb4d00d371e7a900bec3a262216d95a784d52 (diff)
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.
Diffstat (limited to 'app/services')
-rw-r--r--app/services/account_search_service.rb4
-rw-r--r--app/services/activitypub/fetch_remote_actor_service.rb2
-rw-r--r--app/services/activitypub/process_account_service.rb2
-rw-r--r--app/services/report_service.rb2
-rw-r--r--app/services/resolve_url_service.rb4
-rw-r--r--app/services/update_account_service.rb2
6 files changed, 10 insertions, 6 deletions
diff --git a/app/services/account_search_service.rb b/app/services/account_search_service.rb
index 9f2330a94..85538870b 100644
--- a/app/services/account_search_service.rb
+++ b/app/services/account_search_service.rb
@@ -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?
diff --git a/app/services/activitypub/fetch_remote_actor_service.rb b/app/services/activitypub/fetch_remote_actor_service.rb
index 17bf2f287..db09c38d8 100644
--- a/app/services/activitypub/fetch_remote_actor_service.rb
+++ b/app/services/activitypub/fetch_remote_actor_service.rb
@@ -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
diff --git a/app/services/activitypub/process_account_service.rb b/app/services/activitypub/process_account_service.rb
index 3834d79cc..99bcb3835 100644
--- a/app/services/activitypub/process_account_service.rb
+++ b/app/services/activitypub/process_account_service.rb
@@ -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
diff --git a/app/services/report_service.rb b/app/services/report_service.rb
index 8c92cf334..0ce525b07 100644
--- a/app/services/report_service.rb
+++ b/app/services/report_service.rb
@@ -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
 
diff --git a/app/services/resolve_url_service.rb b/app/services/resolve_url_service.rb
index 37c856cf8..52f35daf3 100644
--- a/app/services/resolve_url_service.rb
+++ b/app/services/resolve_url_service.rb
@@ -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
diff --git a/app/services/update_account_service.rb b/app/services/update_account_service.rb
index 77f794e17..71976ab00 100644
--- a/app/services/update_account_service.rb
+++ b/app/services/update_account_service.rb
@@ -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)