Commit 5f68322406eca042ad77dda6964a609bb648b19f
Exists in
master
and in
29 other branches
Merge branch 'ai3028' of https://gitlab.com/brauliobo/noosfero into brauliobo/noosfero-ai3028
Conflicts: db/schema.rb
Showing
22 changed files
with
52 additions
and
34 deletions
Show diff stats
app/models/comment.rb
| ... | ... | @@ -172,7 +172,7 @@ class Comment < ActiveRecord::Base |
| 172 | 172 | def mail(comment) |
| 173 | 173 | profile = comment.article.profile |
| 174 | 174 | recipients comment.notification_emails |
| 175 | - from "#{profile.environment.name} <#{profile.environment.contact_email}>" | |
| 175 | + from "#{profile.environment.name} <#{profile.environment.noreply_email}>" | |
| 176 | 176 | subject _("[%s] you got a new comment!") % [profile.environment.name] |
| 177 | 177 | body :recipient => profile.nickname || profile.name, |
| 178 | 178 | :sender => comment.author_name, |
| ... | ... | @@ -187,7 +187,7 @@ class Comment < ActiveRecord::Base |
| 187 | 187 | def mail_to_followers(comment, emails) |
| 188 | 188 | profile = comment.article.profile |
| 189 | 189 | bcc emails |
| 190 | - from "#{profile.environment.name} <#{profile.environment.contact_email}>" | |
| 190 | + from "#{profile.environment.name} <#{profile.environment.noreply_email}>" | |
| 191 | 191 | subject _("[%s] %s commented on a content of %s") % [profile.environment.name, comment.author_name, profile.short_name] |
| 192 | 192 | body :recipient => profile.nickname || profile.name, |
| 193 | 193 | :sender => comment.author_name, | ... | ... |
app/models/contact.rb
| ... | ... | @@ -26,7 +26,7 @@ class Contact < ActiveRecord::Base #WithoutTable |
| 26 | 26 | content_type 'text/html' |
| 27 | 27 | emails = contact.dest.notification_emails |
| 28 | 28 | recipients emails |
| 29 | - from "#{contact.name} <#{contact.dest.environment.contact_email}>" | |
| 29 | + from "#{contact.name} <#{contact.dest.environment.noreply_email}>" | |
| 30 | 30 | reply_to contact.email |
| 31 | 31 | if contact.sender |
| 32 | 32 | headers 'X-Noosfero-Sender' => contact.sender.identifier | ... | ... |
app/models/environment.rb
| ... | ... | @@ -591,7 +591,7 @@ class Environment < ActiveRecord::Base |
| 591 | 591 | # only one environment can be the default one |
| 592 | 592 | validates_uniqueness_of :is_default, :if => (lambda do |environment| environment.is_default? end), :message => N_('Only one Virtual Community can be the default one') |
| 593 | 593 | |
| 594 | - validates_format_of :contact_email, :with => Noosfero::Constants::EMAIL_FORMAT, :if => (lambda { |record| ! record.contact_email.blank? }) | |
| 594 | + validates_format_of :contact_email, :noreply_email, :with => Noosfero::Constants::EMAIL_FORMAT, :allow_blank => true | |
| 595 | 595 | |
| 596 | 596 | xss_terminate :only => [ :message_for_disabled_enterprise ], :with => 'white_list', :on => 'validation' |
| 597 | 597 | |
| ... | ... | @@ -764,7 +764,7 @@ class Environment < ActiveRecord::Base |
| 764 | 764 | end |
| 765 | 765 | |
| 766 | 766 | def notification_emails |
| 767 | - [contact_email.blank? ? nil : contact_email].compact + admins.map(&:email) | |
| 767 | + [noreply_email.blank? ? nil : noreply_email].compact + admins.map(&:email) | |
| 768 | 768 | end |
| 769 | 769 | |
| 770 | 770 | after_create :create_templates | ... | ... |
app/models/mailing.rb
| ... | ... | @@ -17,7 +17,7 @@ class Mailing < ActiveRecord::Base |
| 17 | 17 | end |
| 18 | 18 | |
| 19 | 19 | def generate_from |
| 20 | - "#{source.name} <#{source.contact_email}>" | |
| 20 | + "#{source.name} <#{if source.is_a? Environment then source.noreply_email else source.contact_email end}>" | |
| 21 | 21 | end |
| 22 | 22 | |
| 23 | 23 | def generate_subject | ... | ... |
app/models/organization_mailing.rb
app/models/pending_task_notifier.rb
| ... | ... | @@ -2,7 +2,7 @@ class PendingTaskNotifier < ActionMailer::Base |
| 2 | 2 | |
| 3 | 3 | def notification(person) |
| 4 | 4 | recipients person.email |
| 5 | - from "#{person.environment.name} <#{person.environment.contact_email}>" | |
| 5 | + from "#{person.environment.name} <#{person.environment.noreply_email}>" | |
| 6 | 6 | subject _("[%s] Pending tasks") % person.environment.name |
| 7 | 7 | body :person => person, |
| 8 | 8 | :tasks => person.tasks.pending, | ... | ... |
app/models/scrap.rb
| ... | ... | @@ -14,7 +14,7 @@ class Scrap < ActiveRecord::Base |
| 14 | 14 | |
| 15 | 15 | named_scope :not_replies, :conditions => {:scrap_id => nil} |
| 16 | 16 | |
| 17 | - track_actions :leave_scrap, :after_create, :keep_params => ['sender.name', 'content', 'receiver.name', 'receiver.url'], :if => Proc.new{|s| s.sender != s.receiver && s.sender != s.top_root.receiver}, :custom_target => :action_tracker_target | |
| 17 | + track_actions :leave_scrap, :after_create, :keep_params => ['sender.name', 'content', 'receiver.name', 'receiver.url'], :if => Proc.new{|s| s.sender != s.receiver && s.sender != s.top_root.receiver}, :custom_target => :action_tracker_target | |
| 18 | 18 | |
| 19 | 19 | track_actions :leave_scrap_to_self, :after_create, :keep_params => ['sender.name', 'content'], :if => Proc.new{|s| s.sender == s.receiver} |
| 20 | 20 | |
| ... | ... | @@ -59,7 +59,7 @@ class Scrap < ActiveRecord::Base |
| 59 | 59 | sender, receiver = scrap.sender, scrap.receiver |
| 60 | 60 | recipients receiver.email |
| 61 | 61 | |
| 62 | - from "#{sender.environment.name} <#{sender.environment.contact_email}>" | |
| 62 | + from "#{sender.environment.name} <#{sender.environment.noreply_email}>" | |
| 63 | 63 | subject _("[%s] You received a scrap!") % [sender.environment.name] |
| 64 | 64 | body :recipient => receiver.name, |
| 65 | 65 | :sender => sender.name, | ... | ... |
app/models/task_mailer.rb
| ... | ... | @@ -60,7 +60,7 @@ class TaskMailer < ActionMailer::Base |
| 60 | 60 | end |
| 61 | 61 | |
| 62 | 62 | def self.generate_from(task) |
| 63 | - "#{task.environment.name} <#{task.environment.contact_email}>" | |
| 63 | + "#{task.environment.name} <#{task.environment.noreply_email}>" | |
| 64 | 64 | end |
| 65 | 65 | |
| 66 | 66 | def generate_environment_url(task, url = {}) | ... | ... |
app/models/user.rb
| ... | ... | @@ -54,7 +54,7 @@ class User < ActiveRecord::Base |
| 54 | 54 | def activation_email_notify(user) |
| 55 | 55 | user_email = "#{user.login}@#{user.email_domain}" |
| 56 | 56 | recipients user_email |
| 57 | - from "#{user.environment.name} <#{user.environment.contact_email}>" | |
| 57 | + from "#{user.environment.name} <#{user.environment.noreply_email}>" | |
| 58 | 58 | subject _("[%{environment}] Welcome to %{environment} mail!") % { :environment => user.environment.name } |
| 59 | 59 | body :name => user.name, |
| 60 | 60 | :email => user_email, |
| ... | ... | @@ -66,7 +66,7 @@ class User < ActiveRecord::Base |
| 66 | 66 | def activation_code(user) |
| 67 | 67 | recipients user.email |
| 68 | 68 | |
| 69 | - from "#{user.environment.name} <#{user.environment.contact_email}>" | |
| 69 | + from "#{user.environment.name} <#{user.environment.noreply_email}>" | |
| 70 | 70 | subject _("[%s] Activate your account") % [user.environment.name] |
| 71 | 71 | body :recipient => user.name, |
| 72 | 72 | :activation_code => user.activation_code, |
| ... | ... | @@ -81,7 +81,7 @@ class User < ActiveRecord::Base |
| 81 | 81 | content_type 'text/html' |
| 82 | 82 | recipients user.email |
| 83 | 83 | |
| 84 | - from "#{user.environment.name} <#{user.environment.contact_email}>" | |
| 84 | + from "#{user.environment.name} <#{user.environment.noreply_email}>" | |
| 85 | 85 | subject email_subject.blank? ? _("Welcome to environment %s") % [user.environment.name] : email_subject |
| 86 | 86 | body email_body |
| 87 | 87 | end |
| ... | ... | @@ -93,7 +93,7 @@ class User < ActiveRecord::Base |
| 93 | 93 | self.person.save! |
| 94 | 94 | end |
| 95 | 95 | end |
| 96 | - | |
| 96 | + | |
| 97 | 97 | has_one :person, :dependent => :destroy |
| 98 | 98 | belongs_to :environment |
| 99 | 99 | |
| ... | ... | @@ -183,7 +183,7 @@ class User < ActiveRecord::Base |
| 183 | 183 | encryption_methods[sym] = block |
| 184 | 184 | end |
| 185 | 185 | |
| 186 | - # the encryption method used for this instance | |
| 186 | + # the encryption method used for this instance | |
| 187 | 187 | def encryption_method |
| 188 | 188 | (password_type || User.system_encryption_method).to_sym |
| 189 | 189 | end |
| ... | ... | @@ -226,7 +226,7 @@ class User < ActiveRecord::Base |
| 226 | 226 | end |
| 227 | 227 | |
| 228 | 228 | def remember_token? |
| 229 | - remember_token_expires_at && Time.now.utc < remember_token_expires_at | |
| 229 | + remember_token_expires_at && Time.now.utc < remember_token_expires_at | |
| 230 | 230 | end |
| 231 | 231 | |
| 232 | 232 | # These create and unset the fields required for remembering users between browser closes |
| ... | ... | @@ -255,7 +255,7 @@ class User < ActiveRecord::Base |
| 255 | 255 | raise IncorrectPassword unless self.authenticated?(current) |
| 256 | 256 | self.force_change_password!(new, confirmation) |
| 257 | 257 | end |
| 258 | - | |
| 258 | + | |
| 259 | 259 | # Changes the password of a user without asking for the old password. This |
| 260 | 260 | # method is intended to be used by the "I forgot my password", and must be |
| 261 | 261 | # used with care. |
| ... | ... | @@ -326,7 +326,7 @@ class User < ActiveRecord::Base |
| 326 | 326 | end |
| 327 | 327 | |
| 328 | 328 | protected |
| 329 | - # before filter | |
| 329 | + # before filter | |
| 330 | 330 | def encrypt_password |
| 331 | 331 | return if password.blank? |
| 332 | 332 | self.salt ||= Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{login}--") if new_record? | ... | ... |
app/views/admin_panel/_site_info.rhtml
| 1 | 1 | <%= required labelled_form_field(_('Site name'), text_field(:environment, :name)) %> |
| 2 | 2 | <%= labelled_form_field(_('Contact email'), text_field(:environment, :contact_email)) %> |
| 3 | +<%= labelled_form_field(_('No reply email'), text_field(:environment, :noreply_email)) %> | |
| 3 | 4 | <% themes_options = Theme.system_themes.map {|theme| [theme.name, theme.id] }.sort %> |
| 4 | 5 | <%= labelled_form_field(_('Theme'), select(:environment, :theme, options_for_select(themes_options, environment.theme))) %> |
| 5 | 6 | <%= required f.text_field(:reports_lower_bound, :size => 3) %> | ... | ... |
db/migrate/20140303173209_move_contact_email_to_noreply_email_at_environment.rb
0 → 100644
| ... | ... | @@ -0,0 +1,16 @@ |
| 1 | +class MoveContactEmailToNoreplyEmailAtEnvironment < ActiveRecord::Migration | |
| 2 | + def self.up | |
| 3 | + add_column :environments, :noreply_email, :string | |
| 4 | + Environment.reset_column_information | |
| 5 | + | |
| 6 | + Environment.find_each do |environment| | |
| 7 | + environment.noreply_email = environment.contact_email | |
| 8 | + environment.contact_email = nil | |
| 9 | + environment.save! | |
| 10 | + end | |
| 11 | + end | |
| 12 | + | |
| 13 | + def self.down | |
| 14 | + say "this migration can't be reverted" | |
| 15 | + end | |
| 16 | +end | ... | ... |
db/schema.rb
| 1 | -# This file is auto-generated from the current state of the database. Instead of editing this file, | |
| 1 | +# This file is auto-generated from the current state of the database. Instead of editing this file, | |
| 2 | 2 | # please use the migrations feature of Active Record to incrementally modify your database, and |
| 3 | 3 | # then regenerate this schema definition. |
| 4 | 4 | # |
| ... | ... | @@ -285,6 +285,7 @@ ActiveRecord::Schema.define(:version => 20140314200103) do |
| 285 | 285 | t.text "signup_welcome_text" |
| 286 | 286 | t.string "languages" |
| 287 | 287 | t.string "default_language" |
| 288 | + t.string "noreply_email" | |
| 288 | 289 | end |
| 289 | 290 | |
| 290 | 291 | create_table "external_feeds", :force => true do |t| | ... | ... |
lib/feed_updater.rb
| ... | ... | @@ -24,8 +24,8 @@ class FeedUpdater |
| 24 | 24 | environment = Environment.default |
| 25 | 25 | |
| 26 | 26 | recipients NOOSFERO_CONF['exception_recipients'] |
| 27 | - from environment.contact_email | |
| 28 | - reply_to environment.contact_email | |
| 27 | + from environment.noreply_email | |
| 28 | + reply_to environment.noreply_email | |
| 29 | 29 | subject "[#{environment.name}] Feed-updater: #{error.message}" |
| 30 | 30 | body render(:text => " |
| 31 | 31 | Container: | ... | ... |
plugins/send_email/controllers/send_email_plugin_base_controller.rb
| ... | ... | @@ -3,7 +3,7 @@ module SendEmailPluginBaseController |
| 3 | 3 | if request.post? |
| 4 | 4 | @context_url = profile ? profile.url : {:host => environment.default_hostname, :controller => 'home'} |
| 5 | 5 | @mail = SendEmailPlugin::Mail.new( |
| 6 | - :from => environment.contact_email, | |
| 6 | + :from => environment.noreply_email, | |
| 7 | 7 | :to => params[:to], |
| 8 | 8 | :message => params[:message], |
| 9 | 9 | :environment => environment, | ... | ... |
plugins/spaminator/lib/spaminator_plugin/mailer.rb
| ... | ... | @@ -2,7 +2,7 @@ class SpaminatorPlugin::Mailer < Noosfero::Plugin::MailerBase |
| 2 | 2 | |
| 3 | 3 | def inactive_person_notification(person) |
| 4 | 4 | recipients person.email |
| 5 | - from "#{person.environment.name} <#{person.environment.contact_email}>" | |
| 5 | + from "#{person.environment.name} <#{person.environment.noreply_email}>" | |
| 6 | 6 | subject _("[%s] You must reactivate your account.") % person.environment.name |
| 7 | 7 | content_type 'text/html' |
| 8 | 8 | body :person => person, | ... | ... |
plugins/spaminator/test/unit/spaminator_plugin/mailer_test.rb
| ... | ... | @@ -14,7 +14,7 @@ class SpaminatorPlugin::MailerTest < ActiveSupport::TestCase |
| 14 | 14 | attr_accessor :environment, :settings |
| 15 | 15 | |
| 16 | 16 | should 'be able to send a inactive person notification message' do |
| 17 | - environment.contact_email = 'no-reply@noosfero.org' | |
| 17 | + environment.noreply_email = 'no-reply@noosfero.org' | |
| 18 | 18 | environment.save |
| 19 | 19 | |
| 20 | 20 | person = create_user('spammer').person | ... | ... |
test/unit/contact_sender_test.rb
| ... | ... | @@ -16,7 +16,7 @@ class ContactSenderTest < ActiveSupport::TestCase |
| 16 | 16 | ent.contact_email = 'contact@invalid.com' |
| 17 | 17 | c = build(Contact, :dest => ent) |
| 18 | 18 | response = Contact::Sender.deliver_mail(c) |
| 19 | - assert_equal Environment.default.contact_email, response.from.to_s | |
| 19 | + assert_equal Environment.default.noreply_email, response.from.to_s | |
| 20 | 20 | assert_equal "[#{ent.name}] #{c.subject}", response.subject |
| 21 | 21 | end |
| 22 | 22 | |
| ... | ... | @@ -27,7 +27,7 @@ class ContactSenderTest < ActiveSupport::TestCase |
| 27 | 27 | response = Contact::Sender.deliver_mail(c) |
| 28 | 28 | assert_includes response.to, c.dest.contact_email |
| 29 | 29 | end |
| 30 | - | |
| 30 | + | |
| 31 | 31 | should 'deliver mail to admins of enterprise' do |
| 32 | 32 | admin = create_user('admin_test').person |
| 33 | 33 | ent = Enterprise.create!(:name => 'my enterprise', :identifier => 'myent', :environment => Environment.default) | ... | ... |
test/unit/contact_test.rb
| ... | ... | @@ -44,11 +44,11 @@ class ContactTest < ActiveSupport::TestCase |
| 44 | 44 | assert !c.deliver |
| 45 | 45 | end |
| 46 | 46 | |
| 47 | - should 'use sender name and environment contact_email on from' do | |
| 47 | + should 'use sender name and environment noreply_email on from' do | |
| 48 | 48 | ent = fast_create(Enterprise, :name => 'my enterprise', :identifier => 'myent') |
| 49 | 49 | c = Contact.new(:name => 'john', :email => 'john@invalid.com', :subject => 'hi', :message => 'hi, all', :dest => ent) |
| 50 | 50 | email = c.deliver |
| 51 | - assert_equal "#{c.name} <#{ent.environment.contact_email}>", email['from'].to_s | |
| 51 | + assert_equal "#{c.name} <#{ent.environment.noreply_email}>", email['from'].to_s | |
| 52 | 52 | end |
| 53 | 53 | |
| 54 | 54 | should 'add dest name on subject' do | ... | ... |
test/unit/environment_mailing_test.rb
| ... | ... | @@ -46,7 +46,7 @@ class EnvironmentMailingTest < ActiveSupport::TestCase |
| 46 | 46 | |
| 47 | 47 | should 'display name and email on generate_from' do |
| 48 | 48 | mailing = EnvironmentMailing.new(:source => environment, :person => person_1) |
| 49 | - assert_equal "#{environment.name} <#{environment.contact_email}>", mailing.generate_from | |
| 49 | + assert_equal "#{environment.name} <#{environment.noreply_email}>", mailing.generate_from | |
| 50 | 50 | end |
| 51 | 51 | |
| 52 | 52 | should 'deliver mailing to each recipient after create' do | ... | ... |
test/unit/mailing_test.rb
| ... | ... | @@ -74,7 +74,7 @@ class MailingTest < ActiveSupport::TestCase |
| 74 | 74 | should 'display name and email on generate_from' do |
| 75 | 75 | person = Person['user_one'] |
| 76 | 76 | mailing = Mailing.new(:source => environment, :person => person) |
| 77 | - assert_equal "#{environment.name} <#{environment.contact_email}>", mailing.generate_from | |
| 77 | + assert_equal "#{environment.name} <#{environment.noreply_email}>", mailing.generate_from | |
| 78 | 78 | end |
| 79 | 79 | |
| 80 | 80 | should 'generate subject' do | ... | ... |
test/unit/organization_mailing_test.rb
| ... | ... | @@ -42,7 +42,7 @@ class OrganizationMailingTest < ActiveSupport::TestCase |
| 42 | 42 | |
| 43 | 43 | should 'display name and email on generate_from' do |
| 44 | 44 | mailing = OrganizationMailing.new(:source => community, :person => person) |
| 45 | - assert_equal "#{person.name} <#{community.environment.contact_email}>", mailing.generate_from | |
| 45 | + assert_equal "#{person.name} <#{community.environment.noreply_email}>", mailing.generate_from | |
| 46 | 46 | end |
| 47 | 47 | |
| 48 | 48 | should 'generate subject' do | ... | ... |
vendor/plugins/monkey_patches/rescue_delayed_job_crashes/init.rb
| ... | ... | @@ -5,8 +5,8 @@ Delayed::Worker.module_eval do |
| 5 | 5 | environment = Environment.default |
| 6 | 6 | |
| 7 | 7 | recipients NOOSFERO_CONF['exception_recipients'] |
| 8 | - from environment.contact_email | |
| 9 | - reply_to environment.contact_email | |
| 8 | + from environment.noreply_email | |
| 9 | + reply_to environment.noreply_email | |
| 10 | 10 | subject "[#{environment.name}] DelayedJob ##{job.id}: #{error.message}" |
| 11 | 11 | body render(:text => " |
| 12 | 12 | Job: | ... | ... |