From 3f9708edc4cd799afb68000adc35036dd8b8faa5 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Fri, 23 Sep 2016 20:23:26 +0200 Subject: 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) --- app/controllers/api/accounts_controller.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'app/controllers/api/accounts_controller.rb') 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 -- cgit