Feature #13340 ยป mail_handler.patch
app/models/group.rb | ||
---|---|---|
78 | 78 |
super(attr_name, *args) |
79 | 79 |
end |
80 | 80 | |
81 |
def self.find_by_name(name) |
|
82 |
where("lastname = ? AND type = 'Group'", name).first if !name.nil? |
|
83 |
end |
|
84 | ||
81 | 85 |
private |
82 | 86 | |
83 | 87 |
# Removes references that are not handled by associations |
app/models/mail_handler.rb | ||
---|---|---|
97 | 97 |
if logger && logger.info |
98 | 98 |
logger.info "MailHandler: [#{@user.login}] account created" |
99 | 99 |
end |
100 |
group = Group.find_by_name(@@handler_options[:default_group]) |
|
101 |
if group |
|
102 |
group.users << @user |
|
103 |
if logger && logger.info |
|
104 |
logger.info "MailHandler: [#{@user.login}] added to group [#{group.name}]" |
|
105 |
end |
|
106 |
end |
|
107 | ||
100 | 108 |
Mailer.account_information(@user, @user.password).deliver |
101 | 109 |
else |
102 | 110 |
if logger && logger.error |
extra/mail_handler/rdm-mailhandler.rb | ||
---|---|---|
25 | 25 |
class RedmineMailHandler |
26 | 26 |
VERSION = '0.2.1' |
27 | 27 | |
28 |
attr_accessor :verbose, :issue_attributes, :allow_override, :unknown_user, :no_permission_check, :url, :key, :no_check_certificate |
|
28 |
attr_accessor :verbose, :issue_attributes, :allow_override, :unknown_user, :default_group, :no_permission_check, :url, :key, :no_check_certificate
|
|
29 | 29 | |
30 | 30 |
def initialize |
31 | 31 |
self.issue_attributes = {} |
... | ... | |
45 | 45 |
"* ignore: email is ignored (default)", |
46 | 46 |
"* accept: accept as anonymous user", |
47 | 47 |
"* create: create a user account") {|v| self.unknown_user = v} |
48 |
opts.on("--default-group GROUP", "add created user to this group (none by default)") { |v| self.default_group = v} |
|
48 | 49 |
opts.on("--no-permission-check", "disable permission checking when receiving", |
49 | 50 |
"the email") {self.no_permission_check = '1'} |
50 | 51 |
opts.on("--key-file FILE", "path to a file that contains the Redmine", |
... | ... | |
95 | 96 |
data = { 'key' => key, 'email' => email, |
96 | 97 |
'allow_override' => allow_override, |
97 | 98 |
'unknown_user' => unknown_user, |
99 |
'default_group' => default_group, |
|
98 | 100 |
'no_permission_check' => no_permission_check} |
99 | 101 |
issue_attributes.each { |attr, value| data["issue[#{attr}]"] = value } |
100 | 102 |