Merge branch 'master' into vdom

This commit is contained in:
Sam 2016-02-16 11:53:14 +11:00
commit 18d67851c0
5 changed files with 25 additions and 38 deletions

View file

@ -1041,16 +1041,3 @@ and (max-width : 767px) {
} }
} }
@media all
and (max-height: 700px) {
.post-menu-area {
margin-bottom: 0px;
margin-top: -18px;
}
.topic-body {
padding: 5px 11px 2px;
}
}

View file

@ -63,7 +63,7 @@ module Jobs
# Markdown reference - [x]: http:// # Markdown reference - [x]: http://
raw.gsub!(/\[([^\]]+)\]:\s?#{escaped_src}/) { "[#{$1}]: #{url}" } raw.gsub!(/\[([^\]]+)\]:\s?#{escaped_src}/) { "[#{$1}]: #{url}" }
# Direct link # Direct link
raw.gsub!(/^#{escaped_src}\s?$/, "<img src='#{url}'>") raw.gsub!(/^#{escaped_src}(\s?)$/) { "<img src='#{url}'>#{$1}" }
end end
rescue => e rescue => e
Rails.logger.info("Failed to pull hotlinked image: #{src} post:#{post_id}\n" + e.message + "\n" + e.backtrace.join("\n")) Rails.logger.info("Failed to pull hotlinked image: #{src} post:#{post_id}\n" + e.message + "\n" + e.backtrace.join("\n"))

View file

@ -6,19 +6,20 @@ module Jobs
class UserEmail < Jobs::Base class UserEmail < Jobs::Base
def execute(args) def execute(args)
notification, post = nil
raise Discourse::InvalidParameters.new(:user_id) unless args[:user_id].present? raise Discourse::InvalidParameters.new(:user_id) unless args[:user_id].present?
raise Discourse::InvalidParameters.new(:type) unless args[:type].present? raise Discourse::InvalidParameters.new(:type) unless args[:type].present?
post = nil
notification = nil
type = args[:type] type = args[:type]
user = User.find_by(id: args[:user_id]) user = User.find_by(id: args[:user_id])
to_address = args[:to_address].presence || user.try(:email).presence || "no_email_found"
set_skip_context(type, args[:user_id], to_address)
set_skip_context(type, args[:user_id], args[:to_address].presence || user.try(:email).presence || "no_email_found")
return skip(I18n.t("email_log.no_user", user_id: args[:user_id])) unless user return skip(I18n.t("email_log.no_user", user_id: args[:user_id])) unless user
if args[:post_id] if args[:post_id].present?
post = Post.find_by(id: args[:post_id]) post = Post.find_by(id: args[:post_id])
return skip(I18n.t('email_log.post_not_found', post_id: args[:post_id])) unless post.present? return skip(I18n.t('email_log.post_not_found', post_id: args[:post_id])) unless post.present?
end end
@ -27,18 +28,17 @@ module Jobs
notification = Notification.find_by(id: args[:notification_id]) notification = Notification.find_by(id: args[:notification_id])
end end
message, skip_reason = message_for_email( user, message, skip_reason = message_for_email(user,
post, post,
type, type,
notification, notification,
args[:notification_type], args[:notification_type],
args[:notification_data_hash], args[:notification_data_hash],
args[:email_token], args[:email_token],
args[:to_address] ) args[:to_address])
if message if message
Email::Sender.new(message, args[:type], user).send Email::Sender.new(message, type, user).send
else else
skip_reason skip_reason
end end
@ -51,8 +51,8 @@ module Jobs
NOTIFICATIONS_SENT_BY_MAILING_LIST ||= Set.new %w{posted replied mentioned group_mentioned quoted} NOTIFICATIONS_SENT_BY_MAILING_LIST ||= Set.new %w{posted replied mentioned group_mentioned quoted}
def message_for_email(user, post, type, notification, def message_for_email(user, post, type, notification,
notification_type=nil, notification_data_hash=nil, notification_type=nil, notification_data_hash=nil,
email_token=nil, to_address=nil) email_token=nil, to_address=nil)
set_skip_context(type, user.id, to_address || user.email) set_skip_context(type, user.id, to_address || user.email)
@ -75,7 +75,7 @@ module Jobs
end end
if notification || notification_type if notification || notification_type
email_args[:notification_type] ||= notification_type || notification.try(:notification_type) email_args[:notification_type] ||= notification_type || notification.try(:notification_type)
email_args[:notification_data_hash] ||= notification_data_hash || notification.try(:data_hash) email_args[:notification_data_hash] ||= notification_data_hash || notification.try(:data_hash)
unless String === email_args[:notification_type] unless String === email_args[:notification_type]
@ -113,7 +113,7 @@ module Jobs
# Update the to address if we have a custom one # Update the to address if we have a custom one
if message && to_address.present? if message && to_address.present?
message.to = [to_address] message.to = to_address
end end
[message, nil] [message, nil]
@ -143,7 +143,7 @@ module Jobs
to_address: @skip_context[:to_address], to_address: @skip_context[:to_address],
user_id: @skip_context[:user_id], user_id: @skip_context[:user_id],
skipped: true, skipped: true,
skipped_reason: reason, skipped_reason: "[UserEmail] #{reason}",
) )
end end

View file

@ -81,7 +81,7 @@ class DiscourseSingleSignOn < SingleSignOn
private private
def match_email_or_create_user(ip_address) def match_email_or_create_user(ip_address)
user = User.find_by_email(email) user = User.find_by(email: email)
try_name = name.blank? ? nil : name try_name = name.blank? ? nil : name
try_username = username.blank? ? nil : username try_username = username.blank? ? nil : username

View file

@ -23,7 +23,7 @@ module Email
def send def send
return if SiteSetting.disable_emails return if SiteSetting.disable_emails
return skip(I18n.t('email_log.message_blank')) if @message.blank? return skip(I18n.t('email_log.message_blank')) if @message.blank?
return skip(I18n.t('email_log.message_to_blank')) if @message.to.blank? return skip(I18n.t('email_log.message_to_blank')) if @message.to.blank?
if @message.text_part if @message.text_part
@ -135,7 +135,7 @@ module Email
def to_address def to_address
@to_address ||= begin @to_address ||= begin
to = @message ? @message.to : nil 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
@ -167,7 +167,7 @@ module Email
to_address: to_address, to_address: to_address,
user_id: @user.try(:id), user_id: @user.try(:id),
skipped: true, skipped: true,
skipped_reason: reason skipped_reason: "[Sender] #{reason}"
) )
end end