diff options
author | Claire <claire.github-309c@sitedethib.com> | 2021-01-11 11:55:42 +0100 |
---|---|---|
committer | Claire <claire.github-309c@sitedethib.com> | 2021-01-11 11:55:42 +0100 |
commit | 33d30632fb627ba1742eff3e0c5fc84ccd156cdb (patch) | |
tree | b7c15bb354c9d2f0ef25c50ab387007703f599d6 /app/services | |
parent | d42e7e01dcd464f80637682d4eee6e5a7f36f26e (diff) | |
parent | 11d603101a7b3389c679b8c155a3cb06203ca31a (diff) |
Merge branch 'master' into glitch-soc/merge-upstream
Conflicts: - `app/models/public_feed.rb`: Upstream refactored a bit, glitch-soc had specific code for local-only statuses. Updated glitch-soc's specific code accordingly.
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/activitypub/fetch_featured_collection_service.rb | 3 | ||||
-rw-r--r-- | app/services/activitypub/process_collection_service.rb | 2 | ||||
-rw-r--r-- | app/services/activitypub/process_poll_service.rb | 2 | ||||
-rw-r--r-- | app/services/activitypub/synchronize_followers_service.rb | 2 | ||||
-rw-r--r-- | app/services/fetch_link_card_service.rb | 2 | ||||
-rw-r--r-- | app/services/import_service.rb | 4 | ||||
-rw-r--r-- | app/services/keys/claim_service.rb | 12 | ||||
-rw-r--r-- | app/services/keys/query_service.rb | 18 |
8 files changed, 25 insertions, 20 deletions
diff --git a/app/services/activitypub/fetch_featured_collection_service.rb b/app/services/activitypub/fetch_featured_collection_service.rb index 2c2770466..82c861f5b 100644 --- a/app/services/activitypub/fetch_featured_collection_service.rb +++ b/app/services/activitypub/fetch_featured_collection_service.rb @@ -24,8 +24,7 @@ class ActivityPub::FetchFeaturedCollectionService < BaseService def process_items(items) status_ids = items.map { |item| value_or_id(item) } .reject { |uri| ActivityPub::TagManager.instance.local_uri?(uri) } - .map { |uri| ActivityPub::FetchRemoteStatusService.new.call(uri) } - .compact + .filter_map { |uri| ActivityPub::FetchRemoteStatusService.new.call(uri) } .select { |status| status.account_id == @account.id } .map(&:id) diff --git a/app/services/activitypub/process_collection_service.rb b/app/services/activitypub/process_collection_service.rb index f1d175dac..170e6709c 100644 --- a/app/services/activitypub/process_collection_service.rb +++ b/app/services/activitypub/process_collection_service.rb @@ -37,7 +37,7 @@ class ActivityPub::ProcessCollectionService < BaseService end def process_items(items) - items.reverse_each.map { |item| process_item(item) }.compact + items.reverse_each.filter_map { |item| process_item(item) } end def supported_context? diff --git a/app/services/activitypub/process_poll_service.rb b/app/services/activitypub/process_poll_service.rb index 903b6a78a..d83e614d8 100644 --- a/app/services/activitypub/process_poll_service.rb +++ b/app/services/activitypub/process_poll_service.rb @@ -30,7 +30,7 @@ class ActivityPub::ProcessPollService < BaseService voters_count = @json['votersCount'] - latest_options = items.map { |item| item['name'].presence || item['content'] }.compact + latest_options = items.filter_map { |item| item['name'].presence || item['content'] } # If for some reasons the options were changed, it invalidates all previous # votes, so we need to remove them diff --git a/app/services/activitypub/synchronize_followers_service.rb b/app/services/activitypub/synchronize_followers_service.rb index d83fcf55e..93cd60253 100644 --- a/app/services/activitypub/synchronize_followers_service.rb +++ b/app/services/activitypub/synchronize_followers_service.rb @@ -14,7 +14,7 @@ class ActivityPub::SynchronizeFollowersService < BaseService # should never happen in practice, since in almost all cases we keep an # Account record, and should we not do that, we should have sent a Delete. # In any case there is not much we can do if that occurs. - @expected_followers = items.map { |uri| ActivityPub::TagManager.instance.uri_to_resource(uri, Account) }.compact + @expected_followers = items.filter_map { |uri| ActivityPub::TagManager.instance.uri_to_resource(uri, Account) } remove_unexpected_local_followers! handle_unexpected_outgoing_follows! diff --git a/app/services/fetch_link_card_service.rb b/app/services/fetch_link_card_service.rb index 7efa31054..255490d5c 100644 --- a/app/services/fetch_link_card_service.rb +++ b/app/services/fetch_link_card_service.rb @@ -67,7 +67,7 @@ class FetchLinkCardService < BaseService else html = Nokogiri::HTML(@status.text) links = html.css('a') - urls = links.map { |a| Addressable::URI.parse(a['href']) unless skip_link?(a) }.compact.map(&:normalize).compact + urls = links.filter_map { |a| Addressable::URI.parse(a['href']) unless skip_link?(a) }.filter_map(&:normalize) end urls.reject { |uri| bad_url?(uri) }.first diff --git a/app/services/import_service.rb b/app/services/import_service.rb index 0c6ef2238..b11532283 100644 --- a/app/services/import_service.rb +++ b/app/services/import_service.rb @@ -107,12 +107,12 @@ class ImportService < BaseService end end - statuses = items.map do |uri| + statuses = items.filter_map do |uri| status = ActivityPub::TagManager.instance.uri_to_resource(uri, Status) next if status.nil? && ActivityPub::TagManager.instance.local_uri?(uri) status || ActivityPub::FetchRemoteStatusService.new.call(uri) - end.compact + end account_ids = statuses.map(&:account_id) preloaded_relations = relations_map_for_account(@account, account_ids) diff --git a/app/services/keys/claim_service.rb b/app/services/keys/claim_service.rb index 672119130..69568a0d1 100644 --- a/app/services/keys/claim_service.rb +++ b/app/services/keys/claim_service.rb @@ -8,11 +8,13 @@ class Keys::ClaimService < BaseService :key, :signature def initialize(account, device_id, key_attributes = {}) - @account = account - @device_id = device_id - @key_id = key_attributes[:key_id] - @key = key_attributes[:key] - @signature = key_attributes[:signature] + super( + account: account, + device_id: device_id, + key_id: key_attributes[:key_id], + key: key_attributes[:key], + signature: key_attributes[:signature], + ) end end diff --git a/app/services/keys/query_service.rb b/app/services/keys/query_service.rb index 286fbd834..ac3388bdc 100644 --- a/app/services/keys/query_service.rb +++ b/app/services/keys/query_service.rb @@ -7,8 +7,10 @@ class Keys::QueryService < BaseService attributes :account, :devices def initialize(account, devices) - @account = account - @devices = devices || [] + super( + account: account, + devices: devices || [], + ) end def find(device_id) @@ -20,11 +22,13 @@ class Keys::QueryService < BaseService attributes :device_id, :name, :identity_key, :fingerprint_key def initialize(attributes = {}) - @device_id = attributes[:device_id] - @name = attributes[:name] - @identity_key = attributes[:identity_key] - @fingerprint_key = attributes[:fingerprint_key] - @claim_url = attributes[:claim_url] + super( + device_id: attributes[:device_id], + name: attributes[:name], + identity_key: attributes[:identity_key], + fingerprint_key: attributes[:fingerprint_key], + ) + @claim_url = attributes[:claim_url] end def valid_claim_url? |