integrate audience helper
This commit is contained in:
parent
14b89d1e71
commit
e13a05cb83
3 changed files with 12 additions and 13 deletions
|
@ -76,7 +76,7 @@ class ActivityPub::InboxesController < ActivityPub::BaseController
|
|||
end
|
||||
|
||||
def process_payload
|
||||
event = ActivityLogEvent.new('inbound', request.path, Oj.load(body, mode: :strict))
|
||||
event = ActivityLogEvent.new('inbound', "https://#{Rails.configuration.x.web_domain}#{request.path}", Oj.load(body, mode: :strict))
|
||||
|
||||
@activity_log_publisher.publish(event)
|
||||
|
||||
|
|
|
@ -9,26 +9,24 @@ class ActivityLogAudienceHelper
|
|||
actor = activity_log_event.data['actor']
|
||||
|
||||
if actor and match = actor.match(Regexp.new("https://#{domain}/users/([^/]*)"))
|
||||
return [match.captures[0]]
|
||||
[match.captures[0]]
|
||||
else
|
||||
return []
|
||||
[]
|
||||
end
|
||||
end
|
||||
|
||||
if activity_log_event.type == 'inbound'
|
||||
elsif activity_log_event.type == 'inbound'
|
||||
if match = activity_log_event.path.match(Regexp.new("https://#{domain}/users/([^/]*)/inbox"))
|
||||
return [match.captures[0]]
|
||||
[match.captures[0]]
|
||||
elsif activity_log_event.path == "https://#{domain}/inbox"
|
||||
return ['to', 'bto', 'cc', 'bcc']
|
||||
['to', 'bto', 'cc', 'bcc']
|
||||
.map { |target| actors(activity_log_event.data[target]) }
|
||||
.flatten
|
||||
.uniq
|
||||
else
|
||||
[]
|
||||
end
|
||||
|
||||
return []
|
||||
else
|
||||
[]
|
||||
end
|
||||
|
||||
return []
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -10,7 +10,8 @@ class ActivityLogSubscriber
|
|||
json = Oj.load(message, mode: :strict)
|
||||
event = ActivityLogEvent.new(json['type'], json['path'], json['data'])
|
||||
|
||||
ActivityLogger.log('admin', event)
|
||||
ActivityLogAudienceHelper.audience(event)
|
||||
.each { |username| ActivityLogger.log(username, event) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue