28 lines
512 B
Ruby
28 lines
512 B
Ruby
# typed: strict
|
|
class TelegramBotLogPolicy < ApplicationPolicy
|
|
extend T::Sig
|
|
|
|
sig { returns(T::Boolean) }
|
|
def index?
|
|
is_real_user? && is_role_admin?
|
|
end
|
|
|
|
sig { returns(T::Boolean) }
|
|
def show?
|
|
is_real_user? && is_role_admin?
|
|
end
|
|
|
|
class Scope < ApplicationPolicy::Scope
|
|
extend T::Sig
|
|
|
|
sig { returns(T.untyped) }
|
|
def resolve
|
|
if @user&.admin?
|
|
scope.all
|
|
else
|
|
scope.where(id: nil) # Returns empty relation for non-admin users
|
|
end
|
|
end
|
|
end
|
|
end
|