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/services/command_tower/messaging/accept/persister.rb', line 17
def call
communication = nil
ActiveRecord::Base.transaction do
communication = Messaging::Communication.create!(
user_id: @request.fetch(:recipient_id),
notification_type_key: @request.fetch(:notification_type_key).to_s,
host_event_identity: @request.fetch(:host_event_identity).to_s,
accept_request_fingerprint: @fingerprint,
status: Messaging::Communication::STATUS_ACCEPTED,
execution_handoff_status: Messaging::Communication::HANDOFF_PENDING,
title: @request.fetch(:title),
body: @request.fetch(:body),
metadata: freeze_metadata(@request[:metadata]),
)
Messaging::DestinationPlan.create!(
communication:,
decision: decision_payload(@plan),
)
if @plan.inbox_selected
Messaging::InboxItem.create!(
communication:,
status: Messaging::InboxItem::STATUS_CREATED,
)
end
@plan.selected_channels.each do |channel_key|
Messaging::ChannelDelivery.create!(
communication:,
channel_key: channel_key.to_s,
status: Messaging::ChannelDelivery::STATUS_PLANNED,
)
end
end
reload_aggregate(communication.id)
end
|