# frozen_string_literal: trueclassChatNotificationWorkerincludeApplicationWorkerRESCHEDULE_INTERVAL=2.seconds# rubocop: disable CodeReuse/ActiveRecorddefperform(build_id)Ci::Build.find_by(id: build_id).trydo|build|send_response(build)endrescueGitlab::Chat::Output::MissingBuildSectionError# The creation of traces and sections appears to be eventually consistent.# As a result it's possible for us to run the above code before the trace# sections are present. To better handle such cases we'll just reschedule# the job instead of producing an error.self.class.perform_in(RESCHEDULE_INTERVAL,build_id)end# rubocop: enable CodeReuse/ActiveRecorddefsend_response(build)Gitlab::Chat::Responder.responder_for(build).trydo|responder|ifbuild.success?output=Gitlab::Chat::Output.new(build)responder.success(output.to_s)elseresponder.failureendendendend