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
|
end
|
||||||
|
|
||||||
def process_payload
|
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)
|
@activity_log_publisher.publish(event)
|
||||||
|
|
||||||
|
|
|
@ -9,26 +9,24 @@ class ActivityLogAudienceHelper
|
||||||
actor = activity_log_event.data['actor']
|
actor = activity_log_event.data['actor']
|
||||||
|
|
||||||
if actor and match = actor.match(Regexp.new("https://#{domain}/users/([^/]*)"))
|
if actor and match = actor.match(Regexp.new("https://#{domain}/users/([^/]*)"))
|
||||||
return [match.captures[0]]
|
[match.captures[0]]
|
||||||
else
|
else
|
||||||
return []
|
[]
|
||||||
end
|
end
|
||||||
end
|
elsif activity_log_event.type == 'inbound'
|
||||||
|
|
||||||
if activity_log_event.type == 'inbound'
|
|
||||||
if match = activity_log_event.path.match(Regexp.new("https://#{domain}/users/([^/]*)/inbox"))
|
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"
|
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]) }
|
.map { |target| actors(activity_log_event.data[target]) }
|
||||||
.flatten
|
.flatten
|
||||||
.uniq
|
.uniq
|
||||||
|
else
|
||||||
|
[]
|
||||||
end
|
end
|
||||||
|
else
|
||||||
return []
|
[]
|
||||||
end
|
end
|
||||||
|
|
||||||
return []
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -10,7 +10,8 @@ class ActivityLogSubscriber
|
||||||
json = Oj.load(message, mode: :strict)
|
json = Oj.load(message, mode: :strict)
|
||||||
event = ActivityLogEvent.new(json['type'], json['path'], json['data'])
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue