app/web_panel.rb in ses-proxy-0.3.1 vs app/web_panel.rb in ses-proxy-0.3.2
- old
+ new
@@ -1,9 +1,10 @@
require 'sinatra'
require 'haml'
require 'kaminari/sinatra'
require 'json'
+require 'aws-sdk'
helpers do
def protected!
unless authorized?
response['WWW-Authenticate'] = %(Basic realm="Restricted Area")
@@ -42,11 +43,11 @@
@chart_url = "/mails.json"
@page_title = "Sent Emails"
@per = params[:per] || 20
mails = mails_query
@mails = mails.page(params[:page]).per(@per)
- haml :mails
+ haml :mails, :layout => "layout"
end
get '/mails.json' do
protected!
mails = mails_query
@@ -75,11 +76,11 @@
@chart_url = "/bounced_mails.json"
@page_title = "Bounced Emails"
@per = params[:per] || 20
mails = bounced_mails_query
@mails = mails.page(params[:page]).per(@per)
- haml :mails
+ haml :mails, :layout => "layout"
end
get '/bounced_mails.json' do
protected!
mails = bounced_mails_query
@@ -109,11 +110,11 @@
@menu_item = "bounces"
@chart_url = "/bounces.json"
@per = params[:per] || 20
bounces = bounces_query
@bounces = bounces.page(params[:page]).per(@per)
- haml :bounces
+ haml :bounces, :layout => "layout"
end
get '/bounces.json' do
protected!
bounces = bounces_query
@@ -145,10 +146,17 @@
content_type :json
data.to_json
end
+get "/refresh_senders" do
+ protected!
+ ses = ::AWS::SimpleEmailService.new(SesProxy::Conf.get[:aws])
+ SesProxy::VerifiedSender.update_identities(ses.client)
+ 204
+end
+
private
def get_key_format(d_array)
if d_array.size <= 30
#days
@@ -173,11 +181,11 @@
@e = params[:e]||Date.today.strftime("%d-%m-%Y")
if @q.nil? or @q.eql?""
if valid_date(@s) and valid_date(@e)
mails = SesProxy::Email.where(:created_at=>{'$gte' => string_to_date(@s),'$lte' => string_to_date(@e)+1.day})
else
- mails = SesProxy::Email.all
+ mails = SesProxy::Email
end
else
if valid_date(@s) and valid_date(@e)
mails = SesProxy::Email.where(:created_at=>{'$gte' => string_to_date(@s),'$lte' => string_to_date(@e)+1.day}).any_of({:recipients => /.*#{@q}.*/i },{:sender => /.*#{@q}.*/i },{:system => /.*#{@q}.*/i },{:subject => /.*#{@q}.*/i })
else
@@ -192,11 +200,11 @@
@e = params[:e]||Date.today.strftime("%d-%m-%Y")
if @q.nil? or @q.eql?""
if valid_date(@s) and valid_date(@e)
mails = SesProxy::BouncedEmail.where(:created_at=>{'$gte' => string_to_date(@s),'$lte' => string_to_date(@e)+1.day})
else
- mails = SesProxy::BouncedEmail.all
+ mails = SesProxy::BouncedEmail
end
else
if valid_date(@s) and valid_date(@e)
mails = SesProxy::BouncedEmail.where(:created_at=>{'$gte' => string_to_date(@s),'$lte' => string_to_date(@e)+1.day}).any_of({:recipients => /.*#{@q}.*/i },{:sender => /.*#{@q}.*/i },{:system => /.*#{@q}.*/i },{:subject => /.*#{@q}.*/i })
else
@@ -209,10 +217,10 @@
@s = params[:s]||(Date.today-1.month).strftime("%d-%m-%Y")
@e = params[:e]||Date.today.strftime("%d-%m-%Y")
if valid_date(@s) and valid_date(@e)
bounces = SesProxy::Bounce.where(:created_at=>{'$gte' => string_to_date(@s),'$lte' => string_to_date(@e)+1.day})
else
- bounces = SesProxy::Bounce.all
+ bounces = SesProxy::Bounce
end
bounces
end
def valid_date(d)