@ -8,6 +8,10 @@ class ApplicationController < BaseController
@@test_host
@@test_host
@@test_location
@@test_location
def default_url_options
{ host : " #{ request . protocol } #{ request . host_with_port } " }
end
def capture_page_info
def capture_page_info
# capture request info in case an error occurs
# capture request info in case an error occurs
if request . method == " GET " && ( params [ :controller ] != 'application' || params [ :action ] != 'contact' )
if request . method == " GET " && ( params [ :controller ] != 'application' || params [ :action ] != 'contact' )
@ -103,18 +107,28 @@ class ApplicationController < BaseController
# log the error
# log the error
logger . info " A JavaScript error has occurred on #{ params [ :location ] } : #{ params [ :lineNumber ] } : #{ params [ :message ] } "
logger . info " A JavaScript error has occurred on #{ params [ :location ] } : #{ params [ :lineNumber ] } : #{ params [ :message ] } "
UserMailer . send_mail ( :error_report ) do
if Rails . env . preview? || Rails . env . production?
[
requestHash = {
" A JavaScript error has occurred " ,
'remote_ip' = > arg . remote_ip ,
report ,
'uuid' = > arg . uuid ,
params [ :message ] ,
'original_url' = > arg . original_url ,
nil ,
'env' = > Hash . new
request ,
}
params ,
request . env . each do | key , value |
current_user ,
requestHash [ 'env' ] [ key . to_s ] = value . to_s
Time . now . strftime ( " %d/%m/%Y %H:%M " )
end
]
end if Rails . env . preview? || Rails . env . production?
UserMailer . error_report (
" A JavaScript error has occurred " ,
report ,
params [ :message ] ,
nil ,
requestHash ,
params ,
current_user ,
Time . now . strftime ( " %d/%m/%Y %H:%M " )
) . deliver_later!
end
rescue Exception = > exception2
rescue Exception = > exception2
logger . info exception2 . to_s
logger . info exception2 . to_s
logger . info exception2 . backtrace . join ( " \n " )
logger . info exception2 . backtrace . join ( " \n " )
@ -168,19 +182,28 @@ class ApplicationController < BaseController
logger . info exception . backtrace . join ( " \n " )
logger . info exception . backtrace . join ( " \n " )
# send and email if this is production
# send and email if this is production
suppress ( Exception ) do
if Rails . env . preview? || Rails . env . production?
UserMailer . send_mail ( :error_report ) do
suppress ( Exception ) do
[
requestHash = {
" An error has occurred in #{ Rails . env } " ,
'remote_ip' = > arg . remote_ip ,
nil ,
'uuid' = > arg . uuid ,
exception . to_s ,
'original_url' = > arg . original_url ,
exception . backtrace . join ( " \n " ) ,
'env' = > Hash . new
request ,
}
params ,
request . env . each do | key , value |
current_user ,
requestHash [ 'env' ] [ key . to_s ] = value . to_s
Time . now . strftime ( " %d/%m/%Y %H:%M " )
end
]
UserMailer . error_report (
end if Rails . env . preview? || Rails . env . production?
" An error has occurred in #{ Rails . env } " ,
nil ,
exception . to_s ,
exception . backtrace . join ( " \n " ) ,
requestHash ,
params ,
current_user ,
Time . now . strftime ( " %d/%m/%Y %H:%M " )
) . deliver_later!
end
end
end
# raise the error if we are in development so that we can debug it
# raise the error if we are in development so that we can debug it
@ -206,30 +229,26 @@ class ApplicationController < BaseController
@conference . organizations . each do | org |
@conference . organizations . each do | org |
org . users . each do | user |
org . users . each do | user |
email_list << user . named_email
# email_list << user. named_email
end
end
end
end
end
end
UserMailer . send_mail ( :contact ) do
UserMailer . contact (
[
current_user || params [ :email ] ,
current_user || params [ :email ] ,
params [ :subject ] ,
params [ :subject ] ,
params [ :message ] ,
params [ :message ] ,
email_list
email_list
]
) . deliver_later
end
request_info = session [ 'request_info' ] || { 'request' = > request , 'params' = > params }
request_info = session [ 'request_info' ] || { 'request' = > request , 'params' = > params }
UserMailer . send_mail ( :contact_details ) do
UserMailer . contact_details (
[
current_user || params [ :email ] ,
current_user || params [ :email ] ,
params [ :subject ] ,
params [ :subject ] ,
params [ :message ] ,
params [ :message ] ,
request_info [ 'request' ] ,
request_info [ 'request' ] ,
request_info [ 'params' ]
request_info [ 'params' ]
]
) . deliver_later
end
redirect_to contact_sent_path
redirect_to contact_sent_path
end
end
@ -303,8 +322,8 @@ class ApplicationController < BaseController
if object . respond_to? ( :get_translators )
if object . respond_to? ( :get_translators )
object . get_translators ( data , locale ) . each do | id , user |
object . get_translators ( data , locale ) . each do | id , user |
if user . id != current_user . id && user . id != translator_id
if user . id != current_user . id && user . id != translator_id
UserMailer . send_mail mailer , user . locale do
LinguaFranca . with_locale user . locale do
{ :args = > [ object , data , locale , user , translator ] }
UserMailer . send ( mailer , object . id , data , locale , user . id , translator . id ) . deliver_later
end
end
end
end
end
end
@ -317,8 +336,8 @@ class ApplicationController < BaseController
if object . respond_to? ( :get_translators )
if object . respond_to? ( :get_translators )
object . get_translators ( data ) . each do | id , user |
object . get_translators ( data ) . each do | id , user |
if user . id != current_user . id
if user . id != current_user . id
UserMailer . send_mail mailer , user . locale do
LinguaFranca . with_locale user . locale do
{ :args = > [ object , data , user , current_user ] }
UserMailer . send ( mailer , object . id , data , user . id , current_user . id )
end
end
end
end
end
end
@ -329,23 +348,32 @@ class ApplicationController < BaseController
# log it
# log it
logger . info " Missing translation found for: #{ key } "
logger . info " Missing translation found for: #{ key } "
# send and email if this is production
# send an email if this is production
begin
if Rails . env . preview? || Rails . env . production?
UserMailer . send_mail ( :error_report ) do
begin
[
requestHash = {
" A missing translation found in #{ Rails . env } " ,
'remote_ip' = > arg . remote_ip ,
" <p>A translation for <code> #{ key } </code> in <code> #{ locale . to_s } </code> was found. The text that was rendered to the user was:</p><blockquote> #{ str || 'nil' } </blockquote> " ,
'uuid' = > arg . uuid ,
exception . to_s ,
'original_url' = > arg . original_url ,
nil ,
'env' = > Hash . new
request ,
}
params ,
request . env . each do | key , value |
current_user ,
requestHash [ 'env' ] [ key . to_s ] = value . to_s
Time . now . strftime ( " %d/%m/%Y %H:%M " )
end
]
UserMailer . error_report (
end if Rails . env . preview? || Rails . env . production?
" A missing translation found in #{ Rails . env } " ,
rescue Exception = > exception2
" <p>A translation for <code> #{ key } </code> in <code> #{ locale . to_s } </code> was found. The text that was rendered to the user was:</p><blockquote> #{ str || 'nil' } </blockquote> " ,
logger . info exception2 . to_s
exception . to_s ,
logger . info exception2 . backtrace . join ( " \n " )
nil ,
requestHash ,
params ,
current_user . id ,
Time . now . strftime ( " %d/%m/%Y %H:%M " )
) . deliver_later!
rescue Exception = > exception2
logger . info exception2 . to_s
logger . info exception2 . backtrace . join ( " \n " )
end
end
end
end
end
@ -608,6 +636,6 @@ class ApplicationController < BaseController
# send the confirmation email and make sure it get sent as quickly as possible
# send the confirmation email and make sure it get sent as quickly as possible
def send_confirmation ( confirmation )
def send_confirmation ( confirmation )
UserMailer . send_mail ( :email_confirmation ) { confirmation }
UserMailer . email_confirmation ( confirmation . id ) . deliver_now
end
end
end
end