Sha256: 86bc0602e360885625972ec54e2249212651bcce2aa0577b9eb3f4c5d129c670

Contents?: true

Size: 693 Bytes

Versions: 1

Compression:

Stored size: 693 Bytes

Contents

module Fediverse
  class Notifier
    class << self
      def post_to_inboxes(activity)
        actors = activity.recipients

        Rails.logger.debug('Nobody to notice') && return if actors.count.zero?

        message = Federails::ApplicationController.renderer.new.render(
          template: 'federails/server/activities/show',
          assigns:  { activity: activity },
          format:   :json
        )
        actors.each do |actor|
          Rails.logger.debug { "Sending activity ##{activity.id} to #{actor.inbox_url}" }
          Faraday.post actor.inbox_url, message, 'Content-Type' => 'application/json', 'Accept' => 'application/json'
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
federails-0.1.0 lib/fediverse/notifier.rb