Everybody group added as requestor


#1

Hello,

I’ve been writing a Perl Catalyst application that uses the RT library to
create, work on and resolve RT tickets. I’m making a call to
RT::Ticket->create
to create a ticket, passing the Queue, Subject, Requestors, Attachments in a
hash.

Yesterday, when the form was submitted with a user’s email address as the
requestor, the Everybody group got added as the requestor for the ticket
that got created. I checked the transactions and found that no AddRequestor
transaction happened on the ticket, from which I deduce that the Everybody
group got added as requestor during ticket creation.

Anyone has any idea how this could have happened?

Regards,
Terence Monteiro.


#2

Hello,

I’ve been writing a Perl Catalyst application that uses the RT
library to
create, work on and resolve RT tickets. I’m making a call to
RT::Ticket->create
to create a ticket, passing the Queue, Subject, Requestors,
Attachments in a
hash.

Yesterday, when the form was submitted with a user’s email address
as the
requestor, the Everybody group got added as the requestor for the
ticket
that got created. I checked the transactions and found that no
AddRequestor
transaction happened on the ticket, from which I deduce that the
Everybody
group got added as requestor during ticket creation.

Anyone has any idea how this could have happened?

It’d probably help if you posted your code…

PGP.sig (186 Bytes)


#3

Jesse Vincent wrote:

Hello,

I’ve been writing a Perl Catalyst application that uses the RT
library to
create, work on and resolve RT tickets. I’m making a call to
RT::Ticket->create
to create a ticket, passing the Queue, Subject, Requestors,
Attachments in a
hash.

Yesterday, when the form was submitted with a user’s email address as
the
requestor, the Everybody group got added as the requestor for the ticket
that got created. I checked the transactions and found that no
AddRequestor
transaction happened on the ticket, from which I deduce that the
Everybody
group got added as requestor during ticket creation.

Anyone has any idea how this could have happened?

It’d probably help if you posted your code…

I’m calling the send action of the create controller,

package tirt::Controller::Create;
use base ‘Catalyst::Controller’;

sub send : Local {
# reads parameters and passes them to rthelper create
my ( $self, $c ) = @_;

my ( $Cc, $Subject, $Requestor, $Queue, $Priority, $ContentType, 

$Content ) =
map { $c->req->params->{$_} }
qw/cc subject requestor queue priority content_type
content/;

my ($id, $tid, $msg) = $c->forward('/rthelper/create_ticket', [
    Requestor => $Requestor,
    Cc => $Cc,
    Subject => $Subject,
    ContentType => $ContentType || 'text/html',
    Content => $Content,
    Queue => $Queue,
    Priority => $Priority,
    Attachments => $c->req->uploads ]); # calling RTHelper to create 

ticket

}

other actions


1;

package tirt::Controller::RTHelper;
use base ‘Catalyst::Controller’;

sub create_ticket : Local {
my $self = shift;
my $c = shift;

my %tkt_fields = ( @_ ); # the hash for arguments to RT::Ticket->create

my $starts = RT::Date->new($c->session->{CurrentUser});
$starts->SetToNow();
$tkt_fields{Starts} = $starts;

my $html = $tkt_fields{Content};
delete $tkt_fields{Content};

my $attachments = $tkt_fields{Attachments};
delete $tkt_fields{Attachments};

my $ctype = $tkt_fields{ContentType};
delete $tkt_fields{ContentType};

my $ent = $c->forward( '__make_mimeobj', [ $ctype,
    $html, $attachments ] );

$tkt_fields{MIMEObj} = $ent;

my $ticket = RT::Ticket->new($c->session->{CurrentUser});
return $ticket->Create(%tkt_fields);

}

sub __make_mimeobj : Private {
my ( $self, $c, $ctype, $content, $attachments ) = @_;

my $msg;
if ( $ctype =~ 'text/plain' ) {
    $msg = MIME::Entity->build(
        Type => 'text/plain',
        Data => $content);
} else {
    my $text = HTML::FormatText->new()->format(
        HTML::TreeBuilder->new_from_content($content));
    $msg = MIME::Entity->build(Type => "multipart/alternative");
    $msg->attach(Type => 'text/plain', Data => $text);
    $msg->attach(Type => 'text/html', Data => $content);
}

$c->log->debug("\$attachments = $attachments, values " .
    join (", ", values(%$attachments)));
unless ($attachments and values(%$attachments)) {
    return $msg;
}

my $ent;
if ($msg->mime_type =~ m/^multipart/) {
    $ent = MIME::Entity->build(Type => "multipart/mixed");
    $ent->add_part($msg);
} else {
    $ent = $msg;
}

foreach my $attach (values(%$attachments)) {
    $ent->attach(
        Type => $attach->type,
        Data => $attach->slurp,
        Filename => $attach->basename,
        Disposition => 'attachment'
    );
}

return $ent;

}

other actions …

1;


#4

Terence Monteiro wrote:

Hello,

I’ve been writing a Perl Catalyst application that uses the RT library to
create, work on and resolve RT tickets. I’m making a call to
RT::Ticket->create
to create a ticket, passing the Queue, Subject, Requestors, Attachments in a
hash.

I’m using RT version 3.6.1-4 installed from the debian package, and mysql
version 5.0.32-7etch1 installed again from the debian package. I’ve not
added
any overlay/vendor/local overlays for the RT::Ticket module. But I’m
using the
User_Local.pm and CurrentUser_Local.pm module overlays for auto create and
canonicalize user info for LDAP posted by Philip Cole on your wiki at
http://wiki.bestpractical.com/view/AutoCreateAndCanonicalizeUserInfo


#5

Terence Monteiro wrote:

Hello,

I’ve been writing a Perl Catalyst application that uses the RT library to
create, work on and resolve RT tickets. I’m making a call to
RT::Ticket->create
to create a ticket, passing the Queue, Subject, Requestors, Attachments in a
hash.

Yesterday, when the form was submitted with a user’s email address as the
requestor, the Everybody group got added as the requestor for the ticket
that got created. I checked the transactions and found that no AddRequestor
transaction happened on the ticket, from which I deduce that the Everybody
group got added as requestor during ticket creation.

I confirmed this by checking the RT database. I queried the MemberIds
obtained
from joining the GroupMembers and Groups tables on the GroupMembers
GroupId = Groups id for Instance = <ticket_id> and Type = ‘Requestor’. I
got the PrincipalId of the Everybody group as a result.

Does RT library have problems if more than 1 Perl application uses the
API? If I wrote a perl script which used the RT API and tried to modify the
database, will it yield unexpected results? Is the scope of all data
structures
used by RT to create tickets local to the subroutine that does the creation?

Regards,
Terence Monteiro.