[Rt-commit] rt branch, 4.0/interface-in-headers, created. rt-4.0.6-233-g9189e69

Alex Vandiver alexmv at bestpractical.com
Fri Jun 29 19:31:41 EDT 2012


The branch, 4.0/interface-in-headers has been created
        at  9189e6989c6a78aa52b024e0027be2e04217aeb6 (commit)

- Log -----------------------------------------------------------------
commit 9189e6989c6a78aa52b024e0027be2e04217aeb6
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Thu Jun 28 20:42:51 2012 -0400

    Encode the interface (Email/Web/Mobile/REST) that content came from
    
    While examining the presence of the Recieved header was often used as a
    stand-in for knowing if a transaction was initiated via email or not, it
    is simpler to record the interface explicitly.  Store one of four values
    in the X-RT-Interface MIME header: Email, Web, Mobile, or REST,
    depending on the endpoint of the request that created the MIME object.

diff --git a/lib/RT/Interface/Email.pm b/lib/RT/Interface/Email.pm
index 8f38d99..784516b 100644
--- a/lib/RT/Interface/Email.pm
+++ b/lib/RT/Interface/Email.pm
@@ -1519,6 +1519,8 @@ sub Gateway {
             );
         }
 
+        $head->replace('X-RT-Interface' => 'Email');
+
         my ( $id, $Transaction, $ErrStr ) = $Ticket->Create(
             Queue     => $SystemQueueObj->Id,
             Subject   => $Subject,
diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 91c8ff2..8e209a4 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -1588,6 +1588,7 @@ sub CreateTicket {
         Cc      => $ARGS{'Cc'},
         Body    => $sigless,
         Type    => $ARGS{'ContentType'},
+        Interface => RT::Interface::Web::MobileClient() ? 'Mobile' : 'Web',
     );
 
     if ( $ARGS{'Attachments'} ) {
@@ -1807,6 +1808,7 @@ sub ProcessUpdateMessage {
         Subject => $args{ARGSRef}->{'UpdateSubject'},
         Body    => $args{ARGSRef}->{'UpdateContent'},
         Type    => $args{ARGSRef}->{'UpdateContentType'},
+        Interface => RT::Interface::Web::MobileClient() ? 'Mobile' : 'Web',
     );
 
     $Message->head->replace( 'Message-ID' => Encode::encode_utf8(
@@ -1937,11 +1939,13 @@ sub MakeMIMEEntity {
         Body                => undef,
         AttachmentFieldName => undef,
         Type                => undef,
+        Interface           => 'API',
         @_,
     );
     my $Message = MIME::Entity->build(
         Type    => 'multipart/mixed',
         "Message-Id" => Encode::encode_utf8( RT::Interface::Email::GenMessageId ),
+        "X-RT-Interface" => $args{Interface},
         map { $_ => Encode::encode_utf8( $args{ $_} ) }
             grep defined $args{$_}, qw(Subject From Cc)
     );
diff --git a/share/html/REST/1.0/Forms/ticket/comment b/share/html/REST/1.0/Forms/ticket/comment
index 35b543d..1baf38f 100755
--- a/share/html/REST/1.0/Forms/ticket/comment
+++ b/share/html/REST/1.0/Forms/ticket/comment
@@ -89,7 +89,10 @@ if (!$changes{Text} && @atts == 0) {
 }
 
 my $cgi = $m->cgi_object;
-my $ent = MIME::Entity->build(Type => "multipart/mixed");
+my $ent = MIME::Entity->build(
+    Type => "multipart/mixed",
+    'X-RT-Interface' => 'REST',
+);
 $ent->attach(Data => $changes{Text}) if $changes{Text};
 
 my $i = 1;
diff --git a/share/html/REST/1.0/Forms/ticket/default b/share/html/REST/1.0/Forms/ticket/default
index 032e6c9..6919938 100755
--- a/share/html/REST/1.0/Forms/ticket/default
+++ b/share/html/REST/1.0/Forms/ticket/default
@@ -188,7 +188,8 @@ else {
                 MIME::Entity->build(
                     From => $session{CurrentUser}->EmailAddress,
                     Subject => $v{Subject},
-                    Data => $text
+                    Data => $text,
+                    'X-RT-Interface' => 'REST',
                 );
         }
 
diff --git a/share/html/REST/1.0/ticket/comment b/share/html/REST/1.0/ticket/comment
index 768a468..bef2717 100755
--- a/share/html/REST/1.0/ticket/comment
+++ b/share/html/REST/1.0/ticket/comment
@@ -106,7 +106,10 @@ if (!$k->{Text} && @atts == 0) {
 }
 
 my $cgi = $m->cgi_object;
-my $ent = MIME::Entity->build(Type => "multipart/mixed");
+my $ent = MIME::Entity->build(
+    Type => "multipart/mixed",
+    'X-RT-Interface' => 'REST',
+);
 $ent->attach(Data => $k->{Text}) if $k->{Text};
 
 my $i = 1;

-----------------------------------------------------------------------


More information about the Rt-commit mailing list