module Redwood
class ReplyMode < EditMessageMode
- REPLY_TYPES = [:sender, :list, :all, :user]
+ REPLY_TYPES = [:sender, :recipient, :list, :all, :user]
TYPE_DESCRIPTIONS = {
:sender => "Reply to sender",
+ :recipient => "Reply to recipient",
:all => "Reply to all",
:list => "Reply to mailing list",
:user => "Customized reply"
super 2, :twiddles => false
@m = message
+ ## it's important to put this early because it forces a read of
+ ## the full headers (most importantly the list-post header, if
+ ## any)
+ @body = reply_body_lines(message)
+
from =
if @m.recipient_email
AccountManager.account_for(@m.recipient_email)
@headers[:sender] = {
"From" => "#{from.name} <#{from_email}>",
"To" => [to.full_address],
- }
+ } unless AccountManager.is_account? to
+
+ @headers[:recipient] = {
+ "From" => "#{from.name} <#{from_email}>",
+ "To" => cc.map { |p| p.full_address },
+ } unless cc.empty?
@headers[:user] = {
"From" => "#{from.name} <#{from_email}>",
end
@type_labels = REPLY_TYPES.select { |t| @headers.member?(t) }
- @selected_type = @m.is_list_message? ? :list : :sender
+ @selected_type =
+ if @m.is_list_message?
+ :list
+ elsif @headers.member? :sender
+ :sender
+ else
+ :recipient
+ end
- @body = reply_body_lines(message) + sig_lines
regen_text
end
protected
- def body; @body; end
+ def body; @body + sig_lines; end
def header; @headers[@selected_type]; end
def reply_body_lines m
end
def regen_text
- @text = header_lines(@headers[@selected_type] - NON_EDITABLE_HEADERS) + [""] + @body
+ @text = header_lines(header - NON_EDITABLE_HEADERS) + [""] + body
end
def gen_references