闭社主体 forked from https://github.com/tootsuite/mastodon
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.

25 lines
541 B

  1. # frozen_string_literal: true
  2. class Form::Migration
  3. include ActiveModel::Validations
  4. attr_accessor :acct, :account
  5. def initialize(attrs = {})
  6. @account = attrs[:account]
  7. @acct = attrs[:account].acct unless @account.nil?
  8. @acct = attrs[:acct].gsub(/\A@/, '').strip unless attrs[:acct].nil?
  9. end
  10. def valid?
  11. return false unless super
  12. set_account
  13. errors.empty?
  14. end
  15. private
  16. def set_account
  17. self.account = (ResolveRemoteAccountService.new.call(acct) if account.nil? && acct.present?)
  18. end
  19. end