Class: EmailsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
lib/generators/mastiff/views/templates/emails_controller.rb

Instance Method Summary collapse

Instance Method Details

#archiveObject

POST /admin/mastiff_email/archive



76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/generators/mastiff/views/templates/emails_controller.rb', line 76

def archive
  #TODO: figure out how to get DataTables to send a JSON array
  tableData = params["tableData"]
  tableData_a = tableData.split ","
  ids = Mastiff::Email.archive(tableData_a)

  respond_to do |format|
     format.json{
       render :json => ids
     }
  end
end

#handle_mailObject

POST /admin/mastiff_email/archive



90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/generators/mastiff/views/templates/emails_controller.rb', line 90

def handle_mail
  #TODO: figure out how to get DataTables to send a JSON array
  tableData = params["tableData"]
  tableData_a = tableData.split ","
  ids = Mastiff::Email.handle_mail(tableData_a)

  respond_to do |format|
     format.json{
       render :json => ids
     }
  end
end

#indexObject

GET /admin/mastiff_emails GET /admin/mastiff_emails.json



6
7
8
9
10
# File 'lib/generators/mastiff/views/templates/emails_controller.rb', line 6

def index
  respond_to do |format|
     format.html{}
  end
end

#listObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/generators/mastiff/views/templates/emails_controller.rb', line 11

def list
  @emails = Mastiff::Email.headers
  @emails.each{|m| m["DT_RowId"] = m[:id]}
  Rails.logger.info @emails.map{|m| "#{m[:id]}, #{m[:attachment_size]}"}
  render :json => {aaData: @emails}
  #    render :json => {aaData: @emails.map{|email| [
  #    email[:id],
  #    email[:date], email[:subject], email[:sender_email],
  #    email[:attachment_name], email[:attachment_size].to_s
  #]}}
end

#message_idsObject

render :json => @emails.map{|email| [

email[:id],
email[:date], email[:subject], email[:sender_email],
email[:attachment_name], email[:attachment_size].to_s

]}



22
23
24
25
26
27
28
29
# File 'lib/generators/mastiff/views/templates/emails_controller.rb', line 22

def message_ids
  respond_to do |format|
      format.json{
        @msg_ids = Mastiff::Email.msg_ids
        render :json => @msg_ids
      }
  end
end

#process_inboxObject



53
54
55
56
57
58
59
60
# File 'lib/generators/mastiff/views/templates/emails_controller.rb', line 53

def process_inbox
  message_ids = Mastiff::Email.process_inbox
  respond_to do |format|
     format.json{
       render :json => message_ids
     }
  end
end

#reloadObject

GETS masquerading as POSTS



37
38
39
40
41
42
43
44
# File 'lib/generators/mastiff/views/templates/emails_controller.rb', line 37

def reload
  message_ids = Mastiff::Email.sync_messages
  respond_to do |format|
     format.json{
       render :json => message_ids
     }
  end
end

#removeObject



63
64
65
66
67
68
69
70
71
72
73
# File 'lib/generators/mastiff/views/templates/emails_controller.rb', line 63

def remove
  #TODO: figure out how to get DataTables to send a JSON array
  tableData = params["tableData"]
  tableData_a = tableData.split ","
  ids = Mastiff::Email.remove(tableData_a)
  respond_to do |format|
     format.json{
       render :json => ids
     }
  end
end

#resetObject



45
46
47
48
49
50
51
52
# File 'lib/generators/mastiff/views/templates/emails_controller.rb', line 45

def reset
  message_ids = Mastiff::Email.sync_all
  respond_to do |format|
     format.json{
       render :json => message_ids
     }
  end
end