Recognize tickets created via email or via web

I have a custom scrip where I want to distinguish whether the ticket was
created via email or via web.

Now I am looking at ther “Received:” header of the first attachment of
the first transaction of the ticket:

my $web;
my $transactions=$self->TicketObj->Transactions;
my $tr = $transactions->Next;
my $attachments = $tr->Attachments;
my $a = $attachments->Next;
if ($a->GetHeader(“Received”)){
$web=0;
} else {
$web=1;
}

This apparently works and has insofar not misclassified, but seems quite
ugly to me. For example, future versions of RT could add a “Received:”
with the IP address where the web connection came from (many webmails do
that). I didn’t even try with a ticket created via CLI.

Can anyone suggest a better and future-proof approach?

Regards,
Bergonz

Ing. Michele Bergonzoni - Laboratori Guglielmo Marconi S.p.a.
Phone:+39-051-6781926 e-mail: bergonz@labs.it
alt.advanced.networks.design.configure.operate

I have a custom scrip where I want to distinguish whether the ticket was
created via email or via web.

Now I am looking at ther “Received:” header of the first attachment of
the first transaction of the ticket:

[…]

This apparently works and has insofar not misclassified, but seems quite
ugly to me. For example, future versions of RT could add a “Received:”
with the IP address where the web connection came from (many webmails do
that). I didn’t even try with a ticket created via CLI.

Can anyone suggest a better and future-proof approach?

well that’s what I used to used since a long time and it still works :wink:

if you look at the transactions and attachments table, there is
currently no dedicated field/header set by RT to distinguish those
transactions. SO as of now, looking at the “Received” header looks the
best solution.

Easter-eggs Sp�cialiste GNU/Linux
44-46 rue de l’Ouest - 75014 Paris - France - M�tro Gait�
Phone: +33 (0) 1 43 35 00 37 - Fax: +33 (0) 1 43 35 00 76
mailto:elacour@easter-eggs.com - http://www.easter-eggs.com

I have a custom scrip where I want to distinguish whether the ticket was
created via email or via web.

Now I am looking at ther “Received:” header of the first attachment of
the first transaction of the ticket:
[…]

This apparently works and has insofar not misclassified, but seems quite
ugly to me. For example, future versions of RT could add a “Received:”
with the IP address where the web connection came from (many webmails do
that). I didn’t even try with a ticket created via CLI.

Can anyone suggest a better and future-proof approach?

well that’s what I used to used since a long time and it still works :wink:

if you look at the transactions and attachments table, there is
currently no dedicated field/header set by RT to distinguish those
transactions. SO as of now, looking at the “Received” header looks the
best solution.
Another option would be to modify RT::Interface::Email.pm and
RT::Interface::Web.pm to insert the desired header into the generated
message (in the case of Web.pm) or parsed email (in the case of
Email.pm). You could probably make a convincing case for such a patch to
be accepted into RT proper, at least for adding a header to Web.pm
generated messages; probably harder to argue modification of externally
originated mail for Email.pm.

Craig Ringer http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

Michele, if you upgrade to RT 4.0.9 you can use the X-RT-Interface
header. The potential values are Email, Web, Mobile, REST, and API.

Craig,

Another option would be to modify RT::Interface::Email.pm and
RT::Interface::Web.pm to insert the desired header into the generated
message (in the case of Web.pm) or parsed email (in the case of
Email.pm). You could probably make a convincing case for such a patch to
be accepted into RT proper…

This is exactly what we’ve done:

tom@whaam rt (4.0-trunk=) $ git ack ‘X-RT-Interface’
lib/RT/Interface/Email.pm
1567: $head->replace(‘X-RT-Interface’ => ‘Email’);

lib/RT/Interface/Web.pm
2077: “X-RT-Interface” => $args{Interface},
2121: $Message->head->delete(‘X-RT-Interface’);

lib/RT/Ticket.pm
2243: $args{‘MIMEObj’}->head->replace(‘X-RT-Interface’ => ‘API’)
2244: unless $args{‘MIMEObj’}->head->get(‘X-RT-Interface’);

share/html/REST/1.0/Forms/ticket/comment
95: ‘X-RT-Interface’ => ‘REST’,

share/html/REST/1.0/Forms/ticket/default
192: ‘X-RT-Interface’ => ‘REST’,

share/html/REST/1.0/ticket/comment
112: ‘X-RT-Interface’ => ‘REST’,

I have a custom scrip where I want to distinguish whether the ticket was
created via email or via web.

Now I am looking at ther “Received:” header of the first attachment of
the first transaction of the ticket:

my $web;
my $transactions=$self->TicketObj->Transactions;
my $tr = $transactions->Next;
my $attachments = $tr->Attachments;
my $a = $attachments->Next;
if ($a->GetHeader(“Received”)){
$web=0;
} else {
$web=1;
}

This apparently works and has insofar not misclassified, but seems quite
ugly to me. For example, future versions of RT could add a "Received:"
with the IP address where the web connection came from (many webmails do
that). I didn’t even try with a ticket created via CLI.

Can anyone suggest a better and future-proof approach?

Regards,
Bergonz

You have to look for the X-RT-Interface header (REST, API, Email, Web)
which was introduced with RT 4.0.9

Il 22/03/2013 17.48, Thomas Sibley wrote:

Michele, if you upgrade to RT 4.0.9 you can use the X-RT-Interface
header. The potential values are Email, Web, Mobile, REST, and API.

Many thanks to you and to other people who pointed this out privately,
this is exactly what I was looking for.

Regards,
Bergonz

Ing. Michele Bergonzoni - Laboratori Guglielmo Marconi S.p.a.
Phone:+39-051-6781926 e-mail: bergonz@labs.it
alt.advanced.networks.design.configure.operate