You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
701 B

  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