From 34bb86f91219bb1ce76337bbd465c542a5afa47b Mon Sep 17 00:00:00 2001 From: luciajanikova <19lucia99@gmail.com> Date: Thu, 14 Nov 2024 12:05:15 +0100 Subject: [PATCH 1/3] Do not inform user about message_draft diff in validations --- app/jobs/fs/validate_message_draft_result_job.rb | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/jobs/fs/validate_message_draft_result_job.rb b/app/jobs/fs/validate_message_draft_result_job.rb index ce0ebea2..4a0e46f5 100644 --- a/app/jobs/fs/validate_message_draft_result_job.rb +++ b/app/jobs/fs/validate_message_draft_result_job.rb @@ -14,11 +14,21 @@ def perform(message_draft, location_header, fs_client: FsEnvironment.fs_client) message_draft.metadata[:validation_errors] = { result: response[:body]['result'], errors: response[:body]['problems']&.select { |problem| problem['level'] == 'error' }&.map{ |problem| problem['message'] }, - warnings: response[:body]['problems']&.select { |problem| problem['level'] == 'warning' }&.map{ |problem| problem['message'] } + warnings: response[:body]['problems']&.select { |problem| problem['level'] == 'warning' }&.map{ |problem| problem['message'] }, } - message_draft.add_cascading_tag(message_draft.tenant.submission_error_tag) + + diff = response[:body]['problems']&.select { |problem| problem['level'] == 'diff' } + log("Message draft DIFF: #{diff.map{ |problem| problem['message']}.join(', ')}") if diff.any? + + message_draft.add_cascading_tag(message_draft.tenant.submission_error_tag) if message_draft.metadata[:validation_errors][:errors].any? || message_draft.metadata[:validation_errors][:warnings].any? end message_draft.save end + + private + + def log(message) + Rails.logger.info(message) + end end From 40e829dfce7fc25f30888da59120fb5e30a2f789 Mon Sep 17 00:00:00 2001 From: luciajanikova <19lucia99@gmail.com> Date: Thu, 14 Nov 2024 12:12:47 +0100 Subject: [PATCH 2/3] Add new line --- app/jobs/fs/validate_message_draft_result_job.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/jobs/fs/validate_message_draft_result_job.rb b/app/jobs/fs/validate_message_draft_result_job.rb index 4a0e46f5..44cf6048 100644 --- a/app/jobs/fs/validate_message_draft_result_job.rb +++ b/app/jobs/fs/validate_message_draft_result_job.rb @@ -25,7 +25,7 @@ def perform(message_draft, location_header, fs_client: FsEnvironment.fs_client) message_draft.save end - + private def log(message) From 5868114353ab69302bf088d4c1d7ef34fbf2ee17 Mon Sep 17 00:00:00 2001 From: luciajanikova <19lucia99@gmail.com> Date: Thu, 14 Nov 2024 12:16:58 +0100 Subject: [PATCH 3/3] Update syntax --- app/jobs/fs/validate_message_draft_result_job.rb | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/app/jobs/fs/validate_message_draft_result_job.rb b/app/jobs/fs/validate_message_draft_result_job.rb index 44cf6048..bfdfb3bc 100644 --- a/app/jobs/fs/validate_message_draft_result_job.rb +++ b/app/jobs/fs/validate_message_draft_result_job.rb @@ -18,17 +18,11 @@ def perform(message_draft, location_header, fs_client: FsEnvironment.fs_client) } diff = response[:body]['problems']&.select { |problem| problem['level'] == 'diff' } - log("Message draft DIFF: #{diff.map{ |problem| problem['message']}.join(', ')}") if diff.any? + Rails.logger.info("Message draft DIFF: #{diff.map{ |problem| problem['message']}.join(', ')}") if diff.any? message_draft.add_cascading_tag(message_draft.tenant.submission_error_tag) if message_draft.metadata[:validation_errors][:errors].any? || message_draft.metadata[:validation_errors][:warnings].any? end message_draft.save end - - private - - def log(message) - Rails.logger.info(message) - end end