Skip to content

Commit

Permalink
Do not inform user about message_draft diff in validations
Browse files Browse the repository at this point in the history
  • Loading branch information
luciajanikova committed Nov 14, 2024
1 parent 8a5e659 commit 34bb86f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions app/jobs/fs/validate_message_draft_result_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 34bb86f

Please sign in to comment.