mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
Rename pop3s settings to pop3, remove 'insecure'
This commit is contained in:
parent
79e37ad1a8
commit
6d357c9c23
5 changed files with 33 additions and 28 deletions
|
@ -8,14 +8,14 @@ require_dependency 'email/message_builder'
|
|||
|
||||
module Jobs
|
||||
class PollMailbox < Jobs::Scheduled
|
||||
every SiteSetting.pop3s_polling_period_mins.minutes
|
||||
every SiteSetting.pop3_polling_period_mins.minutes
|
||||
sidekiq_options retry: false
|
||||
include Email::BuildEmailHelper
|
||||
|
||||
def execute(args)
|
||||
@args = args
|
||||
if SiteSetting.pop3s_polling_enabled?
|
||||
poll_pop3s
|
||||
if SiteSetting.pop3_polling_enabled?
|
||||
poll_pop3
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -72,14 +72,11 @@ module Jobs
|
|||
end
|
||||
end
|
||||
|
||||
def poll_pop3s
|
||||
if !SiteSetting.pop3s_polling_insecure
|
||||
Net::POP3.enable_ssl(OpenSSL::SSL::VERIFY_NONE)
|
||||
end
|
||||
Net::POP3.start(SiteSetting.pop3s_polling_host,
|
||||
SiteSetting.pop3s_polling_port,
|
||||
SiteSetting.pop3s_polling_username,
|
||||
SiteSetting.pop3s_polling_password) do |pop|
|
||||
def poll_pop3
|
||||
Net::POP3.start(SiteSetting.pop3_polling_host,
|
||||
SiteSetting.pop3_polling_port,
|
||||
SiteSetting.pop3_polling_username,
|
||||
SiteSetting.pop3_polling_password) do |pop|
|
||||
unless pop.mails.empty?
|
||||
pop.each do |mail|
|
||||
handle_mail(mail)
|
||||
|
|
|
@ -91,7 +91,7 @@ module Discourse
|
|||
# Configure sensitive parameters which will be filtered from the log file.
|
||||
config.filter_parameters += [
|
||||
:password,
|
||||
:pop3s_polling_password,
|
||||
:pop3_polling_password,
|
||||
:s3_secret_access_key,
|
||||
:twitter_consumer_secret,
|
||||
:facebook_app_secret,
|
||||
|
|
|
@ -385,13 +385,12 @@ email:
|
|||
email_custom_headers: 'Auto-Submitted: auto-generated'
|
||||
reply_by_email_enabled: false
|
||||
reply_by_email_address: ''
|
||||
pop3s_polling_enabled: false
|
||||
pop3s_polling_insecure: false
|
||||
pop3s_polling_period_mins: 5
|
||||
pop3s_polling_host: ''
|
||||
pop3s_polling_port: 995
|
||||
pop3s_polling_username: ''
|
||||
pop3s_polling_password: ''
|
||||
pop3_polling_enabled: false
|
||||
pop3_polling_period_mins: 5
|
||||
pop3_polling_host: ''
|
||||
pop3_polling_port: 995
|
||||
pop3_polling_username: ''
|
||||
pop3_polling_password: ''
|
||||
email_in:
|
||||
default: false
|
||||
client: true
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
class RenameSettingsPop3sToPop3 < ActiveRecord::Migration
|
||||
def up
|
||||
execute "UPDATE site_settings SET name = replace(name, 'pop3s', 'pop3') WHERE name ILIKE 'pop3%'"
|
||||
end
|
||||
|
||||
def down
|
||||
execute "UPDATE site_settings SET name = replace(name, 'pop3', 'pop3s') WHERE name ILIKE 'pop3%'"
|
||||
end
|
||||
end
|
|
@ -7,18 +7,18 @@ describe Jobs::PollMailbox do
|
|||
|
||||
describe ".execute" do
|
||||
|
||||
it "does no polling if pop3s_polling_enabled is false" do
|
||||
SiteSetting.expects(:pop3s_polling_enabled?).returns(false)
|
||||
poller.expects(:poll_pop3s).never
|
||||
it "does no polling if pop3_polling_enabled is false" do
|
||||
SiteSetting.expects(:pop3_polling_enabled?).returns(false)
|
||||
poller.expects(:poll_pop3).never
|
||||
|
||||
poller.execute({})
|
||||
end
|
||||
|
||||
describe "with pop3s_polling_enabled" do
|
||||
describe "with pop3_polling_enabled" do
|
||||
|
||||
it "calls poll_pop3s" do
|
||||
SiteSetting.expects(:pop3s_polling_enabled?).returns(true)
|
||||
poller.expects(:poll_pop3s).once
|
||||
it "calls poll_pop3" do
|
||||
SiteSetting.expects(:pop3_polling_enabled?).returns(true)
|
||||
poller.expects(:poll_pop3).once
|
||||
|
||||
poller.execute({})
|
||||
end
|
||||
|
@ -26,7 +26,7 @@ describe Jobs::PollMailbox do
|
|||
|
||||
end
|
||||
|
||||
describe ".poll_pop3s" do
|
||||
describe ".poll_pop3" do
|
||||
|
||||
it "logs an error on pop authentication error" do
|
||||
error = Net::POPAuthenticationError.new
|
||||
|
@ -36,7 +36,7 @@ describe Jobs::PollMailbox do
|
|||
|
||||
Discourse.expects(:handle_exception)
|
||||
|
||||
poller.poll_pop3s
|
||||
poller.poll_pop3
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue