Class: CommandTower::Messaging::Communication

Inherits:
ApplicationRecord show all
Defined in:
app/models/command_tower/messaging/communication.rb

Constant Summary collapse

STATUS_ACCEPTED =
"accepted"
HANDOFF_PENDING =
"pending"
HANDOFF_ENQUEUED =
"enqueued"
HANDOFF_COMPLETE =
"complete"
HANDOFF_FAILED =
"failed"
HANDOFF_TERMINAL_STATUSES =
[HANDOFF_ENQUEUED, HANDOFF_COMPLETE].freeze
HANDOFF_RECOVERABLE_STATUSES =
[HANDOFF_PENDING, HANDOFF_FAILED].freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationRecord

attribute_to_type_mapping

Class Method Details

.find_by_idempotency_namespace(user_id:, notification_type_key:, host_event_identity:) ⇒ Object



43
44
45
46
47
48
49
# File 'app/models/command_tower/messaging/communication.rb', line 43

def self.find_by_idempotency_namespace(user_id:, notification_type_key:, host_event_identity:)
  find_by(
    user_id:,
    notification_type_key: notification_type_key.to_s,
    host_event_identity: host_event_identity.to_s,
  )
end

Instance Method Details

#handoff_recoverable?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'app/models/command_tower/messaging/communication.rb', line 55

def handoff_recoverable?
  HANDOFF_RECOVERABLE_STATUSES.include?(execution_handoff_status)
end

#handoff_terminal?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'app/models/command_tower/messaging/communication.rb', line 51

def handoff_terminal?
  HANDOFF_TERMINAL_STATUSES.include?(execution_handoff_status)
end