diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2019-06-04 23:11:18 +0200 |
---|---|---|
committer | multiple creatures <dev@multiple-creature.party> | 2019-11-19 16:32:36 -0600 |
commit | fbf08920a0d73231c04b35c263ea4e04224b6e7d (patch) | |
tree | afc2717ba1e5b121d170d0d5adc5236cf73f78dd /app/models | |
parent | 82bd234c3cb4aed81ab4e4c8844bd27d065ea4d9 (diff) |
Refactor all ActivityPub deliveries to be serialized and signed through one concern (#10966)
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/account.rb | 4 | ||||
-rw-r--r-- | app/models/form/account_batch.rb | 9 | ||||
-rw-r--r-- | app/models/status.rb | 2 |
3 files changed, 9 insertions, 6 deletions
diff --git a/app/models/account.rb b/app/models/account.rb index 36616c789..6841fba3a 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -307,6 +307,10 @@ class Account < ApplicationRecord end end + def sign? + true + end + def keypair @keypair ||= OpenSSL::PKey::RSA.new(private_key || public_key) end diff --git a/app/models/form/account_batch.rb b/app/models/form/account_batch.rb index eed65b47a..f1b7a4566 100644 --- a/app/models/form/account_batch.rb +++ b/app/models/form/account_batch.rb @@ -3,6 +3,7 @@ class Form::AccountBatch include ActiveModel::Model include Authorization + include Payloadable attr_accessor :account_ids, :action, :current_account @@ -52,13 +53,9 @@ class Form::AccountBatch def reject_follow!(follow) follow.destroy - json = ActiveModelSerializers::SerializableResource.new( - follow, - serializer: ActivityPub::RejectFollowSerializer, - adapter: ActivityPub::Adapter - ).to_json + return unless follow.account.activitypub? - ActivityPub::DeliveryWorker.perform_async(json, current_account.id, follow.account.inbox_url) + ActivityPub::DeliveryWorker.perform_async(Oj.dump(serialize_payload(follow, ActivityPub::RejectFollowSerializer)), current_account.id, follow.account.inbox_url) end def approve! diff --git a/app/models/status.rb b/app/models/status.rb index c1e68e2f2..ff83f5ad5 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -254,6 +254,8 @@ class Status < ApplicationRecord public_visibility? || unlisted_visibility? || local_visibility? end + alias sign? distributable? + def with_media? media_attachments.any? end |