|
|
@ -1,8 +1,8 @@
|
|
|
|
# frozen_string_literal: true
|
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
|
|
|
|
class Api::V1::AccountsController < ApiController
|
|
|
|
class Api::V1::AccountsController < ApiController
|
|
|
|
before_action -> { doorkeeper_authorize! :read }, except: [:follow, :unfollow, :block, :unblock]
|
|
|
|
before_action -> { doorkeeper_authorize! :read }, except: [:follow, :unfollow, :block, :unblock, :mute, :unmute]
|
|
|
|
before_action -> { doorkeeper_authorize! :follow }, only: [:follow, :unfollow, :block, :unblock]
|
|
|
|
before_action -> { doorkeeper_authorize! :follow }, only: [:follow, :unfollow, :block, :unblock, :mute, :unmute]
|
|
|
|
before_action :require_user!, except: [:show, :following, :followers, :statuses]
|
|
|
|
before_action :require_user!, except: [:show, :following, :followers, :statuses]
|
|
|
|
before_action :set_account, except: [:verify_credentials, :suggestions, :search]
|
|
|
|
before_action :set_account, except: [:verify_credentials, :suggestions, :search]
|
|
|
|
|
|
|
|
|
|
|
@ -86,10 +86,17 @@ class Api::V1::AccountsController < ApiController
|
|
|
|
@followed_by = { @account.id => false }
|
|
|
|
@followed_by = { @account.id => false }
|
|
|
|
@blocking = { @account.id => true }
|
|
|
|
@blocking = { @account.id => true }
|
|
|
|
@requested = { @account.id => false }
|
|
|
|
@requested = { @account.id => false }
|
|
|
|
|
|
|
|
@muting = { @account.id => current_user.account.muting?(@account.id) }
|
|
|
|
|
|
|
|
|
|
|
|
render action: :relationship
|
|
|
|
render action: :relationship
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def mute
|
|
|
|
|
|
|
|
MuteService.new.call(current_user.account, @account)
|
|
|
|
|
|
|
|
set_relationship
|
|
|
|
|
|
|
|
render action: :relationship
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def unfollow
|
|
|
|
def unfollow
|
|
|
|
UnfollowService.new.call(current_user.account, @account)
|
|
|
|
UnfollowService.new.call(current_user.account, @account)
|
|
|
|
set_relationship
|
|
|
|
set_relationship
|
|
|
@ -102,6 +109,12 @@ class Api::V1::AccountsController < ApiController
|
|
|
|
render action: :relationship
|
|
|
|
render action: :relationship
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def unmute
|
|
|
|
|
|
|
|
UnmuteService.new.call(current_user.account, @account)
|
|
|
|
|
|
|
|
set_relationship
|
|
|
|
|
|
|
|
render action: :relationship
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def relationships
|
|
|
|
def relationships
|
|
|
|
ids = params[:id].is_a?(Enumerable) ? params[:id].map(&:to_i) : [params[:id].to_i]
|
|
|
|
ids = params[:id].is_a?(Enumerable) ? params[:id].map(&:to_i) : [params[:id].to_i]
|
|
|
|
|
|
|
|
|
|
|
@ -109,6 +122,7 @@ class Api::V1::AccountsController < ApiController
|
|
|
|
@following = Account.following_map(ids, current_user.account_id)
|
|
|
|
@following = Account.following_map(ids, current_user.account_id)
|
|
|
|
@followed_by = Account.followed_by_map(ids, current_user.account_id)
|
|
|
|
@followed_by = Account.followed_by_map(ids, current_user.account_id)
|
|
|
|
@blocking = Account.blocking_map(ids, current_user.account_id)
|
|
|
|
@blocking = Account.blocking_map(ids, current_user.account_id)
|
|
|
|
|
|
|
|
@muting = Account.muting_map(ids, current_user.account_id)
|
|
|
|
@requested = Account.requested_map(ids, current_user.account_id)
|
|
|
|
@requested = Account.requested_map(ids, current_user.account_id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
@ -130,6 +144,7 @@ class Api::V1::AccountsController < ApiController
|
|
|
|
@following = Account.following_map([@account.id], current_user.account_id)
|
|
|
|
@following = Account.following_map([@account.id], current_user.account_id)
|
|
|
|
@followed_by = Account.followed_by_map([@account.id], current_user.account_id)
|
|
|
|
@followed_by = Account.followed_by_map([@account.id], current_user.account_id)
|
|
|
|
@blocking = Account.blocking_map([@account.id], current_user.account_id)
|
|
|
|
@blocking = Account.blocking_map([@account.id], current_user.account_id)
|
|
|
|
|
|
|
|
@muting = Account.muting_map([@account.id], current_user.account_id)
|
|
|
|
@requested = Account.requested_map([@account.id], current_user.account_id)
|
|
|
|
@requested = Account.requested_map([@account.id], current_user.account_id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|