MT#9263 Fix CF API handling of numbers.

Numbers must be normalized to URIs too.
changes/94/294/1
Andreas Granig 11 years ago
parent f1ac49855a
commit 86fffe08e1

@ -166,12 +166,13 @@ sub POST :Allow {
c => $c,
resource => $resource,
form => $form,
exceptions => [ "subscriber_id" ],
);
my $dset;
unless(defined $resource->{subscriber_id}) {
$self->error($c, HTTP_UNPROCESSABLE_ENTITY, "Required: 'subscriber_id'");
$self->error($c, HTTP_UNPROCESSABLE_ENTITY, "Missing mandatory field 'subscriber_id'");
last;
}

@ -8,12 +8,13 @@ has_field 'id' => (
type => 'Hidden',
);
has_field 'subscriber' => ( # Workaround for validate_form
type => 'Compound',
);
has_field 'subscriber.id' => (
has_field 'subscriber_id' => (
type => 'PosInteger',
required => 1,
element_attr => {
rel => ['tooltip'],
title => ['The subscriber id this destination set belongs to.']
},
);
has_field 'name' => (
@ -21,10 +22,18 @@ has_field 'name' => (
label => 'Name',
wrapper_class => [qw/hfh-rep-field/],
required => 1,
element_attr => {
rel => ['tooltip'],
title => ['The name of the destination set.']
},
);
has_field 'destinations' => (
type => 'Repeatable',
element_attr => {
rel => ['tooltip'],
title => ['An array of destinations, each containing the keys "destination", "timeout" and "priority".']
},
);
has_field 'destinations.id' => (

@ -63,6 +63,7 @@ sub hal_from_item {
form => $form,
resource => \%resource,
run => 0,
exceptions => [ "subscriber_id" ],
);
$hal->resource(\%resource);
return $hal;
@ -97,6 +98,7 @@ sub update_item {
c => $c,
form => $form,
resource => $resource,
exceptions => [ "subscriber_id" ],
);
if (! exists $resource->{destinations} ) {

@ -874,8 +874,12 @@ sub field_to_destination {
$d = "sip:auto-attendant\@app.local";
} elsif($d eq "officehours") {
$d = "sip:office-hours\@app.local";
} elsif($d eq "uri") {
$d = $uri;
} else {
my $v = $uri;
$v =~ s/^sips?://;
my ($vuser, $vdomain) = split(/\@/, $v);
$vdomain = $domain unless($vdomain);
$d = 'sip:' . $vuser . '@' . $vdomain;
}
return $d;
}

Loading…
Cancel
Save