Subject: | [PATCH] Read commands from headers, other patch integration |
We wanted commands to be able to be read from headers so as to be more
transparent to users. While the user-submitted patch to strip the
commands from the e-mail body was nice, it didn't work in all situations.
Here is a patch that allows commands to be read from headers. The
default header is X-RT-Do: although it can be changed by a configuration
option.
To enable, set $CommandByMailDoHeaders to 1 in RT_SiteConfig.pm
If you want to use a different header, for example X-RT-DoCommand or
something, you can set that with $CommandByMailHeaderString in the file.
If unset, it defaults to X-RT-Do:
This is based off of the 0.08_01 source. A second patch will follow in
a second message that integrates several patches, and is more robust.
-stefan
Subject: | ReadFromHeaders.diff |
--- TakeAction.pm.orig 2010-06-14 13:28:32.000104000 -0500
+++ TakeAction.pm 2010-06-14 13:31:27.000182000 -0500
@@ -196,6 +196,19 @@
}
}
+ if ($RT::Config->Get('CommandByMailDoHeaders')) {
+ my $header_string = RT::Config->Get('CommandByMailHeaderString');
+ $header_string = (defined($header_string)) ? $header_string : 'X-RT-Do';
+ # Read any X-RT-Do headers
+ my @command_headers = $args{'Message'}->get($header_string);
+
+ foreach my $cmd (@command_headers) {
+ # make sure they follow the correct format, if good, put it at front
+ next if $cmd !~ /^(?:(\S+(?:{.*})?)\s*?:\s*?(.*)\s*?|)$/;
+ unshift @content, $cmd;
+ }
+ }
+
my @items;
my $found_pseudoheaders = 0;
foreach my $line (@content) {