From 2f926cfdd3d40cfc414a5a82a3319f62c6aa83c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Wed, 17 Feb 2016 11:02:44 +0100 Subject: [PATCH 1/5] only drop users table columns if they exists --- db/fixtures/009_users.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/fixtures/009_users.rb b/db/fixtures/009_users.rb index 4c5f1187540..a75b81b5651 100644 --- a/db/fixtures/009_users.rb +++ b/db/fixtures/009_users.rb @@ -55,7 +55,7 @@ if User.exec_sql("SELECT 1 FROM schema_migration_details automatically_unpin_topics digest_after_days ].each do |column| - User.exec_sql("ALTER TABLE users DROP column #{column}") + User.exec_sql("ALTER TABLE users DROP column IF EXISTS #{column}") end end From 8893d711e0214fee3272bcc3bdf01bbd74357c44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Wed, 17 Feb 2016 11:25:49 +0100 Subject: [PATCH 2/5] FEATURE: new pop3 polling configuration admin dashboard check --- app/models/admin_dashboard_data.rb | 7 ++++++- lib/validators/pop3_polling_enabled_setting_validator.rb | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/models/admin_dashboard_data.rb b/app/models/admin_dashboard_data.rb index 5cfa8bea2c9..e2a130053ae 100644 --- a/app/models/admin_dashboard_data.rb +++ b/app/models/admin_dashboard_data.rb @@ -62,7 +62,8 @@ class AdminDashboardData :failing_emails_check, :default_logo_check, :contact_email_check, :send_consumer_email_check, :title_check, :site_description_check, :site_contact_username_check, - :notification_email_check, :subfolder_ends_in_slash_check + :notification_email_check, :subfolder_ends_in_slash_check, + :pop3_polling_configuration add_problem_check do sidekiq_check || queue_size_check @@ -205,4 +206,8 @@ class AdminDashboardData I18n.t('dashboard.subfolder_ends_in_slash') if Discourse.base_uri =~ /\/$/ end + def pop3_polling_configuration + POP3PollingEnabledSettingValidator.new.error_message if SiteSetting.pop3_polling_enabled + end + end diff --git a/lib/validators/pop3_polling_enabled_setting_validator.rb b/lib/validators/pop3_polling_enabled_setting_validator.rb index adee3dfc5df..f62e252bbbe 100644 --- a/lib/validators/pop3_polling_enabled_setting_validator.rb +++ b/lib/validators/pop3_polling_enabled_setting_validator.rb @@ -23,7 +23,7 @@ class POP3PollingEnabledSettingValidator I18n.t("site_settings.errors.pop3_polling_username_is_empty") elsif SiteSetting.pop3_polling_password.blank? I18n.t("site_settings.errors.pop3_polling_password_is_empty") - else + elsif !authentication_works? I18n.t("site_settings.errors.pop3_polling_authentication_failed") end end From 532fb7ea9dbc5872460f77b38a32a8420d79b210 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Wed, 17 Feb 2016 11:57:06 +0100 Subject: [PATCH 3/5] fix smoke tests --- db/fixtures/009_users.rb | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/db/fixtures/009_users.rb b/db/fixtures/009_users.rb index a75b81b5651..ccdcaceace4 100644 --- a/db/fixtures/009_users.rb +++ b/db/fixtures/009_users.rb @@ -70,20 +70,18 @@ if ENV["SMOKE"] == "1" u.username_lower = "smoke_user" u.email = "smoke_user@discourse.org" u.password = "P4ssw0rd" - u.email_direct = false - u.email_digests = false - u.email_private_messages = false u.active = true u.approved = true u.approved_at = Time.now u.trust_level = TrustLevel[3] end.first - EmailToken.seed do |et| - et.id = 1 - et.user_id = smoke_user.id - et.email = smoke_user.email - et.confirmed = true - end + UserOption.where(user_id: smoke_user.id).update_all( + email_direct: false, + email_digests: false, + email_private_messages: false, + ) + + EmailToken.where(user_id: smoke_user.id).update_all(confirmed: true) end From 52a66826907bebe81b13ea6bd417f13a05443507 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Wed, 17 Feb 2016 17:31:46 +0100 Subject: [PATCH 4/5] FIX: don't create an EmailLog when we can't send a digest --- lib/email/sender.rb | 4 ++++ spec/components/email/sender_spec.rb | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/email/sender.rb b/lib/email/sender.rb index f0cef9ff227..6168b086dfc 100644 --- a/lib/email/sender.rb +++ b/lib/email/sender.rb @@ -23,6 +23,10 @@ module Email def send return if SiteSetting.disable_emails + + return if ActionMailer::Base::NullMail === @message + return if ActionMailer::Base::NullMail === (@message.message rescue nil) + return skip(I18n.t('email_log.message_blank')) if @message.blank? return skip(I18n.t('email_log.message_to_blank')) if @message.to.blank? diff --git a/spec/components/email/sender_spec.rb b/spec/components/email/sender_spec.rb index b77844e01d8..1fc6d71ad18 100644 --- a/spec/components/email/sender_spec.rb +++ b/spec/components/email/sender_spec.rb @@ -7,7 +7,13 @@ describe Email::Sender do SiteSetting.expects(:disable_emails).returns(true) Mail::Message.any_instance.expects(:deliver_now).never message = Mail::Message.new(to: "hello@world.com" , body: "hello") - Email::Sender.new(message, :hello).send + expect(Email::Sender.new(message, :hello).send).to eq(nil) + end + + it "doesn't deliver mail when the message is of type NullMail" do + Mail::Message.any_instance.expects(:deliver_now).never + message = ActionMailer::Base::NullMail.new + expect(Email::Sender.new(message, :hello).send).to eq(nil) end it "doesn't deliver mail when the message is nil" do From f9c5cded6f3b5bc4eaa9e3460afb09fc07eacd46 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 18 Feb 2016 13:20:22 +1100 Subject: [PATCH 5/5] Correct live refresh routine for notifications --- .../subscribe-user-notifications.js.es6 | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/app/assets/javascripts/discourse/initializers/subscribe-user-notifications.js.es6 b/app/assets/javascripts/discourse/initializers/subscribe-user-notifications.js.es6 index 5923dfca878..fd820d82021 100644 --- a/app/assets/javascripts/discourse/initializers/subscribe-user-notifications.js.es6 +++ b/app/assets/javascripts/discourse/initializers/subscribe-user-notifications.js.es6 @@ -49,34 +49,35 @@ export default { const oldNotifications = stale.results.get('content'); const staleIndex = _.findIndex(oldNotifications, {id: lastNotification.id}); - if (staleIndex > -1) { - oldNotifications.splice(staleIndex, 1); + if (staleIndex === -1) { + // this gets a bit tricky, uread pms are bumped to front + var insertPosition = 0; + if (lastNotification.notification_type !== 6) { + insertPosition = _.findIndex(oldNotifications, function(n){ + return n.notification_type !== 6 || n.read; + }); + insertPosition = insertPosition === -1 ? oldNotifications.length - 1 : insertPosition; + } + + oldNotifications.insertAt(insertPosition, Em.Object.create(lastNotification)); } - // this gets a bit tricky, uread pms are bumped to front - var insertPosition = 0; - if (lastNotification.notification_type !== 6) { - insertPosition = _.findIndex(oldNotifications, function(n){ - return n.notification_type !== 6 || n.read; - }); - insertPosition = insertPosition === -1 ? oldNotifications.length - 1 : insertPosition; - } + for (var idx=0; idx < data.recent.length; idx++) { + var old; + while(old = oldNotifications[idx]) { + var info = data.recent[idx]; - oldNotifications.splice(insertPosition, 0, Em.Object.create(lastNotification)); - - var idx=0; - data.recent.forEach((info)=> { - var old = oldNotifications[idx]; - if (old) { if (old.get('id') !== info[0]) { - oldNotifications.splice(idx, 1); - return; - } else if (old.get('read') !== info[1]) { - old.set('read', info[1]); + oldNotifications.removeAt(idx); + } else { + if (old.get('read') !== info[1]) { + old.set('read', info[1]); + } + break; } } - idx += 1; - }); + if ( !old ) { break; } + } } }, user.notification_channel_position);