"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/email/sender.rb" between
discourse-2.5.2.tar.gz and discourse-2.5.3.tar.gz

About: Discourse is a "next-generation" forum platform for community discussions.

sender.rb  (discourse-2.5.2):sender.rb  (discourse-2.5.3)
skipping to change at line 15 skipping to change at line 15
# to be "do nothing". This is because some Mailers will decide not to do work fo r some # to be "do nothing". This is because some Mailers will decide not to do work fo r some
# reason. For example, emailing a user too frequently. A nil to address is also considered # reason. For example, emailing a user too frequently. A nil to address is also considered
# "do nothing" # "do nothing"
# #
# It also adds an HTML part for the plain text body # It also adds an HTML part for the plain text body
# #
require 'uri' require 'uri'
require 'net/smtp' require 'net/smtp'
SMTP_CLIENT_ERRORS = [Net::SMTPFatalError, Net::SMTPSyntaxError] SMTP_CLIENT_ERRORS = [Net::SMTPFatalError, Net::SMTPSyntaxError]
BYPASS_DISABLE_TYPES = ["admin_login", "test_message"] BYPASS_DISABLE_TYPES = %w(
admin_login
test_message
new_version
group_smtp
invite
download_backup_message
admin_confirmation_message
)
module Email module Email
class Sender class Sender
def initialize(message, email_type, user = nil) def initialize(message, email_type, user = nil)
@message = message @message = message
@email_type = email_type @email_type = email_type
@user = user @user = user
end end
skipping to change at line 40 skipping to change at line 48
return return
end end
return if ActionMailer::Base::NullMail === @message return if ActionMailer::Base::NullMail === @message
return if ActionMailer::Base::NullMail === (@message.message rescue nil) return if ActionMailer::Base::NullMail === (@message.message rescue nil)
return skip(SkippedEmailLog.reason_types[:sender_message_blank]) if @me ssage.blank? return skip(SkippedEmailLog.reason_types[:sender_message_blank]) if @me ssage.blank?
return skip(SkippedEmailLog.reason_types[:sender_message_to_blank]) if @me ssage.to.blank? return skip(SkippedEmailLog.reason_types[:sender_message_to_blank]) if @me ssage.to.blank?
if SiteSetting.disable_emails == "non-staff" && !bypass_disable if SiteSetting.disable_emails == "non-staff" && !bypass_disable
return unless User.find_by_email(to_address)&.staff? return unless find_user&.staff?
end end
return skip(SkippedEmailLog.reason_types[:sender_message_to_invalid]) if t o_address.end_with?(".invalid") return skip(SkippedEmailLog.reason_types[:sender_message_to_invalid]) if t o_address.end_with?(".invalid")
if @message.text_part if @message.text_part
if @message.text_part.body.to_s.blank? if @message.text_part.body.to_s.blank?
return skip(SkippedEmailLog.reason_types[:sender_text_part_body_blank] ) return skip(SkippedEmailLog.reason_types[:sender_text_part_body_blank] )
end end
else else
if @message.body.to_s.blank? if @message.body.to_s.blank?
skipping to change at line 224 skipping to change at line 232
begin begin
@message.deliver_now @message.deliver_now
rescue *SMTP_CLIENT_ERRORS => e rescue *SMTP_CLIENT_ERRORS => e
return skip(SkippedEmailLog.reason_types[:custom], custom_reason: e.mess age) return skip(SkippedEmailLog.reason_types[:custom], custom_reason: e.mess age)
end end
email_log.save! email_log.save!
email_log email_log
end end
def find_user
return @user if @user
User.find_by_email(to_address)
end
def to_address def to_address
@to_address ||= begin @to_address ||= begin
to = @message.try(:to) to = @message.try(:to)
to = to.first if Array === to to = to.first if Array === to
to.presence || "no_email_found" to.presence || "no_email_found"
end end
end end
def self.host_for(base_url) def self.host_for(base_url)
host = "localhost" host = "localhost"
 End of changes. 3 change blocks. 
2 lines changed or deleted 15 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)