diff options
author | beatrix <beatrix.bitrot@gmail.com> | 2017-09-09 20:11:48 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-09 20:11:48 -0400 |
commit | 3dff74eecf5387b92b862893248710d2efb90eec (patch) | |
tree | 0d29d8c952a0c62e7de4348a1d63963fd5eca237 /app/services/reblog_service.rb | |
parent | e18ed4bbc7ab4e258d05a3e2a5db0790f67a8f37 (diff) | |
parent | 14e1fb8d36763e5255e7b8e440ecaf02208db004 (diff) |
Merge pull request #141 from yipdw/sync/upstream
Sync with upstream @ v1.6.0rc3 ohhhhhhhhhhh heck here we go
Diffstat (limited to 'app/services/reblog_service.rb')
-rw-r--r-- | app/services/reblog_service.rb | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/app/services/reblog_service.rb b/app/services/reblog_service.rb index 497cdb4f5..52e3ba0e0 100644 --- a/app/services/reblog_service.rb +++ b/app/services/reblog_service.rb @@ -20,17 +20,35 @@ class ReblogService < BaseService reblog = account.statuses.create!(reblog: reblogged_status, text: '') DistributionWorker.perform_async(reblog.id) + unless /👁$/.match?(reblogged_status.content) Pubsubhubbub::DistributionWorker.perform_async(reblog.stream_entry.id) + ActivityPub::DistributionWorker.perform_async(reblog.id) end + create_notification(reblog) + reblog + end + + private - if reblogged_status.local? - NotifyService.new.call(reblog.reblog.account, reblog) - else - NotificationWorker.perform_async(stream_entry_to_xml(reblog.stream_entry), account.id, reblog.reblog.account_id) + def create_notification(reblog) + reblogged_status = reblog.reblog + + if reblogged_status.account.local? + NotifyService.new.call(reblogged_status.account, reblog) + elsif reblogged_status.account.ostatus? + NotificationWorker.perform_async(stream_entry_to_xml(reblog.stream_entry), reblog.account_id, reblogged_status.account_id) + elsif reblogged_status.account.activitypub? && !reblogged_status.account.following?(reblog.account) + ActivityPub::DeliveryWorker.perform_async(build_json(reblog), reblog.account_id, reblogged_status.account.inbox_url) end + end - reblog + def build_json(reblog) + Oj.dump(ActivityPub::LinkedDataSignature.new(ActiveModelSerializers::SerializableResource.new( + reblog, + serializer: ActivityPub::ActivitySerializer, + adapter: ActivityPub::Adapter + ).as_json).sign!(reblog.account)) end end |