about summary refs log tree commit diff
path: root/app/models/concerns/account_interactions.rb
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2021-08-20 14:26:14 +0200
committerGitHub <noreply@github.com>2021-08-20 14:26:14 +0200
commit65b003cab86b6837012f4562d3d9d0910f3e942e (patch)
tree5d63d6f54c327bb3b0feecae7019a7fcd2e0cd9f /app/models/concerns/account_interactions.rb
parent4a364de500029676b9828ec596ed6c2a09cfb65c (diff)
parent4f074b68ba4b9b91a7989f3f7d64ab29cf42214c (diff)
Merge pull request #1588 from ClearlyClaire/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app/models/concerns/account_interactions.rb')
-rw-r--r--app/models/concerns/account_interactions.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/app/models/concerns/account_interactions.rb b/app/models/concerns/account_interactions.rb
index 4bf62539c..8f19176a7 100644
--- a/app/models/concerns/account_interactions.rb
+++ b/app/models/concerns/account_interactions.rb
@@ -254,10 +254,13 @@ module AccountInteractions
          .where('users.current_sign_in_at > ?', User::ACTIVE_DURATION.ago)
   end
 
-  def remote_followers_hash(url_prefix)
-    Rails.cache.fetch("followers_hash:#{id}:#{url_prefix}") do
+  def remote_followers_hash(url)
+    url_prefix = url[Account::URL_PREFIX_RE]
+    return if url_prefix.blank?
+
+    Rails.cache.fetch("followers_hash:#{id}:#{url_prefix}/") do
       digest = "\x00" * 32
-      followers.where(Account.arel_table[:uri].matches(url_prefix + '%', false, true)).pluck_each(:uri) do |uri|
+      followers.where(Account.arel_table[:uri].matches("#{Account.sanitize_sql_like(url_prefix)}/%", false, true)).or(followers.where(uri: url_prefix)).pluck_each(:uri) do |uri|
         Xorcist.xor!(digest, Digest::SHA256.digest(uri))
       end
       digest.unpack('H*')[0]