activitypub-academy/lib/activity_log_subscriber.rb
2023-07-03 19:56:10 +02:00

21 lines
583 B
Ruby

# frozen_string_literal: true
require 'redis'
class ActivityLogSubscriber
def start
redis = RedisConfiguration.new.connection
redis.subscribe('activity_log') do |on|
on.message do |channel, message|
begin
event = ActivityLogEvent.from_json_string(message)
ActivityLogAudienceHelper.audience(event)
.each { |username| ActivityLogger.log(username, event) }
rescue => e
Rails.logger.error (["Error parsing #{message}. #{e.class}: #{e.message}"]+e.backtrace).join("\n")
end
end
end
end
end