Class: EmailsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- EmailsController
- Defined in:
- lib/generators/mastiff/views/templates/emails_controller.rb
Instance Method Summary collapse
-
#archive ⇒ Object
POST /admin/mastiff_email/archive.
-
#handle_mail ⇒ Object
POST /admin/mastiff_email/archive.
-
#index ⇒ Object
GET /admin/mastiff_emails GET /admin/mastiff_emails.json.
- #list ⇒ Object
- #message_ids ⇒ Object
- #process_inbox ⇒ Object
-
#reload ⇒ Object
GETS masquerading as POSTS.
- #remove ⇒ Object
- #reset ⇒ Object
Instance Method Details
#archive ⇒ Object
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_mail ⇒ Object
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 |
#index ⇒ Object
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 |
#list ⇒ Object
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_ids ⇒ Object
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 respond_to do |format| format.json{ @msg_ids = Mastiff::Email.msg_ids render :json => @msg_ids } end end |
#process_inbox ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'lib/generators/mastiff/views/templates/emails_controller.rb', line 53 def process_inbox = Mastiff::Email.process_inbox respond_to do |format| format.json{ render :json => } end end |
#reload ⇒ Object
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 = Mastiff::Email. respond_to do |format| format.json{ render :json => } end end |
#remove ⇒ Object
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 |
#reset ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/generators/mastiff/views/templates/emails_controller.rb', line 45 def reset = Mastiff::Email.sync_all respond_to do |format| format.json{ render :json => } end end |