Class: CommandTower::Messaging::Execution::RevalidateReadiness
- Inherits:
-
Object
- Object
- CommandTower::Messaging::Execution::RevalidateReadiness
- Defined in:
- app/services/command_tower/messaging/execution/revalidate_readiness.rb
Overview
Execution-time RecipientReadiness revalidation (TOCTOU protection).
Class Method Summary collapse
Instance Method Summary collapse
-
#call ⇒ Object
Returns ChannelResult on success, or a String error_code on terminal readiness failure.
-
#initialize(delivery:, attempt:, communication:) ⇒ RevalidateReadiness
constructor
A new instance of RevalidateReadiness.
Constructor Details
#initialize(delivery:, attempt:, communication:) ⇒ RevalidateReadiness
Returns a new instance of RevalidateReadiness.
12 13 14 15 16 |
# File 'app/services/command_tower/messaging/execution/revalidate_readiness.rb', line 12 def initialize(delivery:, attempt:, communication:) @delivery = delivery @attempt = attempt @communication = communication end |
Class Method Details
.call(delivery:, attempt:, communication:) ⇒ Object
8 9 10 |
# File 'app/services/command_tower/messaging/execution/revalidate_readiness.rb', line 8 def self.call(delivery:, attempt:, communication:) new(delivery:, attempt:, communication:).call end |
Instance Method Details
#call ⇒ Object
Returns ChannelResult on success, or a String error_code on terminal readiness failure.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'app/services/command_tower/messaging/execution/revalidate_readiness.rb', line 19 def call platform_enabled_channels = platform_enabled_channels_for(@communication) begin result = RecipientReadiness.for_channel( recipient_id: @communication.user_id, channel_key: @delivery.channel_key, platform_enabled_channels:, ) rescue RecipientReadiness::RecipientNotFoundError OperationLogger.readiness_failed( channel_delivery: @delivery, delivery_attempt: @attempt, error_code: "recipient_missing", reason_codes: [RecipientReadiness::ReasonCodes::IDENTITY_UNAVAILABLE], ) return "recipient_missing" rescue RecipientReadiness::UnknownChannelError OperationLogger.readiness_failed( channel_delivery: @delivery, delivery_attempt: @attempt, error_code: "adapter_unconfigured", reason_codes: [RecipientReadiness::ReasonCodes::PLATFORM_UNCONFIGURED], ) return "adapter_unconfigured" end OperationLogger.readiness_revalidated( channel_delivery: @delivery, delivery_attempt: @attempt, ready: result.ready, ) return result if result.ready error_code = ReadinessTerminalMapping.error_code_for(result.reason_codes) OperationLogger.readiness_failed( channel_delivery: @delivery, delivery_attempt: @attempt, error_code:, reason_codes: result.reason_codes, ) error_code end |