log outbound events as well
This commit is contained in:
parent
a414adc582
commit
3f4a72e7f3
5 changed files with 29 additions and 4 deletions
app
controllers/activitypub
lib
workers/activitypub
config
lib
|
@ -10,6 +10,10 @@ class ActivityPub::InboxesController < ActivityPub::BaseController
|
|||
before_action :require_actor_signature!
|
||||
skip_before_action :authenticate_user!
|
||||
|
||||
def initialize
|
||||
@activity_log_publisher = ActivityLogPublisher.new
|
||||
end
|
||||
|
||||
def create
|
||||
upgrade_account
|
||||
process_collection_synchronization
|
||||
|
@ -77,7 +81,7 @@ class ActivityPub::InboxesController < ActivityPub::BaseController
|
|||
event.path = request.path
|
||||
event.data = Oj.load(body, mode: :strict)
|
||||
|
||||
Redis.new.publish('activity_log', Oj.dump(event))
|
||||
@activity_log_publisher.publish(event)
|
||||
|
||||
ActivityPub::ProcessingWorker.perform_async(signed_request_actor.id, body, @account&.id, signed_request_actor.class.name)
|
||||
end
|
||||
|
|
10
app/lib/activity_log_publisher.rb
Normal file
10
app/lib/activity_log_publisher.rb
Normal file
|
@ -0,0 +1,10 @@
|
|||
class ActivityLogPublisher
|
||||
|
||||
def initialize
|
||||
@redis = Redis.new
|
||||
end
|
||||
|
||||
def publish(log_event)
|
||||
@redis.publish('activity_log', Oj.dump(log_event))
|
||||
end
|
||||
end
|
|
@ -12,9 +12,20 @@ class ActivityPub::DeliveryWorker
|
|||
|
||||
HEADERS = { 'Content-Type' => 'application/activity+json' }.freeze
|
||||
|
||||
def initialize
|
||||
@activity_log_publisher = ActivityLogPublisher.new
|
||||
end
|
||||
|
||||
def perform(json, source_account_id, inbox_url, options = {})
|
||||
return unless DeliveryFailureTracker.available?(inbox_url)
|
||||
|
||||
event = ActivityLogEvent.new
|
||||
event.type = 'outbound'
|
||||
event.path = inbox_url
|
||||
event.data = Oj.load(json, mode: :strict)
|
||||
|
||||
@activity_log_publisher.publish(event)
|
||||
|
||||
Rails.logger.error "=====PUSH===== #{json}"
|
||||
|
||||
@options = options.with_indifferent_access
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require_relative '../lib/activity_subscriber'
|
||||
require_relative '../lib/activity_log_subscriber'
|
||||
|
||||
persistent_timeout ENV.fetch('PERSISTENT_TIMEOUT') { 20 }.to_i
|
||||
|
||||
|
@ -22,7 +22,7 @@ on_worker_boot do
|
|||
end
|
||||
|
||||
Thread.new {
|
||||
ActivitySubscriber.new.start
|
||||
ActivityLogSubscriber.new.start
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
require 'redis'
|
||||
|
||||
class ActivitySubscriber
|
||||
class ActivityLogSubscriber
|
||||
def start
|
||||
redis = Redis.new
|
||||
|
Loading…
Add table
Reference in a new issue