summaryrefslogtreecommitdiffstats
path: root/app/models/mail_handler.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/mail_handler.rb')
-rw-r--r--app/models/mail_handler.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/app/models/mail_handler.rb b/app/models/mail_handler.rb
index 0e07f1069..f85b50d73 100644
--- a/app/models/mail_handler.rb
+++ b/app/models/mail_handler.rb
@@ -97,6 +97,7 @@ class MailHandler < ActionMailer::Base
if logger && logger.info
logger.info "MailHandler: [#{@user.login}] account created"
end
+ add_user_to_group(@@handler_options[:default_group])
Mailer.account_information(@user, @user.password).deliver
else
if logger && logger.error
@@ -463,6 +464,19 @@ class MailHandler < ActionMailer::Base
end
end
+ # Adds the newly created user to default group
+ def add_user_to_group(default_group)
+ if default_group.present?
+ default_group.split(',').each do |group_name|
+ if group = Group.named(group_name).first
+ group.users << @user
+ elsif logger
+ logger.warn "MailHandler: could not add user to [#{group_name}], group not found"
+ end
+ end
+ end
+ end
+
# Removes the email body of text after the truncation configurations.
def cleanup_body(body)
delimiters = Setting.mail_handler_body_delimiters.to_s.split(/[\r\n]+/).reject(&:blank?).map {|s| Regexp.escape(s)}