Merge pull request #4508 from kstaikov/mailing_list_exclude_own_replies

FEATURE:'No Echo' option for mailing list mode.
This commit is contained in:
Régis Hanol
2016-10-22 10:45:14 +02:00
committed by GitHub
9 changed files with 62 additions and 5 deletions

View File

@@ -79,7 +79,8 @@ export default Ember.Controller.extend(CanCheckEmails, {
mailingListModeOptions() {
return [
{name: I18n.t('user.mailing_list_mode.daily'), value: 0},
{name: this.get('frequencyEstimate'), value: 1}
{name: this.get('frequencyEstimate'), value: 1},
{name: I18n.t('user.mailing_list_mode.individual_no_echo'), value: 2}
];
},

View File

@@ -16,7 +16,7 @@ module Jobs
users =
User.activated.not_blocked.not_suspended.real
.joins(:user_option)
.where(user_options: {mailing_list_mode: true, mailing_list_mode_frequency: 1})
.where('user_options.mailing_list_mode AND user_options.mailing_list_mode_frequency > 0')
.where('NOT EXISTS(
SELECT 1
FROM topic_users tu
@@ -46,6 +46,11 @@ module Jobs
next
end
if (user.id == post.user_id) && (user.user_option.mailing_list_mode_frequency == 2)
skip(user.email, user.id, post.id, I18n.t('email_log.no_echo_mailing_list_mode'))
next
end
begin
if message = UserNotifications.mailing_list_notify(user, post)
EmailLog.unique_email_per_post(post, user) do

View File

@@ -103,7 +103,7 @@ module Jobs
end
if user.user_option.mailing_list_mode? &&
user.user_option.mailing_list_mode_frequency == 1 && # don't catch notifications for users on daily mailing list mode
user.user_option.mailing_list_mode_frequency > 0 && # don't catch notifications for users on daily mailing list mode
(!post.try(:topic).try(:private_message?)) &&
NOTIFICATIONS_SENT_BY_MAILING_LIST.include?(email_args[:notification_type])
# no need to log a reason when the mail was already sent via the mailing list job

View File

@@ -9,7 +9,8 @@ class MailingListModeSiteSetting < EnumSiteSetting
def self.values
@values ||= [
{ name: 'user.mailing_list_mode.daily', value: 0 },
{ name: 'user.mailing_list_mode.individual', value: 1 }
{ name: 'user.mailing_list_mode.individual', value: 1 },
{ name: 'user.mailing_list_mode.individual_no_echo', value: 2 }
]
end