[rt-commit] [svn] r538 - rt/trunk/lib/RT
jesse at fsck.com
jesse at fsck.com
Wed Mar 10 19:16:50 EST 2004
Author: jesse
Date: Wed Mar 10 19:16:49 2004
New Revision: 538
Modified:
rt/trunk/lib/RT/EmailParser.pm
Log:
Removing unused code
Modified: rt/trunk/lib/RT/EmailParser.pm
==============================================================================
--- rt/trunk/lib/RT/EmailParser.pm (original)
+++ rt/trunk/lib/RT/EmailParser.pm Wed Mar 10 19:16:49 2004
@@ -295,205 +295,6 @@
# }}}
-# {{{ sub MailError
-
-=head2 MailError { }
-
-
-# TODO this doesn't belong here.
-# TODO doc this
-
-
-=cut
-
-
-sub MailError {
- my $self = shift;
-
- my %args = (
- To => $RT::OwnerEmail,
- Bcc => undef,
- From => $RT::CorrespondAddress,
- Subject => 'There has been an error',
- Explanation => 'Unexplained error',
- MIMEObj => undef,
- LogLevel => 'crit',
- @_
- );
-
- $RT::Logger->log(
- level => $args{'LogLevel'},
- message => $args{'Explanation'}
- );
- my $entity = MIME::Entity->build(
- Type => "multipart/mixed",
- From => $args{'From'},
- Bcc => $args{'Bcc'},
- To => $args{'To'},
- Subject => $args{'Subject'},
- 'X-RT-Loop-Prevention' => $RT::rtname,
- );
-
- $entity->attach( Data => $args{'Explanation'} . "\n" );
-
- my $mimeobj = $args{'MIMEObj'};
- $mimeobj->sync_headers();
- $entity->add_part($mimeobj);
-
- if ( $RT::MailCommand eq 'sendmailpipe' ) {
- open( MAIL, "|$RT::SendmailPath $RT::SendmailArguments" ) || return (0);
- print MAIL $entity->as_string;
- close(MAIL);
- }
- else {
- $entity->send( $RT::MailCommand, $RT::MailParams );
- }
-}
-
-# }}}
-
-
-
-# {{{ sub GetCurrentUser
-
-sub GetCurrentUser {
- my $self = shift;
- my $ErrorsTo = shift;
-
- my %UserInfo = ();
-
- #Suck the address of the sender out of the header
- my ( $Address, $Name ) = $self->ParseSenderAddressFromHead();
-
- my $tempuser = RT::User->new($RT::SystemUser);
-
- #This will apply local address canonicalization rules
- $Address = $tempuser->CanonicalizeEmailAddress($Address);
-
- #If desired, synchronize with an external database
- my $UserFoundInExternalDatabase = 0;
-
- # Username is the 'Name' attribute of the user that RT uses for things
- # like authentication
- my $Username = undef;
- ( $UserFoundInExternalDatabase, %UserInfo ) =
- $self->LookupExternalUserInfo( $Address, $Name );
-
- $Address = $UserInfo{'EmailAddress'};
- $Username = $UserInfo{'Name'};
-
- #Get us a currentuser object to work with.
- my $CurrentUser = RT::CurrentUser->new();
-
- # First try looking up by a username, if we got one from the external
- # db lookup. Next, try looking up by email address. Failing that,
- # try looking up by users who have this user's email address as their
- # username.
-
- if ($Username) {
- $CurrentUser->LoadByName($Username);
- }
-
- unless ( $CurrentUser->Id ) {
- $CurrentUser->LoadByEmail($Address);
- }
-
- #If we can't get it by email address, try by name.
- unless ( $CurrentUser->Id ) {
- $CurrentUser->LoadByName($Address);
- }
-
- unless ( $CurrentUser->Id ) {
-
- #If we couldn't load a user, determine whether to create a user
-
- # {{{ If we require an incoming address to be found in the external
- # user database, reject the incoming message appropriately
- if ( $RT::SenderMustExistInExternalDatabase
- && !$UserFoundInExternalDatabase ) {
-
- my $Message =
- "Sender's email address was not found in the user database.";
-
- # {{{ This code useful only if you've defined an AutoRejectRequest template
-
- require RT::Template;
- my $template = new RT::Template($RT::Nobody);
- $template->Load('AutoRejectRequest');
- $Message = $template->Content || $Message;
-
- # }}}
-
- MailError(
- To => $ErrorsTo,
- Subject => "Ticket Creation failed: user could not be created",
- Explanation => $Message,
- MIMEObj => $self->Entity,
- LogLevel => 'notice' );
-
- return ($CurrentUser);
-
- }
-
- # }}}
-
- else {
- my $NewUser = RT::User->new($RT::SystemUser);
-
- my ( $Val, $Message ) = $NewUser->Create(
- Name => ( $Username || $Address ),
- EmailAddress => $Address,
- RealName => "$Name",
- Password => undef,
- Privileged => 0,
- Comments => 'Autocreated on ticket submission'
- );
-
- unless ($Val) {
-
- # Deal with the race condition of two account creations at once
- #
- if ($Username) {
- $NewUser->LoadByName($Username);
- }
-
- unless ( $NewUser->Id ) {
- $NewUser->LoadByEmail($Address);
- }
-
- unless ( $NewUser->Id ) {
- MailError(To => $ErrorsTo,
- Subject => "User could not be created",
- Explanation =>
- "User creation failed in mailgateway: $Message",
- MIMEObj => $self->Entity,
- LogLevel => 'crit' );
- }
- }
- }
-
- #Load the new user object
- $CurrentUser->LoadByEmail($Address);
-
- unless ( $CurrentUser->id ) {
- $RT::Logger->warning(
- "Couldn't load user '$Address'." . "giving up" );
- MailError(
- To => $ErrorsTo,
- Subject => "User could not be loaded",
- Explanation =>
- "User '$Address' could not be loaded in the mail gateway",
- MIMEObj => $self->Entity,
- LogLevel => 'crit' );
-
- }
- }
-
- return ($CurrentUser);
-
-}
-
-# }}}
# {{{ ParseCcAddressesFromHead
More information about the Rt-commit
mailing list