activitypub-academy/app/lib/activity_log_audience_helper.rb

31 lines
714 B
Ruby
Raw Normal View History

2023-01-05 01:29:24 +09:00
# frozen_string_literal: true
class ActivityLogAudienceHelper
def self.audience(activity_log_event)
domain = Rails.configuration.x.local_domain
2023-01-05 01:29:24 +09:00
if activity_log_event.type == 'outbound'
actor = activity_log_event.data['actor']
if actor and match = actor.match(Regexp.new("https://#{domain}/users/(.*)"))
2023-01-05 01:29:24 +09:00
return [match.captures[0]]
else
return []
end
end
if activity_log_event.type == 'inbound'
if match = activity_log_event.path.match(Regexp.new("https://#{domain}/users/(.*)/inbox"))
2023-01-05 01:29:24 +09:00
return [match.captures[0]]
elsif activity_log_event.path == "https://#{domain}/inbox"
2023-01-05 01:29:24 +09:00
end
return []
end
return []
2023-01-05 01:29:24 +09:00
end
end