[Bps-public-commit] rt-extension-rest2 branch, add-validation-hook-for-status-updates, repushed

Jim Brandt jbrandt at bestpractical.com
Wed Dec 23 16:14:41 EST 2020


The branch add-validation-hook-for-status-updates was deleted and repushed:
       was 5da34d5f16f6f9ebb362bf02447d129bd2ecf879
       now 15e394cc6829207a49782bd0368530893f9448bc

1:  5da34d5 ! 1:  16ac55a Stub out validation hooks for ticket creation and ticket update.
    @@ -6,20 +6,17 @@
     --- a/lib/RT/Extension/REST2/Resource/Message.pm
     +++ b/lib/RT/Extension/REST2/Resource/Message.pm
     @@
    -             \400, $msg || "Message failed for unknown reason");
    -     }
    +         Subject   => $args{Subject},
    +     );
      
    -+    # This hook will only really matter once the
    -+    # allow-update-of-ticket-status-on-correspond branch is merged
    -+    # in, at which point we can delete this comment
    -+    my ($http_code, $errmsg) = RT::Extension::REST2::Resource::Ticket->validate_hook_before_update(\%args, $self->record);
    ++    my ($http_code, $errmsg) = RT::Extension::REST2::Resource::Ticket->validate_hook_before_update($self->record, \%args);
     +    if ($http_code != 200) {
     +        return(\$http_code, $errmsg);
     +    }
     +
    -     push @results, $msg;
    -     push @results, update_custom_fields($self->record, $args{CustomFields});
    -     push @results, $self->_update_txn_custom_fields( $TransObj, $args{TxnCustomFields} || $args{TransactionCustomFields} );
    +     # Process attachments
    +     foreach my $attachment (@{$args{Attachments}}) {
    +         $MIME->attach(
     
     diff --git a/lib/RT/Extension/REST2/Resource/Ticket.pm b/lib/RT/Extension/REST2/Resource/Ticket.pm
     --- a/lib/RT/Extension/REST2/Resource/Ticket.pm
    @@ -38,7 +35,7 @@
              );
          }
      
    -+    my ($retcode, $mesg) = $self->validate_hook_before_create($data, $queue);
    ++    my ($retcode, $mesg) = $self->validate_hook_before_create($queue, $data);
     +    if ($retcode != 200) {
     +        return (\$retcode, $mesg);
     +    }
    @@ -51,7 +48,7 @@
     +{
     +    my ($self, $data) = @_;
     +
    -+    my ($retcode, $msg) = $self->validate_hook_before_update($data, $self->record);
    ++    my ($retcode, $msg) = $self->validate_hook_before_update($self->record, $data);
     +    if ($retcode != 200) {
     +        return (\$retcode, $msg);
     +    }
    @@ -62,12 +59,10 @@
     +# the REST data and the queue in which the ticket should be created.
     +# It should return (200, '') if all is OK, or (4xx, $msg) if something
     +# is wrong and the creation should be aborted.
    -+#
    -+# This is just a stub.  Extensions are expected to replace this
    -+# implementation with their own.
    ++
     +sub validate_hook_before_create
     +{
    -+    my ($self, $data, $queue) = @_;
    ++    my ($self, $queue, $data) = @_;
     +
     +    return (200, '');
     +}
    @@ -76,12 +71,10 @@
     +# REST data and the ticket being updated.  It should return (200, '')
     +# if all is OK, or (4xx, $msg) if something is wrong and the creation
     +# should be aborted.
    -+#
    -+# This is just a stub.  Extensions are expected to replace this
    -+# implementation with their own.
    ++
     +sub validate_hook_before_update
     +{
    -+    my ($self, $data, $ticket) = @_;
    ++    my ($self, $ticket, $data) = @_;
     +
     +    return (200, '');
     +}
    @@ -89,3 +82,4 @@
      sub forbidden {
          my $self = shift;
          return 0 unless $self->record->id;
    +
-:  ------- > 2:  15e394c Add tests for validation hooks



More information about the Bps-public-commit mailing list