X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=rt%2Flib%2FRT%2FInterface%2FEmail%2FAuth%2FMailFrom.pm;h=96e94cc2d5843b9c02cd029b20acc8d3251a7d70;hp=a90306b67f8ecef1f945a1199d70b47abc2f14c5;hb=7322f2afedcc2f427e997d1535a503613a83f088;hpb=0fb307c305e4bc2c9c27dc25a3308beae3a4d33c diff --git a/rt/lib/RT/Interface/Email/Auth/MailFrom.pm b/rt/lib/RT/Interface/Email/Auth/MailFrom.pm index a90306b67..96e94cc2d 100644 --- a/rt/lib/RT/Interface/Email/Auth/MailFrom.pm +++ b/rt/lib/RT/Interface/Email/Auth/MailFrom.pm @@ -2,7 +2,7 @@ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2016 Best Practical Solutions, LLC # # # (Except where explicitly superseded by other copyright notices) @@ -47,6 +47,10 @@ # END BPS TAGGED BLOCK }}} package RT::Interface::Email::Auth::MailFrom; + +use strict; +use warnings; + use RT::Interface::Email qw(ParseSenderAddressFromHead CreateUser); # This is what the ordinary, non-enhanced gateway does at the moment. @@ -62,13 +66,16 @@ sub GetCurrentUser { # We don't need to do any external lookups - my ( $Address, $Name ) = ParseSenderAddressFromHead( $args{'Message'}->head ); + my ( $Address, $Name, @errors ) = ParseSenderAddressFromHead( $args{'Message'}->head ); + $RT::Logger->warning("Failed to parse ".join(', ', @errors)) + if @errors; + unless ( $Address ) { - $RT::Logger->error("Couldn't find sender's address"); + $RT::Logger->error("Couldn't parse or find sender's address"); return ( $args{'CurrentUser'}, -1 ); } - my $CurrentUser = new RT::CurrentUser; + my $CurrentUser = RT::CurrentUser->new; $CurrentUser->LoadByEmail( $Address ); $CurrentUser->LoadByName( $Address ) unless $CurrentUser->Id; if ( $CurrentUser->Id ) { @@ -77,14 +84,13 @@ sub GetCurrentUser { } # If the user can't be loaded, we may need to create one. Figure out the acl situation. - my $unpriv = RT::Group->new( $RT::SystemUser ); - $unpriv->LoadSystemInternalGroup('Unprivileged'); + my $unpriv = RT->UnprivilegedUsers(); unless ( $unpriv->Id ) { $RT::Logger->crit("Couldn't find the 'Unprivileged' internal group"); return ( $args{'CurrentUser'}, -1 ); } - my $everyone = RT::Group->new( $RT::SystemUser ); + my $everyone = RT::Group->new( RT->SystemUser ); $everyone->LoadSystemInternalGroup('Everyone'); unless ( $everyone->Id ) { $RT::Logger->crit("Couldn't find the 'Everyone' internal group"); @@ -174,9 +180,6 @@ sub GetCurrentUser { return ( $CurrentUser, 1 ); } -eval "require RT::Interface::Email::Auth::MailFrom_Vendor"; -die $@ if ($@ && $@ !~ qr{^Can't locate RT/Interface/Email/Auth/MailFrom_Vendor.pm}); -eval "require RT::Interface::Email::Auth::MailFrom_Local"; -die $@ if ($@ && $@ !~ qr{^Can't locate RT/Interface/Email/Auth/MailFrom_Local.pm}); +RT::Base->_ImportOverlays(); 1;