Class: AlertManagement::Alerts::UpdateService

Inherits:
BaseProjectService show all
Includes:
Gitlab::Utils::StrongMemoize
Defined in:
app/services/alert_management/alerts/update_service.rb

Instance Attribute Summary

Attributes inherited from BaseProjectService

#project

Attributes inherited from BaseContainerService

#container, #current_user, #group, #params, #project

Instance Method Summary collapse

Methods inherited from BaseContainerService

#group_container?, #namespace_container?, #project_container?, #project_group

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #visibility_level

Methods included from Gitlab::Allowable

#can?

Constructor Details

#initialize(alert, current_user, params) ⇒ UpdateService

Returns a new instance of UpdateService.

Parameters:



11
12
13
14
15
16
17
# File 'app/services/alert_management/alerts/update_service.rb', line 11

def initialize(alert, current_user, params)
  @alert = alert
  @param_errors = []
  @status = params.delete(:status)

  super(project: alert.project, current_user: current_user, params: params)
end

Instance Method Details

#executeObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/services/alert_management/alerts/update_service.rb', line 19

def execute
  return error_no_permissions unless allowed?

  filter_params
  return error_invalid_params if param_errors.any?

  # Save old assignees for system notes
  old_assignees = alert.assignees.to_a

  if alert.update(params)
    handle_changes(old_assignees: old_assignees)

    success
  else
    error(alert.errors.full_messages.to_sentence)
  end
end