2022-12-07 03:37:33 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
require 'redis'
|
|
|
|
|
2022-12-07 19:51:25 +09:00
|
|
|
class ActivityLogSubscriber
|
2022-12-07 03:37:33 +09:00
|
|
|
def start
|
2023-01-10 05:46:58 +09:00
|
|
|
redis = RedisConfiguration.new.connection
|
2022-12-07 03:37:33 +09:00
|
|
|
|
|
|
|
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'])
|
2022-12-07 03:37:33 +09:00
|
|
|
|
2023-01-05 23:15:25 +09:00
|
|
|
ActivityLogAudienceHelper.audience(event)
|
|
|
|
.each { |username| ActivityLogger.log(username, event) }
|
2022-12-07 03:37:33 +09:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|