diff options
author | Fire Demon <firedemon@creature.cafe> | 2020-08-03 04:52:21 -0500 |
---|---|---|
committer | ThibG <thib@sitedethib.com> | 2020-08-04 19:43:19 +0200 |
commit | 3d5b3e357c26aeee86da8f69a86130d52f325729 (patch) | |
tree | 1d7de09a4fd381f6dad447c3753cd61cf718ff4b /app/lib | |
parent | b988bc75649425266e848a25290a86a9fc53625e (diff) |
Add support for direct message assertions
Diffstat (limited to 'app/lib')
-rw-r--r-- | app/lib/activitypub/activity/create.rb | 12 | ||||
-rw-r--r-- | app/lib/activitypub/adapter.rb | 1 |
2 files changed, 10 insertions, 3 deletions
diff --git a/app/lib/activitypub/activity/create.rb b/app/lib/activitypub/activity/create.rb index 08dd98e94..f09caaae4 100644 --- a/app/lib/activitypub/activity/create.rb +++ b/app/lib/activitypub/activity/create.rb @@ -137,7 +137,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 @@ -148,7 +148,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 @@ -159,7 +159,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) @@ -358,6 +358,8 @@ class ActivityPub::Activity::Create < ActivityPub::Activity :unlisted elsif equals_or_includes?(audience_to, @account.followers_url) :private + elsif direct_message == false + :limited else :direct end @@ -368,6 +370,10 @@ class ActivityPub::Activity::Create < ActivityPub::Activity equals_or_includes?(audience_to, uri) || equals_or_includes?(audience_cc, uri) end + def direct_message + @object['directMessage'] + end + def replied_to_status return @replied_to_status if defined?(@replied_to_status) diff --git a/app/lib/activitypub/adapter.rb b/app/lib/activitypub/adapter.rb index 634ed29fa..712c48823 100644 --- a/app/lib/activitypub/adapter.rb +++ b/app/lib/activitypub/adapter.rb @@ -7,6 +7,7 @@ class ActivityPub::Adapter < ActiveModelSerializers::Adapter::Base }.freeze CONTEXT_EXTENSION_MAP = { + direct_message: { 'litepub': 'http://litepub.social/ns#', 'directMessage': 'litepub:directMessage' }, manually_approves_followers: { 'manuallyApprovesFollowers' => 'as:manuallyApprovesFollowers' }, sensitive: { 'sensitive' => 'as:sensitive' }, hashtag: { 'Hashtag' => 'as:Hashtag' }, |