18 lines
465 B
Ruby
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
|