From 8700716fcd705d7ab9baaad0beec99b4387453ca Mon Sep 17 00:00:00 2001 From: Arpit Jalan Date: Wed, 22 Oct 2014 00:44:56 +0530 Subject: [PATCH] separate site setting for showing full name in emails --- app/mailers/user_notifications.rb | 4 ++-- config/locales/server.en.yml | 2 ++ config/site_settings.yml | 1 + spec/mailers/user_notifications_spec.rb | 8 ++++---- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/mailers/user_notifications.rb b/app/mailers/user_notifications.rb index f016d4d1b9..c76dbf2db1 100644 --- a/app/mailers/user_notifications.rb +++ b/app/mailers/user_notifications.rb @@ -127,7 +127,7 @@ class UserNotifications < ActionMailer::Base title: post.topic.title, post: post, username: post.user.username, - from_alias: SiteSetting.enable_names ? post.user.name : post.user.username, + from_alias: SiteSetting.enable_email_names ? post.user.name : post.user.username, allow_reply_by_email: true, use_site_subject: true, add_re_to_subject: true, @@ -172,7 +172,7 @@ class UserNotifications < ActionMailer::Base return unless @post = opts[:post] user_name = @notification.data_hash[:original_username] - if @post && SiteSetting.enable_names + if @post && SiteSetting.enable_email_names user_name = User.find_by(id: @post.user_id).name end diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 4706a30719..ea169c9e4a 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -941,6 +941,8 @@ en: strip_images_from_short_emails: "Strip images from emails having size less than 2800 Bytes" short_email_length: "Short email length in Bytes" + enable_email_names: "Allow showing user full name in emails. Disable to hide full name in emails." + pop3_polling_enabled: "Poll via POP3 for email replies." pop3_polling_ssl: "Use SSL while connecting to the POP3 server. (Recommended)" pop3_polling_period_mins: "The period in minutes between checking the POP3 account for email. NOTE: requires restart." diff --git a/config/site_settings.yml b/config/site_settings.yml index 6e736b48b0..525a68b369 100644 --- a/config/site_settings.yml +++ b/config/site_settings.yml @@ -416,6 +416,7 @@ email: disable_emails: false strip_images_from_short_emails: true short_email_length: 2800 + enable_email_names: true files: max_image_size_kb: diff --git a/spec/mailers/user_notifications_spec.rb b/spec/mailers/user_notifications_spec.rb index 706bc9f698..c166c75840 100644 --- a/spec/mailers/user_notifications_spec.rb +++ b/spec/mailers/user_notifications_spec.rb @@ -80,7 +80,7 @@ describe UserNotifications do let(:notification) { Fabricate(:notification, user: user) } it 'generates a correct email' do - SiteSetting.stubs(:enable_names).returns(true) + SiteSetting.stubs(:enable_email_names).returns(true) mail = UserNotifications.user_replied(response.user, post: response, notification: notification) # from should include full user name @@ -121,7 +121,7 @@ describe UserNotifications do let(:notification) { Fabricate(:notification, user: user) } it 'generates a correct email' do - SiteSetting.stubs(:enable_names).returns(false) + SiteSetting.stubs(:enable_email_names).returns(false) mail = UserNotifications.user_posted(response.user, post: response, notification: notification) # from should not include full user name if "show user full names" is disabled @@ -150,7 +150,7 @@ describe UserNotifications do let(:notification) { Fabricate(:notification, user: user) } it 'generates a correct email' do - SiteSetting.stubs(:enable_names).returns(true) + SiteSetting.stubs(:enable_email_names).returns(true) mail = UserNotifications.user_private_message(response.user, post: response, notification: notification) # from should include full user name @@ -239,7 +239,7 @@ describe UserNotifications do end it "has a from alias" do - SiteSetting.stubs(:enable_names).returns(true) + SiteSetting.stubs(:enable_email_names).returns(true) expects_build_with(has_entry(:from_alias, "#{user.name}")) end