Skip to content

Commit

Permalink
jmap_contact: add disableUriAsBlobId argument to Card{get/parse}
Browse files Browse the repository at this point in the history
Signed-off-by: Robert Stepanek <[email protected]>
  • Loading branch information
rsto committed Aug 24, 2023
1 parent a21650f commit 50c9984
Show file tree
Hide file tree
Showing 3 changed files with 188 additions and 71 deletions.
39 changes: 39 additions & 0 deletions cassandane/tiny-tests/JMAPContacts/card_get_disable_uri_as_blobid
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!perl
use Cassandane::Tiny;

sub test_card_get_disable_uri_as_blobid
:min_version_3_9 :needs_component_jmap
{
my ($self) = @_;
my $jmap = $self->{jmap};
my $carddav = $self->{carddav};

my $vcard = <<'EOF';
BEGIN:VCARD
VERSION:4.0
UID:85b5d651-1cde-43d9-901d-7059d67807f9
FN:Jane
PHOTO;PROP-ID=photo1:data:image/x-bla;base64,YmxhYmxhCg=
CREATED:20230823T133154Z
END:VCARD
EOF
$vcard =~ s/\r?\n/\r\n/gs;
$carddav->Request('PUT', 'Default/test.vcf', $vcard,
'Content-Type' => 'text/vcard');

my $res = $jmap->CallMethods([
['ContactCard/get', {
properties => ['media'],
}, 'R1'],
['ContactCard/get', {
properties => ['media'],
disableUriAsBlobId => JSON::true,
}, 'R2'],
]);

$self->assert_not_null($res->[0][1]{list}[0]{media}{photo1}{blobId});
$self->assert_null($res->[0][1]{list}[0]{media}{photo1}{uri});

$self->assert_null($res->[1][1]{list}[0]{media}{photo1}{blobId});
$self->assert_not_null($res->[1][1]{list}[0]{media}{photo1}{uri});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!perl
use Cassandane::Tiny;

sub test_card_parse_disable_uri_as_blobid
:min_version_3_9 :needs_component_jmap
{
my ($self) = @_;
my $jmap = $self->{jmap};
my $carddav = $self->{carddav};

my $vcard = <<'EOF';
BEGIN:VCARD
VERSION:4.0
UID:85b5d651-1cde-43d9-901d-7059d67807f9
FN:Jane
PHOTO;PROP-ID=photo1:data:image/x-bla;base64,YmxhYmxhCg=
CREATED:20230823T133154Z
END:VCARD
EOF
$vcard =~ s/\r?\n/\r\n/gs;

my $data = $jmap->Upload($vcard, "text/vcard");
my $blobId = $data->{blobId};
$self->assert_not_null($blobId);

$res = $jmap->CallMethods([
['ContactCard/parse', {
blobIds => [$blobId],
}, 'R1'],
['ContactCard/parse', {
blobIds => [$blobId],
disableUriAsBlobId => JSON::true,
}, 'R2'],
]);

$self->assert_not_null($res->[0][1]{parsed}{$blobId}{
media}{photo1}{blobId});
$self->assert_null($res->[0][1]{parsed}{$blobId}{
media}{photo1}{uri});

$self->assert_null($res->[1][1]{parsed}{$blobId}{
media}{photo1}{blobId});
$self->assert_not_null($res->[1][1]{parsed}{$blobId}{
media}{photo1}{uri});
}
Loading

0 comments on commit 50c9984

Please sign in to comment.