Class: ServiceDesk::CustomEmailVerifications::UpdateService

Inherits:
BaseService show all
Defined in:
app/services/service_desk/custom_email_verifications/update_service.rb

Constant Summary collapse

EMAIL_TOKEN_REGEXP =
/Verification token: ([A-Za-z0-9_-]{12})/

Instance Attribute Summary

Attributes inherited from BaseService

#settings

Attributes inherited from BaseProjectService

#project

Attributes inherited from BaseContainerService

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

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

Methods inherited from BaseProjectService

#initialize

Methods inherited from BaseContainerService

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

Methods included from BaseServiceUtility

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

Methods included from Gitlab::Allowable

#can?

Constructor Details

This class inherits a constructor from ServiceDesk::CustomEmailVerifications::BaseService

Instance Method Details

#executeObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/services/service_desk/custom_email_verifications/update_service.rb', line 8

def execute
  return error_feature_flag_disabled unless Feature.enabled?(:service_desk_custom_email, project)
  return error_parameter_missing if settings.blank? || verification.blank?
  return error_already_finished if already_finished_and_no_mail?
  return error_already_failed if already_failed_and_no_mail?

  verification_error = verify

  settings.update!(custom_email_enabled: false) if settings.custom_email_enabled?

  notify_project_owners_and_user_about_result(user: verification.triggerer)

  if verification_error.present?
    verification.mark_as_failed!(verification_error)

    error_not_verified(verification_error)
  else
    verification.mark_as_finished!

    log_info
    ServiceResponse.success
  end
end