From: Don Armstrong Date: Sun, 10 Feb 2008 22:17:40 +0000 (-0800) Subject: * Start using the templates for control and the fake control message X-Git-Tag: release/2.6.0~510^2~3 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=9aba53759b7fc1ebc096f05be45b8fb3a65960e4;p=debbugs.git * Start using the templates for control and the fake control message --- diff --git a/Debbugs/Control.pm b/Debbugs/Control.pm index c462b53..97e1e7f 100644 --- a/Debbugs/Control.pm +++ b/Debbugs/Control.pm @@ -99,9 +99,13 @@ use File::Path qw(mkpath); 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, @@ -471,30 +475,14 @@ sub __return_append_to_log_options{ } if (not exists $param{message}) { $action = $param{action} if exists $param{action}; - my $date = strftime "%a, %d %h %Y %T +0000", gmtime; - $param{message} = < 'fake_control_message', + variables => {request_addr => $param{request_addr}, + requester => $param{requester}, + date => $date, + action => $action + }, + ); } return (action => $action, %param); diff --git a/scripts/service.in b/scripts/service.in index 0cfe4f0..b766ce0 100755 --- a/scripts/service.in +++ b/scripts/service.in @@ -16,6 +16,7 @@ use Debbugs::Config qw(:globals :config); 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; @@ -152,8 +153,7 @@ my $quickabort = 0; 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; } @@ -1353,6 +1353,45 @@ sub sendmailmessage { $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") diff --git a/templates/en_US/mail/excluded_from_control.tmpl b/templates/en_US/mail/excluded_from_control.tmpl new file mode 100644 index 0000000..adf10e4 --- /dev/null +++ b/templates/en_US/mail/excluded_from_control.tmpl @@ -0,0 +1,3 @@ +You have been specifically excluded from using the control interface. + +Have a nice day diff --git a/templates/en_US/mail/fake_control_message.tmpl b/templates/en_US/mail/fake_control_message.tmpl new file mode 100644 index 0000000..beeaf3d --- /dev/null +++ b/templates/en_US/mail/fake_control_message.tmpl @@ -0,0 +1,21 @@ +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