diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2016-09-23 20:23:26 +0200 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2016-09-23 20:23:26 +0200 |
commit | 3f9708edc4cd799afb68000adc35036dd8b8faa5 (patch) | |
tree | af7e97a0095c562810577acf68933b461e126794 /app/controllers/api/accounts_controller.rb | |
parent | c6d893a71dede65dd88a0dfac81178c8e81e27d2 (diff) |
Change output of api/accounts/:id/follow and unfollow to return relationship
Track relationship in redux state. Display follow/unfollow and following-back information on account view (unstyled)
Diffstat (limited to 'app/controllers/api/accounts_controller.rb')
-rw-r--r-- | app/controllers/api/accounts_controller.rb | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/app/controllers/api/accounts_controller.rb b/app/controllers/api/accounts_controller.rb index ccbbc93ff..490c28e75 100644 --- a/app/controllers/api/accounts_controller.rb +++ b/app/controllers/api/accounts_controller.rb @@ -1,6 +1,6 @@ class Api::AccountsController < ApiController - before_action :set_account before_action :doorkeeper_authorize! + before_action :set_account respond_to :json def show @@ -20,12 +20,14 @@ class Api::AccountsController < ApiController def follow @follow = FollowService.new.(current_user.account, @account.acct) - render action: :show + set_relationship + render action: :relationship end def unfollow @unfollow = UnfollowService.new.(current_user.account, @account) - render action: :show + set_relationship + render action: :relationship end def relationships @@ -41,4 +43,10 @@ class Api::AccountsController < ApiController def set_account @account = Account.find(params[:id]) end + + def set_relationship + @following = Account.following_map([@account.id], current_user.account_id) + @followed_by = Account.followed_by_map([@account.id], current_user.account_id) + @blocking = {} + end end |