Skip to content

Commit

Permalink
Update automation to be able to add tag to thread after form object i…
Browse files Browse the repository at this point in the history
…s downloaded
  • Loading branch information
luciajanikova committed Nov 12, 2024
1 parent 7307fae commit 9de9135
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ def before_render
@trigger_events_list = [
[t('message_created'), 'message_created'],
[t('message_draft_submitted'), 'message_draft_submitted'],
[t('form_object_downloaded'), 'form_object_downloaded'],
]
end
end
5 changes: 5 additions & 0 deletions app/controllers/message_objects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ def show

def download
authorize @message_object

EventBus.publish(:form_object_downloaded, @message_object.message) if @message_object.form?

send_data @message_object.content, filename: MessageObjectHelper.displayable_name(@message_object), type: @message_object.mimetype, disposition: :download
end

Expand All @@ -34,6 +37,8 @@ def download_pdf

pdf_content = @message_object.prepare_pdf_visualization
if pdf_content
EventBus.publish(:form_object_downloaded, @message_object.message) if @message_object.form?

send_data pdf_content, filename: MessageObjectHelper.pdf_name(@message_object), type: 'application/pdf', disposition: :download
else
redirect_back fallback_location: message_thread_path(@message_object.message.thread), alert: "Obsah nie je možné stiahnuť."
Expand Down
2 changes: 1 addition & 1 deletion app/lib/event_bus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def self.reset!
# wiring

# automation
[:message_thread_created, :message_created, :message_draft_submitted].each do |event|
[:message_thread_created, :message_created, :message_draft_submitted, :form_object_downloaded].each do |event|
EventBus.subscribe_job event, Automation::ApplyRulesForEventJob
end

Expand Down
1 change: 1 addition & 0 deletions config/locales/sk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ sk:
message_updated: "Upravená správa"
message_thread_changed: "Zmena vo vlákne správ"
message_draft_submitted: "Odoslaná správa"
form_object_downloaded: "Stiahnutá správa"
"Automation::ContainsCondition": "obsahuje"
"Automation::AttachmentContentContainsCondition": "obsahuje"
"Automation::MetadataValueCondition": "v metadátach obsahuje"
Expand Down

0 comments on commit 9de9135

Please sign in to comment.