Class: DeliveryUncle::EmailRequestsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/delivery_uncle/email_requests_controller.rb

Constant Summary

Constants inherited from ApplicationController

ApplicationController::MAILERS

Instance Method Summary collapse

Instance Method Details

#blockObject



57
58
59
60
61
62
# File 'app/controllers/delivery_uncle/email_requests_controller.rb', line 57

def block
  mailer ? 
    act_on_mailer(:block_mailer, mailer) :
    error_mailer_not_found
  redirect_to action: :configure
end

#configureObject



52
53
54
55
# File 'app/controllers/delivery_uncle/email_requests_controller.rb', line 52

def configure
  @mailers = union_of_mailers - Activity.blocked_mailers
  @blocked_mailers = Activity.blocked_mailers
end

#indexObject



6
7
8
9
10
11
12
# File 'app/controllers/delivery_uncle/email_requests_controller.rb', line 6

def index
  requests = EmailRequest.order_by_latest
  pagination = paginate.page(requests, params)
 
  @requests = pagination.data
  @pagination = pagination
end

#pauseObject



18
19
20
21
# File 'app/controllers/delivery_uncle/email_requests_controller.rb', line 18

def pause
  EmailQueue.pause(email_request) if email_request.present?
  redirect_to email_requests_url
end

#pause_allObject



23
24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/delivery_uncle/email_requests_controller.rb', line 23

def pause_all
  if email_request.present?
    EmailRequest.
      not_sent.
      with_mailer_method(email_request.mailer, email_request.mailer_method).
      each do |entry|
        EmailQueue.pause(entry)
      end
  end
  redirect_to email_requests_url
end

#retryObject



35
36
37
38
# File 'app/controllers/delivery_uncle/email_requests_controller.rb', line 35

def retry
  EmailQueue.retry(email_request) if email_request.present?
  redirect_to email_requests_url
end

#retry_allObject



40
41
42
43
44
45
46
47
48
49
50
# File 'app/controllers/delivery_uncle/email_requests_controller.rb', line 40

def retry_all
  if email_request.present?
    EmailRequest.
      not_sent.
      with_mailer_method(email_request.mailer, email_request.mailer_method).
      each do |entry|
        EmailQueue.retry(entry)
      end
  end
  redirect_to email_requests_url
end

#showObject



14
15
16
# File 'app/controllers/delivery_uncle/email_requests_controller.rb', line 14

def show
  @request = email_request 
end

#unblockObject



64
65
66
67
68
69
# File 'app/controllers/delivery_uncle/email_requests_controller.rb', line 64

def unblock
  mailer ? 
    act_on_mailer(:unblock_mailer, mailer) : 
    error_mailer_not_found
  redirect_to action: :configure
end