about summary refs log tree commit diff
path: root/app/lib/activitypub/activity/create.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/lib/activitypub/activity/create.rb')
-rw-r--r--app/lib/activitypub/activity/create.rb12
1 files changed, 9 insertions, 3 deletions
diff --git a/app/lib/activitypub/activity/create.rb b/app/lib/activitypub/activity/create.rb
index 9a2960507..cc2d391fb 100644
--- a/app/lib/activitypub/activity/create.rb
+++ b/app/lib/activitypub/activity/create.rb
@@ -132,7 +132,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
       # If there is at least one silent mention, then the status can be considered
       # as a limited-audience status, and not strictly a direct message, but only
       # if we considered a direct message in the first place
-      next unless @params[:visibility] == :direct
+      next unless @params[:visibility] == :direct && direct_message.nil?
 
       @params[:visibility] = :limited
     end
@@ -143,7 +143,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
 
     @mentions << Mention.new(account_id: @options[:delivered_to_account_id], silent: true)
 
-    return unless @params[:visibility] == :direct
+    return unless @params[:visibility] == :direct && direct_message.nil?
 
     @params[:visibility] = :limited
   end
@@ -154,7 +154,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
     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?
+    @status.update(visibility: :limited) if @status.direct_visibility? && direct_message.nil?
 
     return unless delivered_to_account.following?(@account)
 
@@ -353,6 +353,8 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
       :unlisted
     elsif audience_to.include?(@account.followers_url)
       :private
+    elsif direct_message == false
+      :limited
     else
       :direct
     end
@@ -363,6 +365,10 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
     audience_to.include?(uri) || audience_cc.include?(uri)
   end
 
+  def direct_message
+    @object['directMessage']
+  end
+
   def replied_to_status
     return @replied_to_status if defined?(@replied_to_status)