about summary refs log tree commit diff
path: root/app/services/reblog_service.rb
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2020-03-08 22:09:53 +0100
committerGitHub <noreply@github.com>2020-03-08 22:09:53 +0100
commit840b17e3444f9a68d3639f1ffeb326e8cb1e03b1 (patch)
tree8254538ed33f4c4b974b5379f3b5a0b489ba095a /app/services/reblog_service.rb
parent13ef4d5fb0dbb66074f42df7989ae40509a4724f (diff)
parent9c2922958783f7e499cdda5bb874d6096e47eb0a (diff)
Merge pull request #1297 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app/services/reblog_service.rb')
-rw-r--r--app/services/reblog_service.rb16
1 files changed, 13 insertions, 3 deletions
diff --git a/app/services/reblog_service.rb b/app/services/reblog_service.rb
index 0b12f143c..0a46509f8 100644
--- a/app/services/reblog_service.rb
+++ b/app/services/reblog_service.rb
@@ -8,6 +8,8 @@ class ReblogService < BaseService
   # @param [Account] account Account to reblog from
   # @param [Status] reblogged_status Status to be reblogged
   # @param [Hash] options
+  # @option [String]  :visibility
+  # @option [Boolean] :with_rate_limit
   # @return [Status]
   def call(account, reblogged_status, options = {})
     reblogged_status = reblogged_status.reblog if reblogged_status.reblog?
@@ -18,9 +20,15 @@ class ReblogService < BaseService
 
     return reblog unless reblog.nil?
 
-    visibility = options[:visibility] || account.user&.setting_default_privacy
-    visibility = reblogged_status.visibility if reblogged_status.hidden?
-    reblog = account.statuses.create!(reblog: reblogged_status, text: '', visibility: visibility)
+    visibility = begin
+      if reblogged_status.hidden?
+        reblogged_status.visibility
+      else
+        options[:visibility] || account.user&.setting_default_privacy
+      end
+    end
+
+    reblog = account.statuses.create!(reblog: reblogged_status, text: '', visibility: visibility, rate_limit: options[:with_rate_limit])
 
     DistributionWorker.perform_async(reblog.id)
     ActivityPub::DistributionWorker.perform_async(reblog.id) unless reblogged_status.local_only?
@@ -45,7 +53,9 @@ class ReblogService < BaseService
 
   def bump_potential_friendship(account, reblog)
     ActivityTracker.increment('activity:interactions')
+
     return if account.following?(reblog.reblog.account_id)
+
     PotentialFriendshipTracker.record(account.id, reblog.reblog.account_id, :reblog)
   end