diff options
| author | Teddy Wing | 2014-06-08 12:41:16 -0400 |
|---|---|---|
| committer | Teddy Wing | 2014-06-08 12:41:16 -0400 |
| commit | dbdf6a3486a3456b6a6d4fc4f2c5973113015109 (patch) | |
| tree | 549c0ad3957527a49b6eac2928f3e350f35436d4 | |
| parent | d9fb8accb78af12c544c81cb13ea35bbbebf0bac (diff) | |
| download | sellevate-dbdf6a3486a3456b6a6d4fc4f2c5973113015109.tar.bz2 | |
JSON API for individual messages
| -rw-r--r-- | app.rb | 5 | ||||
| -rw-r--r-- | fancy_bear/contextio/message.rb | 17 |
2 files changed, 21 insertions, 1 deletions
@@ -42,4 +42,9 @@ class App < Sinatra::Base contextio = FancyBear::ContextIO::Message.new('sellevate.hack@gmail.com') json contextio.all end + + get '/messages/:id.json' do + contextio = FancyBear::ContextIO::Message.new('sellevate.hack@gmail.com') + json contextio.get(params[:id]) + end end diff --git a/fancy_bear/contextio/message.rb b/fancy_bear/contextio/message.rb index bae9be4..abf4a09 100644 --- a/fancy_bear/contextio/message.rb +++ b/fancy_bear/contextio/message.rb @@ -25,8 +25,23 @@ module FancyBear messages end - def get + def get(id) + output = {} + message = @account.messages.where(:message_id => id).first + output['from_address'] = message.from['email'] + output['from_name'] = message.from['name'] + output['subject'] = message.subject + output['timestamp'] = message.date + output['labels'] = message.folders + + message.body_parts.each do |p| + if p.content + output['html'] = p.html? + output['content'] = p.content + end + end + output end end |
