Class: CommandTower::Services::Audit::Events::Show
- Inherits:
-
CommandTower::Services::ApplicationService
- Object
- CommandTower::ServiceBase
- CommandTower::Services::ApplicationService
- CommandTower::Services::Audit::Events::Show
- Defined in:
- app/services/command_tower/services/audit/events.rb
Constant Summary collapse
- VIEWER_SCOPES =
%i[user admin].freeze
Constants inherited from CommandTower::ServiceBase
CommandTower::ServiceBase::ON_ARGUMENT_VALIDATION
Instance Method Summary collapse
Methods inherited from CommandTower::Services::ApplicationService
Methods included from Transactional
#fail_transaction!, #transaction
Methods inherited from CommandTower::ServiceBase
#command_tower_lifecycle, inherited, #internal_validate, #service_lifecycle_error_codes, #service_lifecycle_log_level, #validate!
Methods included from Logging::LifecycleDeclaration
Methods included from Execution::ContextAccess
#audit, #execution_context, #log_debug, #log_error, #log_info, #log_warn, #publish_event
Methods included from ArgumentValidation
Methods included from CommandTower::ServiceLogging
Instance Method Details
#call ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'app/services/command_tower/services/audit/events.rb', line 94 def call if viewer_scope == :user && affected_user_id.nil? return context.fail!(application_error: CommandTower::Errors::InternalError.new) end relation = CommandTower::Audit::Event.where(id:) if viewer_scope == :user relation = relation.where(affected_user_id:, user_history: true) elsif scope_context.present? relation = CommandTower::AdminScope::ApplyAuditScoping.call( relation:, scope_context:, principal: principal || scope_context_principal ) end event = relation.first if event.nil? return context.fail!(application_error: CommandTower::Errors::NotFoundError.new) end context.event = event end |