about summary refs log tree commit diff
path: root/app/lib
diff options
context:
space:
mode:
Diffstat (limited to 'app/lib')
-rw-r--r--app/lib/activitypub/activity/block.rb7
-rw-r--r--app/lib/entity_cache.rb2
-rw-r--r--app/lib/settings/scoped_settings.rb2
-rw-r--r--app/lib/webfinger.rb2
4 files changed, 9 insertions, 4 deletions
diff --git a/app/lib/activitypub/activity/block.rb b/app/lib/activitypub/activity/block.rb
index 90477bf33..92a0f813f 100644
--- a/app/lib/activitypub/activity/block.rb
+++ b/app/lib/activitypub/activity/block.rb
@@ -11,8 +11,13 @@ class ActivityPub::Activity::Block < ActivityPub::Activity
       return
     end
 
+    UnfollowService.new.call(@account, target_account) if @account.following?(target_account)
     UnfollowService.new.call(target_account, @account) if target_account.following?(@account)
+    RejectFollowService.new.call(target_account, @account) if target_account.requested?(@account)
 
-    @account.block!(target_account, uri: @json['id']) unless delete_arrived_first?(@json['id'])
+    unless delete_arrived_first?(@json['id'])
+      BlockWorker.perform_async(@account.id, target_account.id)
+      @account.block!(target_account, uri: @json['id'])
+    end
   end
 end
diff --git a/app/lib/entity_cache.rb b/app/lib/entity_cache.rb
index e38a3adcd..5d51e8585 100644
--- a/app/lib/entity_cache.rb
+++ b/app/lib/entity_cache.rb
@@ -25,7 +25,7 @@ class EntityCache
     end
 
     unless uncached_ids.empty?
-      uncached = CustomEmoji.where(shortcode: shortcodes, domain: domain, disabled: false).each_with_object({}) { |item, h| h[item.shortcode] = item }
+      uncached = CustomEmoji.where(shortcode: shortcodes, domain: domain, disabled: false).index_by(&:shortcode)
       uncached.each_value { |item| Rails.cache.write(to_key(:emoji, item.shortcode, domain), item, expires_in: MAX_EXPIRATION) }
     end
 
diff --git a/app/lib/settings/scoped_settings.rb b/app/lib/settings/scoped_settings.rb
index 9889940f3..95e195458 100644
--- a/app/lib/settings/scoped_settings.rb
+++ b/app/lib/settings/scoped_settings.rb
@@ -31,7 +31,7 @@ module Settings
 
     def all_as_records
       vars = thing_scoped
-      records = vars.each_with_object({}) { |r, h| h[r.var] = r }
+      records = vars.index_by(&:var)
 
       Setting.default_settings.each do |key, default_value|
         next if records.key?(key) || default_value.is_a?(Hash)
diff --git a/app/lib/webfinger.rb b/app/lib/webfinger.rb
index c7aa43bb3..702365939 100644
--- a/app/lib/webfinger.rb
+++ b/app/lib/webfinger.rb
@@ -21,7 +21,7 @@ class Webfinger
     private
 
     def links
-      @links ||= @json['links'].map { |link| [link['rel'], link] }.to_h
+      @links ||= @json['links'].index_by { |link| link['rel'] }
     end
   end