Class: EgovUtils::RegistrationRequests::CheckAutoAccept

Inherits:
ActiveInteraction::Base
  • Object
show all
Defined in:
app/services/egov_utils/registration_requests/check_auto_accept.rb

Instance Method Summary collapse

Instance Method Details

#executeObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/services/egov_utils/registration_requests/check_auto_accept.rb', line 6

def execute
  member = nil
  EgovUtils::Group.where.not(provider: nil).detect do |g|
    member = g.ldap_members.detect do |m|
      m[:login] == registration_request.mail
    end
  end

  return unless member

  registration_request.update(
    status: 'accepted',
    internal_reason:
      'Automaticky schválen na základě členství v LDAP skupině'
  )

  EgovUtils::RegistrationRequestMailer
    .auto_accepted(registration_request.id)
    .deliver_now

  registration_request
end