From a8d644af2822b0490663c40d237af842ac3428fc Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sun, 6 Sep 2015 13:39:16 +0200 Subject: [PATCH] Show also notice on account overview if account is ok. --- .../channel/email_account_overview.jst.eco | 4 +-- app/models/channel/driver/imap.rb | 25 ++++++++++--------- app/models/channel/driver/pop3.rb | 23 ++++++++--------- lib/email_helper/probe.rb | 18 ++++++------- 4 files changed, 35 insertions(+), 35 deletions(-) diff --git a/app/assets/javascripts/app/views/channel/email_account_overview.jst.eco b/app/assets/javascripts/app/views/channel/email_account_overview.jst.eco index a798ec21b..fd6004a25 100644 --- a/app/assets/javascripts/app/views/channel/email_account_overview.jst.eco +++ b/app/assets/javascripts/app/views/channel/email_account_overview.jst.eco @@ -65,12 +65,12 @@ <%- @Icon('trash') %> - <% if channel.status_in is 'error': %> + <% if !_.isEmpty(channel.last_log_in): %> <%= channel.last_log_in %> <% end %> - <% if channel.status_out is 'error': %> + <% if !_.isEmpty(channel.last_log_out): %> <%= channel.last_log_out %> diff --git a/app/models/channel/driver/imap.rb b/app/models/channel/driver/imap.rb index 70f0463fc..ab55b9ddd 100644 --- a/app/models/channel/driver/imap.rb +++ b/app/models/channel/driver/imap.rb @@ -101,7 +101,7 @@ returns break if content_max_check < content_messages end end - if content_messages >= content_messages + if content_messages >= content_max_check content_messages = message_ids.count end disconnect @@ -123,15 +123,15 @@ returns # check if verify message exists subject = message_meta['ENVELOPE'].subject - if subject && subject =~ /#{verify_string}/ - Rails.logger.info " - verify email #{verify_string} found" - @imap.store(message_id, '+FLAGS', [:Deleted]) - @imap.expunge() - disconnect - return { - result: 'ok', - } - end + next if !subject + next if subject !~ /#{verify_string}/ + Rails.logger.info " - verify email #{verify_string} found" + @imap.store(message_id, '+FLAGS', [:Deleted]) + @imap.expunge() + disconnect + return { + result: 'ok', + } end disconnect @@ -153,10 +153,10 @@ returns message_meta = @imap.fetch(message_id, ['RFC822.SIZE', 'FLAGS', 'INTERNALDATE'])[0] # ignore to big messages - max_message_size = Setting.get('postmaster_max_size') + max_message_size = Setting.get('postmaster_max_size').to_f real_message_size = message_meta.attr['RFC822.SIZE'].to_f / 1024 / 1024 if real_message_size > max_message_size - info = " - ignore message #{count}/#{count_all} - because message is to big (is:#{real_message_size}/max:#{max_message_size} in MB)" + info = " - ignore message #{count}/#{count_all} - because message is to big (is:#{real_message_size} MB/max:#{max_message_size} MB)" Rails.logger.info info notice += "#{info}\n" next @@ -170,6 +170,7 @@ returns # delete email from server after article was created msg = @imap.fetch(message_id, 'RFC822')[0].attr['RFC822'] + next if !msg if process(channel, msg) @imap.store(message_id, '+FLAGS', [:Deleted]) count_fetched += 1 diff --git a/app/models/channel/driver/pop3.rb b/app/models/channel/driver/pop3.rb index 554102d5e..fe54f0f74 100644 --- a/app/models/channel/driver/pop3.rb +++ b/app/models/channel/driver/pop3.rb @@ -88,7 +88,7 @@ returns break if content_max_check < content_messages end end - if content_messages >= content_messages + if content_messages >= content_max_check content_messages = mails.count end disconnect @@ -109,14 +109,13 @@ returns next if !mail # check if verify message exists - if mail =~ /#{verify_string}/ - Rails.logger.info " - verify email #{verify_string} found" - m.delete - disconnect - return { - result: 'ok', - } - end + next if mail !~ /#{verify_string}/ + Rails.logger.info " - verify email #{verify_string} found" + m.delete + disconnect + return { + result: 'ok', + } end return { @@ -132,14 +131,14 @@ returns mails.each do |m| count += 1 Rails.logger.info " - message #{count}/#{count_all}" - mail = m.pop + next if !mail # ignore to big messages - max_message_size = Setting.get('postmaster_max_size') + max_message_size = Setting.get('postmaster_max_size').to_f real_message_size = mail.size.to_f / 1024 / 1024 if real_message_size > max_message_size - info = " - ignore message #{count}/#{count_all} - because message is to big (is:#{real_message_size}/max:#{max_message_size} in MB)" + info = " - ignore message #{count}/#{count_all} - because message is to big (is:#{real_message_size} MB/max:#{max_message_size} MB)" Rails.logger.info info notice += "#{info}\n" next diff --git a/lib/email_helper/probe.rb b/lib/email_helper/probe.rb index 043ea099c..c9b3d7984 100644 --- a/lib/email_helper/probe.rb +++ b/lib/email_helper/probe.rb @@ -72,15 +72,15 @@ returns on fail next if domain_to_check !~ /#{settings[:domain]}/i # probe inbound - Rails.logger.info "INBOUND PROBE PROVIDER: #{settings[:inbound].inspect}" + Rails.logger.debug "INBOUND PROBE PROVIDER: #{settings[:inbound].inspect}" result_inbound = EmailHelper::Probe.inbound(settings[:inbound]) - Rails.logger.info "INBOUND RESULT PROVIDER: #{result_inbound.inspect}" + Rails.logger.debug "INBOUND RESULT PROVIDER: #{result_inbound.inspect}" next if result_inbound[:result] != 'ok' # probe outbound - Rails.logger.info "OUTBOUND PROBE PROVIDER: #{settings[:outbound].inspect}" + Rails.logger.debug "OUTBOUND PROBE PROVIDER: #{settings[:outbound].inspect}" result_outbound = EmailHelper::Probe.outbound(settings[:outbound], params[:email]) - Rails.logger.info "OUTBOUND RESULT PROVIDER: #{result_outbound.inspect}" + Rails.logger.debug "OUTBOUND RESULT PROVIDER: #{result_outbound.inspect}" next if result_outbound[:result] != 'ok' return { @@ -103,9 +103,9 @@ returns on fail } success = false inbound_map.each {|config| - Rails.logger.info "INBOUND PROBE GUESS: #{config.inspect}" + Rails.logger.debug "INBOUND PROBE GUESS: #{config.inspect}" result_inbound = EmailHelper::Probe.inbound(config) - Rails.logger.info "INBOUND RESULT GUESS: #{result_inbound.inspect}" + Rails.logger.debug "INBOUND RESULT GUESS: #{result_inbound.inspect}" next if result_inbound[:result] != 'ok' @@ -131,9 +131,9 @@ returns on fail success = false outbound_map.each {|config| - Rails.logger.info "OUTBOUND PROBE GUESS: #{config.inspect}" + Rails.logger.debug "OUTBOUND PROBE GUESS: #{config.inspect}" result_outbound = EmailHelper::Probe.outbound(config, params[:email]) - Rails.logger.info "OUTBOUND RESULT GUESS: #{result_outbound.inspect}" + Rails.logger.debug "OUTBOUND RESULT GUESS: #{result_outbound.inspect}" next if result_outbound[:result] != 'ok' @@ -149,7 +149,7 @@ returns on fail reason: 'outbound failed', } end - + Rails.logger.info "PROBE FULL SUCCESS: #{result.inspect}" result end