[Bps-public-commit] rt-extension-rest2 branch, allow-updating-of-ticket-links, created. 1.07-1-gb2f5a8c

Craig Kaiser craig at bestpractical.com
Thu Mar 5 13:45:00 EST 2020


The branch, allow-updating-of-ticket-links has been created
        at  b2f5a8c24208c56ef34faeb5001de24badf10851 (commit)

- Log -----------------------------------------------------------------
commit b2f5a8c24208c56ef34faeb5001de24badf10851
Author: Craig Kaiser <craig at bestpractical.com>
Date:   Thu Jun 13 14:39:05 2019 -0400

    Allow updating of ticket links
    
    Use the 'AddLink' and 'DeleteLink' keys with a link
    'type' (MemberOf DependsOn RefersTo ect) key and a
    'base' key, this can be a ticket id or a link URL.

diff --git a/lib/RT/Extension/REST2/Resource/Record/Writable.pm b/lib/RT/Extension/REST2/Resource/Record/Writable.pm.orig
similarity index 100%
rename from lib/RT/Extension/REST2/Resource/Record/Writable.pm
rename to lib/RT/Extension/REST2/Resource/Record/Writable.pm.orig
diff --git a/lib/RT/Extension/REST2/Util.pm b/lib/RT/Extension/REST2/Util.pm
index e814c1c..1727724 100644
--- a/lib/RT/Extension/REST2/Util.pm
+++ b/lib/RT/Extension/REST2/Util.pm
@@ -145,6 +145,7 @@ sub deserialize_record {
     my $data   = shift;
 
     my $does_roles = $record->DOES("RT::Record::Role::Roles");
+    my $does_links = $record->DOES("RT::Record::Role::Links");
 
     # Sanitize input for the Perl API
     for my $field (sort keys %$data) {
@@ -152,6 +153,7 @@ sub deserialize_record {
 
         my $value = $data->{$field};
         next unless ref $value;
+
         if (looks_like_uid($value)) {
             # Deconstruct UIDs back into simple foreign key IDs, assuming it
             # points to the same record type (class).
@@ -167,6 +169,11 @@ sub deserialize_record {
             }
             $data->{$field} = \@members;
         }
+        elsif ( $does_links and ($field =~ /^(Add|Delete)Link$/ ) ) {
+            my @links = ref $value eq 'ARRAY'
+                ? @$value : $value;
+            $data->{$field} = \@links;
+        }
         else {
             RT->Logger->debug("Received unknown value via JSON for field $field: ".ref($value));
             delete $data->{$field};

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


More information about the Bps-public-commit mailing list