diff options
author | Starfall <us@starfall.systems> | 2021-03-04 23:55:42 -0600 |
---|---|---|
committer | Starfall <us@starfall.systems> | 2021-03-04 23:55:42 -0600 |
commit | fe6381b9acc28cd610b032160de2952e1fdefc86 (patch) | |
tree | ad1ba10427d5d792d3ba797479528f01e51404a5 /app/services | |
parent | 033b1b5b900babc9b068ddad0ae644c5f15e9ffe (diff) | |
parent | f4abf8e7829c6a5b952dea6fb9ad01b6b3601f95 (diff) |
Merge remote-tracking branch 'glitchsoc/main' into main
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/fetch_link_card_service.rb | 12 | ||||
-rw-r--r-- | app/services/follow_service.rb | 7 | ||||
-rw-r--r-- | app/services/resolve_account_service.rb | 5 |
3 files changed, 13 insertions, 11 deletions
diff --git a/app/services/fetch_link_card_service.rb b/app/services/fetch_link_card_service.rb index 74fe9a0a5..d4e4931e6 100644 --- a/app/services/fetch_link_card_service.rb +++ b/app/services/fetch_link_card_service.rb @@ -2,12 +2,12 @@ class FetchLinkCardService < BaseService URL_PATTERN = %r{ - ( # $1 URL - (https?:\/\/) # $2 Protocol (required) - (#{Twitter::Regex[:valid_domain]}) # $3 Domain(s) - (?::(#{Twitter::Regex[:valid_port_number]}))? # $4 Port number (optional) - (/#{Twitter::Regex[:valid_url_path]}*)? # $5 URL Path and anchor - (\?#{Twitter::Regex[:valid_url_query_chars]}*#{Twitter::Regex[:valid_url_query_ending_chars]})? # $6 Query String + ( # $1 URL + (https?:\/\/) # $2 Protocol (required) + (#{Twitter::TwitterText::Regex[:valid_domain]}) # $3 Domain(s) + (?::(#{Twitter::TwitterText::Regex[:valid_port_number]}))? # $4 Port number (optional) + (/#{Twitter::TwitterText::Regex[:valid_url_path]}*)? # $5 URL Path and anchor + (\?#{Twitter::TwitterText::Regex[:valid_url_query_chars]}*#{Twitter::TwitterText::Regex[:valid_url_query_ending_chars]})? # $6 Query String ) }iox diff --git a/app/services/follow_service.rb b/app/services/follow_service.rb index b98f7011d..d3db07a74 100644 --- a/app/services/follow_service.rb +++ b/app/services/follow_service.rb @@ -3,10 +3,11 @@ class FollowService < BaseService include Redisable include Payloadable + include DomainControlHelper # Follow a remote user, notify remote user about the follow # @param [Account] source_account From which to follow - # @param [String, Account] uri User URI to follow in the form of username@domain (or account record) + # @param [Account] target_account Account to follow # @param [Hash] options # @option [Boolean] :reblogs Whether or not to show reblogs, defaults to true # @option [Boolean] :notify Whether to create notifications about new posts, defaults to false @@ -15,7 +16,7 @@ class FollowService < BaseService # @option [Boolean] :with_rate_limit def call(source_account, target_account, options = {}) @source_account = source_account - @target_account = ResolveAccountService.new.call(target_account, skip_webfinger: true) + @target_account = target_account @options = { bypass_locked: false, bypass_limit: false, with_rate_limit: false }.merge(options) raise ActiveRecord::RecordNotFound if following_not_possible? @@ -43,7 +44,7 @@ class FollowService < BaseService end def following_not_allowed? - @target_account.blocking?(@source_account) || @source_account.blocking?(@target_account) || @target_account.moved? || (!@target_account.local? && @target_account.ostatus?) || @source_account.domain_blocking?(@target_account.domain) + domain_not_allowed?(@target_account.domain) || @target_account.blocking?(@source_account) || @source_account.blocking?(@target_account) || @target_account.moved? || (!@target_account.local? && @target_account.ostatus?) || @source_account.domain_blocking?(@target_account.domain) end def change_follow_options! diff --git a/app/services/resolve_account_service.rb b/app/services/resolve_account_service.rb index 3301aaf51..b8ddeb2ad 100644 --- a/app/services/resolve_account_service.rb +++ b/app/services/resolve_account_service.rb @@ -10,7 +10,7 @@ class ResolveAccountService < BaseService # @param [String, Account] uri URI in the username@domain format or account record # @param [Hash] options # @option options [Boolean] :redirected Do not follow further Webfinger redirects - # @option options [Boolean] :skip_webfinger Do not attempt to refresh account data + # @option options [Boolean] :skip_webfinger Do not attempt any webfinger query or refreshing account data # @return [Account] def call(uri, options = {}) return if uri.blank? @@ -120,8 +120,9 @@ class ResolveAccountService < BaseService def webfinger_update_due? return false if @options[:check_delivery_availability] && !DeliveryFailureTracker.available?(@domain) + return false if @options[:skip_webfinger] - @account.nil? || ((!@options[:skip_webfinger] || @account.ostatus?) && @account.possibly_stale?) + @account.nil? || (@account.ostatus? && @account.possibly_stale?) end def activitypub_ready? |