Class: ZendeskTools::CleanSuspended

Inherits:
Command
  • Object
show all
Includes:
Loggable
Defined in:
lib/zendesk-tools/clean_suspended.rb

Instance Method Summary collapse

Methods included from Loggable

#log, logger_for

Methods inherited from Command

run

Constructor Details

#initialize(*args) ⇒ CleanSuspended

Array with delete subjects. Defined in config file



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/zendesk-tools/clean_suspended.rb', line 8

def initialize(*args)
  super

  @delete_causes = ZendeskTools.config['delete_causes'] || [
    "Detected email as being from a system user",
    "Detected as mail loop",
    "Automated response mail"
  ]

  @delete_subjects = ZendeskTools.config['delete_subjects'] || [
    "Returned mail: see transcript",
    "Delivery Status Notification (Failure)",
    "Undeliverable:",
    "Kan ikke leveres:",
    "Automatisk svar"
  ]
end

Instance Method Details

#runObject



26
27
28
29
30
31
32
33
34
35
# File 'lib/zendesk-tools/clean_suspended.rb', line 26

def run
  @client.suspended_tickets.each do |suspended_ticket|
    if should_delete?(suspended_ticket)
      log.info "Deleting: #{suspended_ticket.subject}"
      suspended_ticket.destroy
    else
      log.info "Keeping: #{suspended_ticket.subject}"
    end
  end
end