]> git.donarmstrong.com Git - debbugs.git/commitdiff
* Start using the templates for control and the fake control message
authorDon Armstrong <don@donarmstrong.com>
Sun, 10 Feb 2008 22:17:40 +0000 (14:17 -0800)
committerDon Armstrong <don@donarmstrong.com>
Sun, 10 Feb 2008 22:17:40 +0000 (14:17 -0800)
Debbugs/Control.pm
scripts/service.in
templates/en_US/mail/excluded_from_control.tmpl [new file with mode: 0644]
templates/en_US/mail/fake_control_message.tmpl [new file with mode: 0644]

index c462b536604e4d7279af9bf594ee7573137e8e08..97e1e7f74a443a7700ba7d5327144cf891822280 100644 (file)
@@ -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} = <<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);
index 0cfe4f0f50757abab382d52f2526e1b2c1a8cd25..b766ce0e9d51f34d7399312a128694c20d5fd30e 100755 (executable)
@@ -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 (file)
index 0000000..adf10e4
--- /dev/null
@@ -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 (file)
index 0000000..beeaf3d
--- /dev/null
@@ -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