-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
jmap_mail: return lowest createdmodseq in Email/get
Signed-off-by: Robert Stepanek <[email protected]>
- Loading branch information
Showing
2 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!perl | ||
use Cassandane::Tiny; | ||
use Time::HiRes qw( usleep gettimeofday ); | ||
|
||
sub test_email_get_createdmodseq | ||
:min_version_3_9 :needs_component_jmap :JMAPExtensions | ||
{ | ||
my ($self) = @_; | ||
my $jmap = $self->{jmap}; | ||
my $imap = $self->{store}->get_client(); | ||
$jmap->AddUsing('https://cyrusimap.org/ns/jmap/mail'); | ||
|
||
xlog $self, "Append duplicate messages"; | ||
$mimeMessage = <<'EOF'; | ||
From: <from@local> | ||
To: to@local | ||
Subject: test | ||
Date: Mon, 13 Apr 2020 15:34:03 +0200 | ||
MIME-Version: 1.0 | ||
Content-Type: text/plain | ||
test | ||
EOF | ||
$mimeMessage =~ s/\r?\n/\r\n/gs; | ||
$imap->append('INBOX', '17-Aug-2023 15:13:54 +0200', $mimeMessage) || die $@; | ||
$imap->append('INBOX', '17-Aug-2023 15:13:54 +0200', $mimeMessage) || die $@; | ||
|
||
$imap->select('INBOX'); | ||
$fetch = $imap->fetch('1:2', ['INTERNALDATE', 'CREATEDMODSEQ']); | ||
$self->assert_str_equals( | ||
$fetch->{1}{internaldate}, $fetch->{2}{internaldate} | ||
); | ||
$self->assert_num_lt( | ||
$fetch->{2}{createdmodseq}[0], $fetch->{1}{createdmodseq}[0] | ||
); | ||
|
||
# The createdModseq must be the lower modseq. | ||
$res = $jmap->CallMethods([ | ||
['Email/query', { }, "R1"], | ||
['Email/get', { | ||
'#ids' => { | ||
resultOf => 'R1', | ||
name => 'Email/query', | ||
path => '/ids' | ||
}, | ||
properties => ['createdModseq'], | ||
}, 'R2' ], | ||
]); | ||
$self->assert_num_equals(1, scalar @{$res->[1][1]{list}}); | ||
$self->assert_num_equals($fetch->{1}{createdmodseq}[0], | ||
$res->[1][1]{list}[0]{createdModseq}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters