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