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.

19 lines
621 B

  1. class PostStatusService < BaseService
  2. def call(account, text, in_reply_to = nil)
  3. status = account.statuses.create!(text: text, thread: in_reply_to)
  4. status.text.scan(Account::MENTION_RE).each do |match|
  5. next if match.first.split('@').size == 1
  6. username, domain = match.first.split('@')
  7. local_account = Account.find_by(username: username, domain: domain)
  8. next unless local_account.nil?
  9. follow_remote_account_service.("acct:#{match.first}")
  10. end
  11. end
  12. private
  13. def follow_remote_account_service
  14. @follow_remote_account_service ||= FollowRemoteAccountService.new
  15. end
  16. end