diff --git a/app/policies/group_policy.rb b/app/policies/group_policy.rb index 2b629dae..f7ba956f 100644 --- a/app/policies/group_policy.rb +++ b/app/policies/group_policy.rb @@ -24,6 +24,7 @@ class GroupPolicy < ApplicationPolicy def join? check_archive! raise GabSocial::ValidationError, "User is already a member of this group." if is_member? + raise GabSocial::ValidationError, "Account is removed from this group." if is_removed? return true end @@ -56,6 +57,10 @@ class GroupPolicy < ApplicationPolicy private + def is_removed? + record.group_removed_accounts.where(account_id: current_account.id).exists? + end + def is_member? record.group_accounts.where(account_id: current_account.id).exists? end