]> cat aescling's git repositories - mastodon.git/commitdiff
Fix #2027 - Accept own ID for remote follow with and without preceding @ (#2991)
authorEugen Rochko <eugen@zeonfederated.com>
Thu, 11 May 2017 19:54:30 +0000 (21:54 +0200)
committerGitHub <noreply@github.com>
Thu, 11 May 2017 19:54:30 +0000 (21:54 +0200)
* Fix #2027 - Accept own ID for remote follow with and without preceding @
Fix #2177 - Omit leading "acct:" in remote follow redirect template expansion

* Fix test

app/models/remote_follow.rb
spec/controllers/remote_follow_controller_spec.rb

index c226cdb143ca0925562f0349855181ba1c4bccfe..3da3ba0ae7dab56e3c3f1d7edbcb9c51cdd902c8 100644 (file)
@@ -6,7 +6,7 @@ class RemoteFollow
   attr_accessor :acct, :addressable_template
 
   def initialize(attrs = {})
-    @acct = attrs[:acct].strip unless attrs[:acct].nil?
+    @acct = attrs[:acct].gsub(/\A@/, '').strip unless attrs[:acct].nil?
   end
 
   def valid?
@@ -15,7 +15,7 @@ class RemoteFollow
   end
 
   def subscribe_address_for(account)
-    addressable_template.expand(uri: account.to_webfinger_s).to_s
+    addressable_template.expand(uri: account.local_username_and_domain).to_s
   end
 
   private
index ce04e2c43269813088d31f20f4a3b145b1878f69..915c86f8ea5c3a1cdafd092018da887293c270a6 100644 (file)
@@ -66,7 +66,7 @@ describe RemoteFollowController do
         end
 
         it 'redirects to the remote location' do
-          address = "http://example.com/follow_me?acct=acct%3Atest_user%40#{Rails.configuration.x.local_domain}"
+          address = "http://example.com/follow_me?acct=test_user%40#{Rails.configuration.x.local_domain}"
 
           expect(response).to redirect_to(address)
         end