activitypub-academy/app/lib/activity_log_audience_helper.rb
2023-01-09 14:48:03 +01:00

26 lines
662 B
Ruby

# frozen_string_literal: true
class ActivityLogAudienceHelper
def self.audience(activity_log_event)
if activity_log_event.type == 'outbound'
actor = activity_log_event.data['actor']
if actor and match = actor.match(Regexp.new("https://#{Rails.configuration.x.local_domain}/users/(.*)"))
return [match.captures[0]]
else
return []
end
end
if activity_log_event.type == 'inbound'
if match = activity_log_event.path.match(Regexp.new("https://#{Rails.configuration.x.local_domain}/users/(.*)/inbox"))
return [match.captures[0]]
end
return []
end
return ['admin']
end
end