From c47817d2d9271f82387ac8ab68b06f783472b4b9 Mon Sep 17 00:00:00 2001 From: Rui Leite Date: Wed, 27 Oct 2021 11:27:21 +0100 Subject: [PATCH] Add 'Description' and 'MergedTickets' fields to Resource.pm --- lib/RT/REST2/Resource.pm | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/RT/REST2/Resource.pm b/lib/RT/REST2/Resource.pm index 777023404ca..79300dcf95c 100644 --- a/lib/RT/REST2/Resource.pm +++ b/lib/RT/REST2/Resource.pm @@ -110,6 +110,28 @@ sub expand_field { push @{ $result }, values %values if %values; } + } elsif ($field eq 'Description' && $item->isa('RT::Ticket')) { + my $transactions = $item->Transactions; + $transactions->Limit( + FIELD => 'Type', + VALUE => 'Create' + ); + if ($transactions->Count > 0) { + my $forceHtml = $self->request->param('forceHtml'); + my $content = undef; + if (!defined $forceHtml || $forceHtml eq '1' || $forceHtml eq 'True') { + $content = $transactions->First->Content('Type' => 'text/html'); + } else { + $content = $transactions->First->Content; + } + if (defined $content) { + $result = $content; + } + } + } elsif ($field eq 'MergedTickets' && $item->isa('RT::Ticket')) { + my $method = 'Merged'; + my @obj = $item->$method; + $result = \@obj; } elsif ($field eq 'ContentLength' && $item->can('ContentLength')) { $result = $item->ContentLength; } elsif ($field eq 'CustomRoles') {