2020-05-06 12:09:36 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Mutations
|
|
|
|
module AlertManagement
|
|
|
|
class UpdateAlertStatus < Base
|
|
|
|
graphql_name 'UpdateAlertStatus'
|
|
|
|
|
|
|
|
argument :status, Types::AlertManagement::StatusEnum,
|
|
|
|
required: true,
|
|
|
|
description: 'The status to set the alert'
|
|
|
|
|
|
|
|
def resolve(args)
|
|
|
|
alert = authorized_find!(project_path: args[:project_path], iid: args[:iid])
|
|
|
|
result = update_status(alert, args[:status])
|
|
|
|
|
|
|
|
prepare_response(result)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def update_status(alert, status)
|
2020-05-12 12:09:47 +00:00
|
|
|
::AlertManagement::UpdateAlertStatusService
|
|
|
|
.new(alert, current_user, status)
|
|
|
|
.execute
|
2020-05-06 12:09:36 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def prepare_response(result)
|
|
|
|
{
|
|
|
|
alert: result.payload[:alert],
|
2020-06-09 00:08:47 +00:00
|
|
|
errors: result.errors
|
2020-05-06 12:09:36 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|