Class: CommandTower::Workflows::Messaging::Communications::ProduceRecipientWorkflow
- Inherits:
-
ApplicationWorkflow
- Object
- ApplicationWorkflow
- CommandTower::Workflows::Messaging::Communications::ProduceRecipientWorkflow
- Defined in:
- app/workflows/command_tower/workflows/messaging/communications/produce_recipient_workflow.rb
Overview
Thin job entry for async ProduceMany units. Reloads User by id then Produce.
Constant Summary
Constants inherited from ApplicationWorkflow
ApplicationWorkflow::ALLOWED_RETRY_STRATEGIES, ApplicationWorkflow::InvalidTransactionResult, ApplicationWorkflow::TransactionFailure
Instance Method Summary collapse
Methods inherited from ApplicationWorkflow
call, call_from_job, continuation_max_attempts, declared_retry_strategy, mark_impersonation_activity!, retry_strategy, validate_retry_strategy!
Methods included from Impersonation::ActivityDeclaration
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 Transactional
#fail_transaction!, #transaction
Instance Method Details
#call(user_id:, notification_type_key:, campaign_identity:, title:, body:, platform_enabled_channels:, metadata: nil) ⇒ Object
11 12 13 14 15 16 17 18 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 |
# File 'app/workflows/command_tower/workflows/messaging/communications/produce_recipient_workflow.rb', line 11 def call( user_id:, notification_type_key:, campaign_identity:, title:, body:, platform_enabled_channels:, metadata: nil ) user = User.find_by(id: user_id) unless user return failure( errors: [CommandTower::Errors::NotFoundError.new], http_status: :not_found, meta: { propagate_to_job: false } ) end result = CommandTower::Services::Messaging::Communications::Produce.call( user:, notification_type_key:, host_event_identity: "#{campaign_identity}/#{user.id}", title:, body:, metadata:, platform_enabled_channels:, ) unless result.success? return failure( errors: result.errors, http_status: CommandTower::Workflows::Messaging::ErrorMapping.http_status_for(result.errors.first), meta: { propagate_to_job: false } ) end success( payload: { "communicationId" => result.data[:communication_id], "inboxItemId" => result.data[:inbox_item_id], "userId" => user.id, }, http_status: :ok ) end |