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] 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