]> cat aescling's git repositories - mastodon.git/commitdiff
Fix RemoteFollow behavior (#3868)
authorunarist <m.unarist@gmail.com>
Tue, 20 Jun 2017 18:40:56 +0000 (03:40 +0900)
committerEugen Rochko <eugen@zeonfederated.com>
Tue, 20 Jun 2017 18:40:56 +0000 (20:40 +0200)
* Invalid acct is an error. not "2 errors".
* Empty input should be different error from invalid acct

app/models/remote_follow.rb

index 3da3ba0ae7dab56e3c3f1d7edbcb9c51cdd902c8..8366d43c5bc0227f0a3242c6cc8552d83127831e 100644 (file)
@@ -5,11 +5,15 @@ class RemoteFollow
 
   attr_accessor :acct, :addressable_template
 
+  validates :acct, presence: true
+
   def initialize(attrs = {})
     @acct = attrs[:acct].gsub(/\A@/, '').strip unless attrs[:acct].nil?
   end
 
   def valid?
+    return false unless super
+
     populate_template
     errors.empty?
   end
@@ -39,7 +43,6 @@ class RemoteFollow
   def acct_resource
     @_acct_resource ||= Goldfinger.finger("acct:#{acct}")
   rescue Goldfinger::Error
-    missing_resource_error
     nil
   end