forked from cyrusimap/cyrus-imapd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request cyrusimap#4742 from cyrusimap/prune_calendareventn…
…otifs Remove jmap_expire and automatically prune calendareventnotifs
- Loading branch information
Showing
14 changed files
with
197 additions
and
631 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
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
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
128 changes: 128 additions & 0 deletions
128
cassandane/tiny-tests/JMAPCalendars/calendareventnotification-prune
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,128 @@ | ||
#!perl | ||
use Cassandane::Tiny; | ||
|
||
sub test_calendareventnotification_prune | ||
:min_version_3_9 :needs_component_jmap :JmapMaxCalendarEventNotifs | ||
{ | ||
my ($self) = @_; | ||
my $jmap = $self->{jmap}; | ||
|
||
my $jmap_max_calendareventnotifs = $self->{instance}->{ | ||
config}->get('jmap_max_calendareventnotifs'); | ||
$self->assert_not_null($jmap_max_calendareventnotifs); | ||
|
||
my ($manJmap) = $self->create_user('manifold'); | ||
$manJmap->DefaultUsing([ | ||
'urn:ietf:params:jmap:core', | ||
'urn:ietf:params:jmap:calendars', | ||
'urn:ietf:params:jmap:principals', | ||
'https://cyrusimap.org/ns/jmap/calendars', | ||
]); | ||
|
||
xlog $self, "Share calendar"; | ||
my $res = $jmap->CallMethods([ | ||
['Calendar/set', { | ||
update => { | ||
Default => { | ||
shareWith => { | ||
manifold => { | ||
mayReadFreeBusy => JSON::true, | ||
mayReadItems => JSON::true, | ||
mayUpdatePrivate => JSON::true, | ||
mayWriteOwn => JSON::true, | ||
mayAdmin => JSON::false | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, 'R1'], | ||
]); | ||
$self->assert(exists $res->[0][1]{updated}{Default}); | ||
|
||
xlog $self, "Create event notification"; | ||
my $res = $jmap->CallMethods([ | ||
['CalendarEvent/set', { | ||
create => { | ||
event1 => { | ||
title => 'event1', | ||
calendarIds => { | ||
Default => JSON::true, | ||
}, | ||
start => '2011-01-01T04:05:06', | ||
duration => 'PT1H', | ||
}, | ||
}, | ||
}, 'R1'], | ||
]); | ||
$self->assert_not_null($res->[0][1]{created}{event1}); | ||
|
||
xlog $self, "Get event notification"; | ||
$res = $manJmap->CallMethods([ | ||
['CalendarEventNotification/get', { | ||
accountId => 'cassandane', | ||
}, 'R1'], | ||
]); | ||
$self->assert_num_equals(1, scalar @{$res->[0][1]{list}}); | ||
my $notif1Id = $res->[0][1]{list}[0]{id}; | ||
$self->assert_not_null($notif1Id); | ||
|
||
xlog $self, "Create maximum count of allowed notifications"; | ||
for my $i (2 .. $jmap_max_calendareventnotifs) { | ||
my $res = $jmap->CallMethods([ | ||
['CalendarEvent/set', { | ||
create => { | ||
"event$i" => { | ||
title => "event$i", | ||
calendarIds => { | ||
Default => JSON::true, | ||
}, | ||
start => '2011-01-01T04:05:06', | ||
duration => 'PT1H', | ||
}, | ||
}, | ||
}, 'R1'], | ||
]); | ||
$self->assert_not_null($res->[0][1]{created}{"event$i"}); | ||
} | ||
|
||
xlog $self, "Get event notifications"; | ||
$res = $manJmap->CallMethods([ | ||
['CalendarEventNotification/get', { | ||
accountId => 'cassandane', | ||
properties => ['id'], | ||
}, 'R1'], | ||
]); | ||
$self->assert_num_equals($jmap_max_calendareventnotifs, scalar @{$res->[0][1]{list}}); | ||
|
||
xlog $self, "Assert first event notification exists"; | ||
$self->assert_equals(1, scalar grep { $_->{id} eq $notif1Id } @{$res->[0][1]{list}}); | ||
|
||
xlog $self, "Create one more event notification"; | ||
my $res = $jmap->CallMethods([ | ||
['CalendarEvent/set', { | ||
create => { | ||
eventX => { | ||
title => 'eventX', | ||
calendarIds => { | ||
Default => JSON::true, | ||
}, | ||
start => '2011-01-01T04:05:06', | ||
duration => 'PT1H', | ||
}, | ||
}, | ||
}, 'R1'], | ||
]); | ||
$self->assert_not_null($res->[0][1]{created}{eventX}); | ||
|
||
xlog $self, "Get event notifications"; | ||
$res = $manJmap->CallMethods([ | ||
['CalendarEventNotification/get', { | ||
accountId => 'cassandane', | ||
properties => ['id'], | ||
}, 'R1'], | ||
]); | ||
$self->assert_num_equals($jmap_max_calendareventnotifs, scalar @{$res->[0][1]{list}}); | ||
|
||
xlog $self, "Assert first event notification does not exist"; | ||
$self->assert_equals(0, scalar grep { $_->{id} eq $notif1Id } @{$res->[0][1]{list}}); | ||
} |
This file was deleted.
Oops, something went wrong.
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,15 @@ | ||
Description: | ||
|
||
Prune JMAP CalendarEventNotification objects each time a new one is created. | ||
|
||
|
||
Config changes: | ||
|
||
jmap_max_calendareventnotifs | ||
|
||
|
||
Upgrade instructions: | ||
|
||
The default maximum count of CalendarEventNotifications is set to 200 | ||
per account. Installations that need any other count or want to not | ||
prune notifications must update the jmap_max_calendareventnotifs config. |
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
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
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
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
138 changes: 0 additions & 138 deletions
138
docsrc/imap/reference/manpages/systemcommands/jmap_expire.rst
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.