use IO::File;
use IO::Scalar;
+use Debbugs::Text qw(:templates);
+
+use Debbugs::Mail qw(rfc822_date);
+
use POSIX qw(strftime);
-# These are a set of options which are common to all of these functions
+# These are a set of options which are common to all of these functions
my %common_options = (debug => {type => SCALARREF,
optional => 1,
}
if (not exists $param{message}) {
$action = $param{action} if exists $param{action};
- my $date = strftime "%a, %d %h %Y %T +0000", gmtime;
- $param{message} = <<END;
-Received: (at fakecontrol) by fakecontrolmessage;
-To: $param{request_addr}
-From: $param{requester}
-Subject: Internal Control
-Message-Id: $action
-Date: $date
-User-Agent: Fakemail v42.6.9
-
-# A New Hope
-# A log time ago, in a galaxy far, far away
-# something happened.
-#
-# Magically this resulted in the following
-# action being taken, but this fake control
-# message doesn't tell you why it happened
-#
-# The action:
-# $action
-thanks
-# This fakemail brought to you by your local debbugs
-# administrator
-END
+ my $date = rfc822_date();
+ $param{message} = fill_in_template(template => 'fake_control_message',
+ variables => {request_addr => $param{request_addr},
+ requester => $param{requester},
+ date => $date,
+ action => $action
+ },
+ );
}
return (action => $action,
%param);
use Debbugs::CGI qw(html_escape);
use Debbugs::Control qw(:archive :log);
use Debbugs::Log qw(:misc);
+use Debbugs::Text qw(:templates);
use Mail::RFC822::Address;
my $fuckheads = "(" . join("|", @gExcludeFromControl) . ")";
if (@gExcludeFromControl and $replyto =~ m/$fuckheads/) {
- &transcript("You have been specifically excluded from using the\ncontrol interface.\n\n");
- &transcript("Have a nice day\n\n.");
+ &transcript(fill_template('excluded_from_control'));
$quickabort = 1;
}
$midix++;
}
+sub fill_template{
+ my ($template,$extra_var) = @_;
+ $extra_var ||={};
+ my $variables = {config => \%config,
+ defined($ref)?(ref => $ref):(),
+ defined($data)?(data => $data):(),
+ %{$extra_var},
+ };
+ my $hole_var = {'&bugurl' =>
+ sub{"$_[0]: ".
+ 'http://'.$config{cgi_domain}.'/'.
+ Debbugs::CGI::bug_url($_[0]);
+ }
+ };
+ return fill_in_template(template => $template,
+ variables => $variables,
+ hole_var => $hole_var,
+ );
+}
+
+=head2 message_body_template
+
+ message_body_template('mail/ack',{ref=>'foo'});
+
+Creates a message body using a template
+
+=cut
+
+sub message_body_template{
+ my ($template,$extra_var) = @_;
+ $extra_var ||={};
+ my $body = fill_template($template,$extra_var);
+ return fill_template('mail/message_body',
+ {%{$extra_var},
+ body => $body,
+ },
+ );
+}
+
sub sendhelp {
&sendtxthelpraw("bug-log-mailserver.txt","instructions for request\@$gEmailDomain");
&sendtxthelpraw("bug-maint-mailcontrol.txt","instructions for control\@$gEmailDomain")
--- /dev/null
+You have been specifically excluded from using the control interface.
+
+Have a nice day
--- /dev/null
+Received: (at fakecontrol) by fakecontrolmessage;
+To: {$request_addr}
+From: $requester
+Subject: Internal Control
+Message-Id: {$action}
+Date: {$date}
+User-Agent: Fakemail v42.6.9
+
+# A New Hope
+# A log time ago, in a galaxy far, far away
+# something happened.
+#
+# Magically this resulted in the following
+# action being taken, but this fake control
+# message doesn't tell you why it happened
+#
+# The action:
+# {$action}
+thanks
+# This fakemail brought to you by your local debbugs
+# administrator