activitypub-academy/lib/activity_log_subscriber.rb
2023-04-17 17:50:35 +02:00

18 lines
465 B
Ruby

# frozen_string_literal: true
require 'redis'
class ActivityLogSubscriber
def start
redis = Redis.new
redis.subscribe('activity_log') do |on|
on.message do |channel, message|
json = Oj.load(message, mode: :strict)
event = ActivityLogEvent.new(json['type'], json['path'], json['data'])
ActivityLogAudienceHelper.audience(event)
.each { |username| ActivityLogger.log(username, event) }
end
end
end
end