about summary refs log tree commit diff
path: root/app/lib/activitypub/activity/create.rb
diff options
context:
space:
mode:
authorpluralcafe-docker <git@plural.cafe>2018-11-02 00:56:08 +0000
committerpluralcafe-docker <git@plural.cafe>2018-11-02 00:56:08 +0000
commit521df92d8ccdc715b3ee9e1ccea63fbd6810f5c5 (patch)
tree3726f4f70214171ab56fc0f8803d669ce4c9efe0 /app/lib/activitypub/activity/create.rb
parent431c09bfbe07715a2a88846864179a419d72ab59 (diff)
parent34209c0340ca6b7c61de964a17f5f3fe2e0f7c7b (diff)
Merge branch 'glitch'
Diffstat (limited to 'app/lib/activitypub/activity/create.rb')
-rw-r--r--app/lib/activitypub/activity/create.rb20
1 files changed, 19 insertions, 1 deletions
diff --git a/app/lib/activitypub/activity/create.rb b/app/lib/activitypub/activity/create.rb
index baa05e14c..45079e2b3 100644
--- a/app/lib/activitypub/activity/create.rb
+++ b/app/lib/activitypub/activity/create.rb
@@ -10,7 +10,12 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
     RedisLock.acquire(lock_options) do |lock|
       if lock.acquired?
         @status = find_existing_status
-        process_status if @status.nil?
+
+        if @status.nil?
+          process_status
+        elsif @options[:delivered_to_account_id].present?
+          postprocess_audience_and_deliver
+        end
       else
         raise Mastodon::RaceConditionError
       end
@@ -99,6 +104,19 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
     @params[:visibility] = :limited
   end
 
+  def postprocess_audience_and_deliver
+    return if @status.mentions.find_by(account_id: @options[:delivered_to_account_id])
+
+    delivered_to_account = Account.find(@options[:delivered_to_account_id])
+
+    @status.mentions.create(account: delivered_to_account, silent: true)
+    @status.update(visibility: :limited) if @status.direct_visibility?
+
+    return unless delivered_to_account.following?(@account)
+
+    FeedInsertWorker.perform_async(@status.id, delivered_to_account.id, :home)
+  end
+
   def attach_tags(status)
     @tags.each do |tag|
       status.tags << tag