post_status_service.rb 701 B

1234567891011121314151617181920
  1. class PostStatusService < BaseService
  2. # Post a text status update, fetch and notify remote users mentioned
  3. # @param [Account] account Account from which to post
  4. # @param [String] text Message
  5. # @param [Status] in_reply_to Optional status to reply to
  6. # @return [Status]
  7. def call(account, text, in_reply_to = nil)
  8. status = account.statuses.create!(text: text, thread: in_reply_to)
  9. process_mentions_service.(status)
  10. DistributionWorker.perform_async(status.id)
  11. account.ping!(account_url(account, format: 'atom'), [Rails.configuration.x.hub_url])
  12. status
  13. end
  14. private
  15. def process_mentions_service
  16. @process_mentions_service ||= ProcessMentionsService.new
  17. end
  18. end