activitypub-academy/lib/activity_log_subscriber.rb

19 lines
489 B
Ruby
Raw Normal View History

# frozen_string_literal: true
require 'redis'
2022-12-07 19:51:25 +09:00
class ActivityLogSubscriber
def start
redis = RedisConfiguration.new.connection
redis.subscribe('activity_log') do |on|
on.message do |channel, message|
json = Oj.load(message, mode: :strict)
2023-01-05 01:29:24 +09:00
event = ActivityLogEvent.new(json['type'], json['path'], json['data'])
2023-01-05 23:15:25 +09:00
ActivityLogAudienceHelper.audience(event)
.each { |username| ActivityLogger.log(username, event) }
end
end
end
end