diff --git a/app/components/settings/rules/rule_header_form_component.rb b/app/components/settings/rules/rule_header_form_component.rb index 6a56cdf9..db40add0 100644 --- a/app/components/settings/rules/rule_header_form_component.rb +++ b/app/components/settings/rules/rule_header_form_component.rb @@ -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 diff --git a/app/controllers/message_objects_controller.rb b/app/controllers/message_objects_controller.rb index 8e5d56e7..fd78aa9b 100644 --- a/app/controllers/message_objects_controller.rb +++ b/app/controllers/message_objects_controller.rb @@ -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 @@ -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ť." diff --git a/app/lib/event_bus.rb b/app/lib/event_bus.rb index 1d2bcecc..c5e52632 100644 --- a/app/lib/event_bus.rb +++ b/app/lib/event_bus.rb @@ -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 diff --git a/config/locales/sk.yml b/config/locales/sk.yml index 2f5ecb77..8e859638 100644 --- a/config/locales/sk.yml +++ b/config/locales/sk.yml @@ -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"