Skip Menu |

This queue is for tickets about the RT-Extension-CommandByMail CPAN distribution.

Report information
The Basics
Id: 40480
Status: open
Priority: 0/
Queue: RT-Extension-CommandByMail

People
Owner: Nobody in particular
Requestors: btm [...] loftninjas.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Add option to redirect error emails
Date: Tue, 28 Oct 2008 18:55:17 -0700
To: bug-RT-Extension-CommandByMail [...] rt.cpan.org
From: "Bryan McLellan" <btm [...] loftninjas.org>
I wrote this patch a while ago [1] and keep coming back finding it useful. These modifications to TakeAction.pm allow you to configure where errors go. This is useful if you want to use command-by-mail, but don't want your users getting an obtuse error email if they start their email off with a link. (Or most recent was "WHAT:"). RT_SiteConfig.pm: Set($ErrorEmailAddress, 'noc@example.com'); diff TakeAction.pm.orig TakeAction.pm 663c663,668 < my $ErrorsTo = RT::Interface::Email::ParseErrorsToAddressFromHead( $args{'Message'}->head ); --- Show quoted text
> my $ErrorsTo = ''; > if ( defined( $RT::ErrorEmailAddress ) ) { > $ErrorsTo = $RT::ErrorEmailAddress; > } else { > $ErrorsTo = RT::Interface::Email::ParseErrorsToAddressFromHead( $args{'Message'}->head ); > }
[1] http://blog.loftninjas.org/?p=237
From: stefan [...] cae.wisc.edu
Here's an extended version of this patch which allows a toggle to be set in RT_SiteConfig.pm (Specifically Set($CommandByMailOnlyPrivileged, 1) ) This is based off of the 0.8_01 source. -stefan On Tue Oct 28 21:55:47 2008, btm@loftninjas.org wrote: Show quoted text
> I wrote this patch a while ago [1] and keep coming back finding it > useful. These modifications to TakeAction.pm allow you to configure > where errors go. This is useful if you want to use command-by-mail, > but don't want your users getting an obtuse error email if they start > their email off with a link. (Or most recent was "WHAT:"). > > RT_SiteConfig.pm: > Set($ErrorEmailAddress, 'noc@example.com'); > > diff TakeAction.pm.orig TakeAction.pm > 663c663,668 > < my $ErrorsTo = > RT::Interface::Email::ParseErrorsToAddressFromHead( > $args{'Message'}->head ); > ---
> > my $ErrorsTo = ''; > > if ( defined( $RT::ErrorEmailAddress ) ) { > > $ErrorsTo = $RT::ErrorEmailAddress; > > } else { > > $ErrorsTo =
> RT::Interface::Email::ParseErrorsToAddressFromHead( $args{'Message'}-
> >head ); > > }
> > [1] http://blog.loftninjas.org/?p=237
Subject: TakeActionPrivileged.diff
--- TakeActionVirgin.pm 2010-06-14 10:02:26.000021000 -0500 +++ TakeActionPrivileged.pm 2010-06-14 12:59:18.000038000 -0500 @@ -158,6 +158,17 @@ return ( $args{'CurrentUser'}, $args{'AuthLevel'} ); } + # If we have $RT::CommandByMailOnlyPrivileged set, then + # Non-privileged users can't use this extension. The main benefit + # here is they won't accidentally try to ("Guys: My computer is on + # fire!") and get errors. + if ($RT::CommandByMailOnlyPrivileged) { + unless ( $args{'CurrentUser'}->Privileged ) { + $RT::Logger->debug("Filter::TakeAction ignoring non-privileged user"); + return ( $args{'CurrentUser'}, $args{'AuthLevel'} ); + } + } + # If the user isn't asking for a comment or a correspond, # bail out unless ( $args{'Action'} =~ /^(?:comment|correspond)$/i ) {
From: stefan [...] cae.wisc.edu
Oops, too many tabs open. That was for a different patch. Here is the correct patch for this - This adds an option to e-mail users with errors if they are privileged while e-mailing to a generic address in the config file if they are unprivileged. The variables for RT_SiteConfig.pm are: CommandByMailErrorEmailAddress - set to the address you want to use for errors. CommandByMailErrorsToPrivileged - set to 1 if you want privileged users to get error e-mails while unprivileged users don't. The code could be shortened but is verbose for readability, and tested as working. Apologies for the incorrect patch in the first comment. -stefan On Mon Jun 14 14:10:17 2010, shortspecialbus wrote: Show quoted text
> Here's an extended version of this patch which allows a toggle to be set > in RT_SiteConfig.pm (Specifically Set($CommandByMailOnlyPrivileged, 1) ) > > This is based off of the 0.8_01 source. > > -stefan > > On Tue Oct 28 21:55:47 2008, btm@loftninjas.org wrote:
> > I wrote this patch a while ago [1] and keep coming back finding it > > useful. These modifications to TakeAction.pm allow you to configure > > where errors go. This is useful if you want to use command-by-mail, > > but don't want your users getting an obtuse error email if they start > > their email off with a link. (Or most recent was "WHAT:"). > > > > RT_SiteConfig.pm: > > Set($ErrorEmailAddress, 'noc@example.com'); > > > > diff TakeAction.pm.orig TakeAction.pm > > 663c663,668 > > < my $ErrorsTo = > > RT::Interface::Email::ParseErrorsToAddressFromHead( > > $args{'Message'}->head ); > > ---
> > > my $ErrorsTo = ''; > > > if ( defined( $RT::ErrorEmailAddress ) ) { > > > $ErrorsTo = $RT::ErrorEmailAddress; > > > } else { > > > $ErrorsTo =
> > RT::Interface::Email::ParseErrorsToAddressFromHead( $args{'Message'}-
> > >head ); > > > }
> > > > [1] http://blog.loftninjas.org/?p=237
> >
Subject: ErrorsToAddress.diff
--- TakeAction.pm.orig 2010-06-14 13:11:53.000049000 -0500 +++ TakeAction.pm 2010-06-14 13:13:21.000038000 -0500 @@ -694,7 +694,19 @@ return unless $msg && $msg !~ /^\s*$/; $RT::Logger->warning( $msg ); + # default to mailing the user for errors my $ErrorsTo = RT::Interface::Email::ParseErrorsToAddressFromHead( $args{'Message'}->head ); + if (defined ( $RT::CommandByMailErrorEmailAddress ) ) { + # If we want to mail privileged users their errors and the current + # user is privileged, mail it to them instead of the error address + if ( (defined($RT::CommandByMailErrorsToPrivileged)) && + ($args{'CurrentUser'}->Privileged) ) { + $ErrorsTo = RT::Interface::Email::ParseErrorsToAddressFromHead( $args{'Message'}->head ); + } else { + # We want to mail a generic address + $ErrorsTo = $RT::CommandByMailErrorEmailAddress; + } + } RT::Interface::Email::MailError( To => $ErrorsTo, Subject => "Extended mailgate error",