From f2b743e715758f6af818f68fb77cd44d2451ae48 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Tue, 4 Jun 2019 23:11:18 +0200 Subject: Refactor all ActivityPub deliveries to be serialized and signed through one concern (#10966) --- app/models/account.rb | 4 ++++ app/models/form/account_batch.rb | 9 ++------- app/models/status.rb | 2 ++ 3 files changed, 8 insertions(+), 7 deletions(-) (limited to 'app/models') diff --git a/app/models/account.rb b/app/models/account.rb index fe48fce10..c977f887c 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -204,6 +204,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 5bc44e809..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 @@ -54,13 +55,7 @@ class Form::AccountBatch return unless follow.account.activitypub? - json = ActiveModelSerializers::SerializableResource.new( - follow, - serializer: ActivityPub::RejectFollowSerializer, - adapter: ActivityPub::Adapter - ).to_json - - 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 2f6101b90..a7f32f41c 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -204,6 +204,8 @@ class Status < ApplicationRecord public_visibility? || unlisted_visibility? end + alias sign? distributable? + def with_media? media_attachments.any? end -- cgit From 6a9a759f40801f65a3da9315fe143fa3cb0007ee Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Tue, 4 Jun 2019 23:11:44 +0200 Subject: Change reblogs counter to be updated when boosted privately (#10964) --- app/models/status.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/models') diff --git a/app/models/status.rb b/app/models/status.rb index a7f32f41c..fb9bbc9a9 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -499,7 +499,7 @@ class Status < ApplicationRecord return if direct_visibility? account&.increment_count!(:statuses_count) - reblog&.increment_count!(:reblogs_count) if reblog? && (public_visibility? || unlisted_visibility?) + reblog&.increment_count!(:reblogs_count) if reblog? thread&.increment_count!(:replies_count) if in_reply_to_id.present? && (public_visibility? || unlisted_visibility?) end @@ -507,7 +507,7 @@ class Status < ApplicationRecord return if direct_visibility? || marked_for_mass_destruction? account&.decrement_count!(:statuses_count) - reblog&.decrement_count!(:reblogs_count) if reblog? && (public_visibility? || unlisted_visibility?) + reblog&.decrement_count!(:reblogs_count) if reblog? thread&.decrement_count!(:replies_count) if in_reply_to_id.present? && (public_visibility? || unlisted_visibility?) end -- cgit