Commiting
This commit is contained in:
@@ -19,21 +19,18 @@ class Api::V1::Groups::AccountsController < Api::BaseController
|
||||
def create
|
||||
authorize @group, :join?
|
||||
|
||||
if !@group.password.nil?
|
||||
if @group.has_password?
|
||||
# use the groups/password_controller to join group with password
|
||||
render json: { error: true, message: 'Unable to join group. Incorrect password.' }, status: 422
|
||||
end
|
||||
|
||||
if @group.is_private
|
||||
@group.join_requests << current_account
|
||||
else
|
||||
@group.accounts << current_account
|
||||
|
||||
if current_user.allows_group_in_home_feed?
|
||||
current_user.force_regeneration!
|
||||
if @group.is_private
|
||||
@group.join_requests << current_account
|
||||
else
|
||||
@group.accounts << current_account
|
||||
end
|
||||
end
|
||||
|
||||
render json: @group, serializer: REST::GroupRelationshipSerializer, relationships: relationships
|
||||
render json: @group, serializer: REST::GroupRelationshipSerializer, relationships: relationships
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@@ -41,7 +38,7 @@ class Api::V1::Groups::AccountsController < Api::BaseController
|
||||
|
||||
@account = @group.accounts.find(params[:account_id])
|
||||
GroupAccount.where(group: @group, account: @account).update(group_account_params)
|
||||
render_empty
|
||||
render_empty_success
|
||||
end
|
||||
|
||||
def destroy
|
||||
@@ -51,9 +48,6 @@ class Api::V1::Groups::AccountsController < Api::BaseController
|
||||
else
|
||||
authorize @group, :leave?
|
||||
GroupAccount.where(group: @group, account_id: current_account.id).destroy_all
|
||||
if current_user.allows_group_in_home_feed?
|
||||
current_user.force_regeneration!
|
||||
end
|
||||
end
|
||||
|
||||
render json: @group, serializer: REST::GroupRelationshipSerializer, relationships: relationships
|
||||
|
||||
@@ -10,25 +10,29 @@ class Api::V1::Groups::PinsController < Api::BaseController
|
||||
|
||||
def create
|
||||
authorize @group, :update?
|
||||
|
||||
GroupPinnedStatus.create!(group: @group, status: @status)
|
||||
render json: @status, serializer: REST::StatusSerializer
|
||||
|
||||
pin = GroupPinnedStatus.find_by(group: @group, status: @status)
|
||||
if pin.nil?
|
||||
GroupPinnedStatus.create!(group: @group, status: @status)
|
||||
render json: @status, serializer: REST::StatusGroupPinnedSerializer, group_id: @group.id
|
||||
else
|
||||
return render json: { error: 'Status is already pinned to group' }, status: 500
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
# is status pinned by user of group?
|
||||
render json: @status, serializer: REST::StatusGroupPinnedSerializer, group_id: @group.id
|
||||
end
|
||||
|
||||
def destroy
|
||||
authorize @group, :update?
|
||||
|
||||
pin = GroupPinnedStatus.find_by(group: @group, status: @status)
|
||||
|
||||
if pin
|
||||
pin.destroy!
|
||||
end
|
||||
|
||||
render json: @status, serializer: REST::StatusSerializer
|
||||
render json: @status, serializer: REST::StatusGroupPinnedSerializer, group_id: @group.id
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -23,7 +23,7 @@ class Api::V1::Groups::RemovedAccountsController < Api::BaseController
|
||||
@account = @group.accounts.find(params[:account_id])
|
||||
@group.removed_accounts << @account
|
||||
GroupAccount.where(group: @group, account: @account).destroy_all
|
||||
render_empty
|
||||
render_empty_success
|
||||
end
|
||||
|
||||
def destroy
|
||||
@@ -31,7 +31,7 @@ class Api::V1::Groups::RemovedAccountsController < Api::BaseController
|
||||
|
||||
@account = @group.removed_accounts.find(params[:account_id])
|
||||
GroupRemovedAccount.where(group: @group, account: @account).destroy_all
|
||||
render_empty
|
||||
render_empty_success
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
Reference in New Issue
Block a user