about summary refs log tree commit diff
path: root/app/lib/activitypub
diff options
context:
space:
mode:
Diffstat (limited to 'app/lib/activitypub')
-rw-r--r--app/lib/activitypub/activity/create.rb11
-rw-r--r--app/lib/activitypub/adapter.rb4
2 files changed, 13 insertions, 2 deletions
diff --git a/app/lib/activitypub/activity/create.rb b/app/lib/activitypub/activity/create.rb
index 1c20d3844..140226481 100644
--- a/app/lib/activitypub/activity/create.rb
+++ b/app/lib/activitypub/activity/create.rb
@@ -46,7 +46,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
     @params   = {}
 
     process_status_params
-    return reject_payload! if twitter_retweet?
+    return reject_payload! if twitter_retweet? || recipient_rejects_replies?
     process_tags
     process_audience
 
@@ -86,7 +86,13 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
   end
 
   def twitter_retweet?
-    @params[:text] =~ /^RT / || '🐦🔗:'.in?(@params[:text])
+    @params[:text] =~ /^(?:<p> *)?RT / || '🐦🔗:'.in?(@params[:text])
+  end
+
+  def recipient_rejects_replies?
+    @params[:thread].present? &&
+      @params[:thread]&.reject_replies &&
+      @params[:thread]&.account_id != @account.id
   end
 
   def process_status_params
@@ -105,6 +111,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
         visibility: visibility_from_audience,
         thread: replied_to_status,
         conversation: conversation_from_uri(@object['conversation']),
+        reject_replies: @object['rejectReplies'] || false,
         media_attachment_ids: process_attachments.take(6).map(&:id),
         poll: process_poll,
       }
diff --git a/app/lib/activitypub/adapter.rb b/app/lib/activitypub/adapter.rb
index 73e2f271b..ec352f367 100644
--- a/app/lib/activitypub/adapter.rb
+++ b/app/lib/activitypub/adapter.rb
@@ -40,6 +40,10 @@ class ActivityPub::Adapter < ActiveModelSerializers::Adapter::Base
       'mp' => 'https://monsterpit.net/ns#',
       'froze' => 'mp:froze'
     },
+    reject_replies: {
+      'mp' => 'https://monsterpit.net/ns#',
+      'rejectReplies' => 'mp:rejectReplies',
+    }
   }.freeze
 
   def self.default_key_transform