Mute button progress so far. WIP, doesn't entirely work correctly.
This commit is contained in:
parent
89fc2d7f48
commit
442fdbfc53
26 changed files with 390 additions and 33 deletions
|
@ -1,8 +1,8 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Api::V1::AccountsController < ApiController
|
||||
before_action -> { doorkeeper_authorize! :read }, except: [:follow, :unfollow, :block, :unblock]
|
||||
before_action -> { doorkeeper_authorize! :follow }, only: [: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, :mute, :unmute]
|
||||
before_action :require_user!, except: [:show, :following, :followers, :statuses]
|
||||
before_action :set_account, except: [:verify_credentials, :suggestions, :search]
|
||||
|
||||
|
@ -86,10 +86,17 @@ class Api::V1::AccountsController < ApiController
|
|||
@followed_by = { @account.id => false }
|
||||
@blocking = { @account.id => true }
|
||||
@requested = { @account.id => false }
|
||||
@muting = { @account.id => current_user.account.muting?(@account.id) }
|
||||
|
||||
render action: :relationship
|
||||
end
|
||||
|
||||
def mute
|
||||
MuteService.new.call(current_user.account, @account)
|
||||
set_relationship
|
||||
render action: :relationship
|
||||
end
|
||||
|
||||
def unfollow
|
||||
UnfollowService.new.call(current_user.account, @account)
|
||||
set_relationship
|
||||
|
@ -102,6 +109,12 @@ class Api::V1::AccountsController < ApiController
|
|||
render action: :relationship
|
||||
end
|
||||
|
||||
def unmute
|
||||
UnmuteService.new.call(current_user.account, @account)
|
||||
set_relationship
|
||||
render action: :relationship
|
||||
end
|
||||
|
||||
def relationships
|
||||
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)
|
||||
@followed_by = Account.followed_by_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)
|
||||
end
|
||||
|
||||
|
@ -130,6 +144,7 @@ class Api::V1::AccountsController < ApiController
|
|||
@following = Account.following_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)
|
||||
@muting = Account.muting_map([@account.id], current_user.account_id)
|
||||
@requested = Account.requested_map([@account.id], current_user.account_id)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue