mirror of
https://github.com/discourse/discourse.git
synced 2025-09-05 08:59:27 +08:00
new hidden 'allow_staged_accounts' setting
This commit is contained in:
parent
09bfe49254
commit
0d54c18c8b
11 changed files with 94 additions and 159 deletions
|
@ -59,13 +59,17 @@ module Email
|
|||
return unless html_override = @opts[:html_override]
|
||||
|
||||
if @opts[:add_unsubscribe_link]
|
||||
if response_instructions = @template_args[:respond_instructions]
|
||||
respond_instructions = PrettyText.cook(response_instructions).html_safe
|
||||
html_override.gsub!("%{respond_instructions}", respond_instructions)
|
||||
end
|
||||
|
||||
unsubscribe_link = PrettyText.cook(I18n.t('unsubscribe_link', template_args)).html_safe
|
||||
html_override.gsub!("%{unsubscribe_link}", unsubscribe_link)
|
||||
else
|
||||
html_override.gsub!("%{unsubscribe_link}", "")
|
||||
end
|
||||
|
||||
if response_instructions = @template_args[:respond_instructions]
|
||||
respond_instructions = PrettyText.cook(response_instructions).html_safe
|
||||
html_override.gsub!("%{respond_instructions}", respond_instructions)
|
||||
else
|
||||
html_override.gsub!("%{respond_instructions}", "")
|
||||
end
|
||||
|
||||
styled = Email::Styles.new(html_override, @opts)
|
||||
|
|
|
@ -58,12 +58,17 @@ module Email
|
|||
|
||||
user_email = @message.from.first
|
||||
@user = User.find_by_email(user_email)
|
||||
if @user.blank? && @allow_strangers
|
||||
|
||||
wrap_body_in_quote user_email
|
||||
# TODO This is WRONG it should register an account
|
||||
# and email the user details on how to log in / activate
|
||||
@user = Discourse.system_user
|
||||
# create staged account when user doesn't exist
|
||||
if @user.blank? && @allow_strangers
|
||||
if SiteSetting.allow_staged_accounts
|
||||
username = UserNameSuggester.suggest(user_email)
|
||||
name = User.suggest_name(user_email)
|
||||
@user = User.create(email: user_email, username: username, name: name, staged: true)
|
||||
else
|
||||
wrap_body_in_quote(user_email)
|
||||
@user = Discourse.system_user
|
||||
end
|
||||
end
|
||||
|
||||
raise UserNotFoundError if @user.blank?
|
||||
|
@ -196,14 +201,12 @@ module Email
|
|||
lines[range_start..range_end].join.strip
|
||||
end
|
||||
|
||||
def wrap_body_in_quote(user_email)
|
||||
@body = "[quote=\"#{user_email}\"]
|
||||
#{@body}
|
||||
[/quote]"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def wrap_body_in_quote(user_email)
|
||||
@body = "[quote=\"#{user_email}\"]\n#{@body}\n[/quote]"
|
||||
end
|
||||
|
||||
def create_reply
|
||||
create_post_with_attachments(@email_log.user,
|
||||
raw: @body,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue