From 1d2eba7a84b70d4bb6035ae27b00def9e632afb5 Mon Sep 17 00:00:00 2001 From: unarist Date: Wed, 21 Jun 2017 03:40:56 +0900 Subject: [PATCH] Fix RemoteFollow behavior (#3868) * Invalid acct is an error. not "2 errors". * Empty input should be different error from invalid acct --- app/models/remote_follow.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/models/remote_follow.rb b/app/models/remote_follow.rb index 3da3ba0ae7..8366d43c5b 100644 --- a/app/models/remote_follow.rb +++ b/app/models/remote_follow.rb @@ -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