From d77189fc6d9e0a5dfe7ad416390dd8eabf6ce275 Mon Sep 17 00:00:00 2001 From: VladislavSokov Date: Wed, 6 Sep 2023 13:10:44 +0300 Subject: [PATCH] feat(public account share): fixup! fixup! fixup! fixup! fixup! fixup! add public account share --- app/controllers/accounts_controller.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index 0a94a26a..34f5bd5d 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -27,11 +27,18 @@ def create Set.new(AccountShare.accepted.for_public.pluck(:account_id)) end - helper_method memoize def public_share?(account) - public_shared_accounts.include?(account.id) + memoize def private_shared_accounts + Set.new(AccountShare.accepted.for(current_user).pluck(:account_id)) end helper_method memoize def account Account.visible_for(current_user).find(ps.fetch(:id)) end + + helper_method def public_share?(account) + return false if current_user.account.id == account.parent.id || + private_shared_accounts.include?(account.id) + + public_shared_accounts.include?(account.id) + end end