Class: CommandTower::Messaging::Inbox::OperationLogger

Inherits:
Object
  • Object
show all
Defined in:
app/services/command_tower/messaging/inbox/operation_logger.rb

Constant Summary collapse

EVENT_BY_OPERATION =
{
  mark_viewed: "messaging.inbox.viewed",
  mark_unviewed: "messaging.inbox.unviewed",
  archive: "messaging.inbox.archived",
  restore: "messaging.inbox.restored",
  delete: "messaging.inbox.deleted",
}.freeze

Class Method Summary collapse

Class Method Details

.lifecycle_changed(operation:, item:, bulk: false) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/services/command_tower/messaging/inbox/operation_logger.rb', line 16

def lifecycle_changed(operation:, item:, bulk: false)
  event = EVENT_BY_OPERATION.fetch(operation)
  Contract::Observability::Publisher.info(
    event:,
    messaging_operation: "inbox",
    operation: operation.to_s,
    bulk:,
    correlation_id: Contract::Observability::Correlation.resolve,
    recipient_id: item.recipient_id,
    inbox_item_id: item.id,
    communication_id: item.communication_id,
    status: item.status,
    viewed_at: item.viewed_at&.utc&.iso8601(3),
    archived_at: item.archived_at&.utc&.iso8601(3),
    deleted_at: item.deleted_at&.utc&.iso8601(3),
  )
end