Feature #15141 ยป listserv.patch
| app/models/mail_handler.rb | ||
|---|---|---|
|
# Use when receiving emails with rake tasks
|
||
|
def self.extract_options_from_env(env)
|
||
|
options = {:issue => {}}
|
||
|
%w(project status tracker category priority).each do |option|
|
||
|
%w(project status tracker category priority board).each do |option|
|
||
|
options[:issue][option.to_sym] = env[option] if env[option]
|
||
|
end
|
||
|
%w(allow_override unknown_user no_permission_check no_account_notice default_group).each do |option|
|
||
| ... | ... | |
|
false
|
||
|
end
|
||
|
# If a board number is provided in the environment, new emails are messages to that
|
||
|
# board, rather than a new issue
|
||
|
def dispatch_to_default
|
||
|
receive_issue
|
||
|
if get_keyword(:board)
|
||
|
receive_message
|
||
|
else
|
||
|
receive_issue
|
||
|
end
|
||
|
end
|
||
|
# Creates a new issue
|
||
|
def receive_message
|
||
|
board = target_board
|
||
|
# check permission
|
||
|
unless @@handler_options[:no_permission_check]
|
||
|
raise UnauthorizedAction unless user.allowed_to?(:add_messages, board.project)
|
||
|
end
|
||
|
message = Message.new(:subject => cleaned_up_subject.gsub(%r{^.*msg\d+\]}, '').strip,
|
||
|
:content => cleaned_up_text_body)
|
||
|
message.author = user
|
||
|
message.board = board
|
||
|
message.save!
|
||
|
add_attachments(message)
|
||
|
logger.info "MailHandler: message ##{message.id} created by #{user}" if logger
|
||
|
message
|
||
|
end
|
||
|
# Creates a new issue
|
||
| ... | ... | |
|
keyword
|
||
|
end
|
||
|
def target_board
|
||
|
target = Board.find_by_id(get_keyword(:board))
|
||
|
if target.nil?
|
||
|
# Invalid board keyword, use the board specified as the default one
|
||
|
default_board = @@handler_options[:issue][:board]
|
||
|
if default_board.present?
|
||
|
target = Board.find_by_id(default_board)
|
||
|
end
|
||
|
end
|
||
|
raise MissingInformation.new('Unable to determine target board') if target.nil?
|
||
|
target
|
||
|
end
|
||
|
def target_project
|
||
|
# TODO: other ways to specify project:
|
||
|
# * parse the email To field
|
||
| app/views/mailer/message_posted.text.erb | ||
|---|---|---|
|
<%= @message_url %>
|
||
|
<%= @message.author %>
|
||
|
<%= @message.content %>
|
||
| lib/tasks/email.rake | ||
|---|---|---|
|
Issue attributes control options:
|
||
|
project=PROJECT identifier of the target project
|
||
|
board=BOARD_ID identifier of the board unknown input goes to
|
||
|
status=STATUS name of the target status
|
||
|
tracker=TRACKER name of the target tracker
|
||
|
category=CATEGORY name of the target category
|
||