[Pkg-owncloud-commits] [php-sabre-vobject] 11/38: Don't generate REPLY messages for events that have been CANCELLED.
David Prévot
taffit at moszumanska.debian.org
Tue Sep 23 03:10:21 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch upstream
in repository php-sabre-vobject.
commit 7df1c146c0ce628efe8063e0ed20a2c7cff2b94e
Author: Evert Pot <evert at rooftopsolutions.nl>
Date: Mon Sep 15 20:04:09 2014 +0100
Don't generate REPLY messages for events that have been CANCELLED.
Fixes #122
---
ChangeLog.md | 1 +
lib/ITip/Broker.php | 17 ++++-
tests/VObject/ITip/BrokerAttendeeReplyTest.php | 102 +++++++++++++++++++++++++
tests/VObject/ITip/BrokerDeleteEventTest.php | 31 +++++++-
4 files changed, 148 insertions(+), 3 deletions(-)
diff --git a/ChangeLog.md b/ChangeLog.md
index c301645..5d647ba 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -9,6 +9,7 @@ ChangeLog
* #119: Support for detecting 'significant changes'.
* #120: Support for `SCHEDULE-FORCE-SEND`.
* #121: iCal demands parameters contain the + sign to be quoted.
+* #122: Don't generate REPLY messages for events that have been cancelled.
3.3.1 (2014-08-18)
------------------
diff --git a/lib/ITip/Broker.php b/lib/ITip/Broker.php
index e1362dc..3700b55 100644
--- a/lib/ITip/Broker.php
+++ b/lib/ITip/Broker.php
@@ -212,11 +212,13 @@ class Broker {
}
$eventInfo = $oldEventInfo;
- $eventInfo['sequence']++;
if (in_array($eventInfo['organizer'], $userHref)) {
// This is an organizer deleting the event.
$eventInfo['attendees'] = array();
+ // Increasing the sequence, but only if the organizer deleted
+ // the event.
+ $eventInfo['sequence']++;
} else {
// This is an attendee deleting the event.
foreach($eventInfo['attendees'] as $key=>$attendee) {
@@ -605,6 +607,12 @@ class Broker {
*/
protected function parseEventForAttendee(VCalendar $calendar, array $eventInfo, array $oldEventInfo, $attendee) {
+ // Don't bother generating messages for events that have already been
+ // cancelled.
+ if ($eventInfo['status']==='CANCELLED') {
+ return array();
+ }
+
$instances = array();
foreach($oldEventInfo['attendees'][$attendee]['instances'] as $instance) {
@@ -723,6 +731,7 @@ class Broker {
$organizerForceSend = null;
$sequence = null;
$timezone = null;
+ $status = null;
$significantChangeHash = '';
@@ -767,6 +776,9 @@ class Broker {
if (isset($vevent->EXDATE)) {
$exdate = $vevent->EXDATE->getParts();
}
+ if (isset($vevent->STATUS)) {
+ $status = strtoupper($vevent->STATUS->getValue());
+ }
$recurId = isset($vevent->{'RECURRENCE-ID'})?$vevent->{'RECURRENCE-ID'}->getValue():'master';
if ($recurId==='master') {
@@ -839,7 +851,8 @@ class Broker {
'sequence',
'exdate',
'timezone',
- 'significantChangeHash'
+ 'significantChangeHash',
+ 'status'
);
}
diff --git a/tests/VObject/ITip/BrokerAttendeeReplyTest.php b/tests/VObject/ITip/BrokerAttendeeReplyTest.php
index fa900ef..9d98c8a 100644
--- a/tests/VObject/ITip/BrokerAttendeeReplyTest.php
+++ b/tests/VObject/ITip/BrokerAttendeeReplyTest.php
@@ -471,4 +471,106 @@ ICS
}
+ function testDeclined() {
+
+ $oldMessage = <<<ICS
+BEGIN:VCALENDAR
+VERSION:2.0
+BEGIN:VEVENT
+UID:foobar
+SEQUENCE:1
+ORGANIZER;CN=Strunk:mailto:strunk at example.org
+ATTENDEE;CN=One:mailto:one at example.org
+DTSTART:20140716T120000Z
+END:VEVENT
+END:VCALENDAR
+ICS;
+
+
+ $newMessage = <<<ICS
+BEGIN:VCALENDAR
+VERSION:2.0
+BEGIN:VEVENT
+UID:foobar
+SEQUENCE:1
+ORGANIZER;CN=Strunk:mailto:strunk at example.org
+ATTENDEE;PARTSTAT=DECLINED;CN=One:mailto:one at example.org
+DTSTART:20140716T120000Z
+END:VEVENT
+END:VCALENDAR
+ICS;
+
+ $version = \Sabre\VObject\Version::VERSION;
+
+ $expected = array(
+ array(
+ 'uid' => 'foobar',
+ 'method' => 'REPLY',
+ 'component' => 'VEVENT',
+ 'sender' => 'mailto:one at example.org',
+ 'senderName' => 'One',
+ 'recipient' => 'mailto:strunk at example.org',
+ 'recipientName' => 'Strunk',
+ 'message' => <<<ICS
+BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//Sabre//Sabre VObject $version//EN
+CALSCALE:GREGORIAN
+METHOD:REPLY
+BEGIN:VEVENT
+UID:foobar
+SEQUENCE:1
+ORGANIZER;CN=Strunk:mailto:strunk at example.org
+ATTENDEE;PARTSTAT=DECLINED;CN=One:mailto:one at example.org
+END:VEVENT
+END:VCALENDAR
+ICS
+
+ ),
+
+ );
+
+ $result = $this->parse($oldMessage, $newMessage, $expected);
+
+ }
+
+ function testDeclinedCancelledEvent() {
+
+ $oldMessage = <<<ICS
+BEGIN:VCALENDAR
+VERSION:2.0
+BEGIN:VEVENT
+STATUS:CANCELLED
+UID:foobar
+SEQUENCE:1
+ORGANIZER;CN=Strunk:mailto:strunk at example.org
+ATTENDEE;CN=One:mailto:one at example.org
+DTSTART:20140716T120000Z
+END:VEVENT
+END:VCALENDAR
+ICS;
+
+
+ $newMessage = <<<ICS
+BEGIN:VCALENDAR
+VERSION:2.0
+BEGIN:VEVENT
+STATUS:CANCELLED
+UID:foobar
+SEQUENCE:1
+ORGANIZER;CN=Strunk:mailto:strunk at example.org
+ATTENDEE;PARTSTAT=DECLINED;CN=One:mailto:one at example.org
+DTSTART:20140716T120000Z
+END:VEVENT
+END:VCALENDAR
+ICS;
+
+ $version = \Sabre\VObject\Version::VERSION;
+
+ $expected = array();
+
+ $result = $this->parse($oldMessage, $newMessage, $expected);
+
+ }
+
}
diff --git a/tests/VObject/ITip/BrokerDeleteEventTest.php b/tests/VObject/ITip/BrokerDeleteEventTest.php
index 68837ff..00172cc 100644
--- a/tests/VObject/ITip/BrokerDeleteEventTest.php
+++ b/tests/VObject/ITip/BrokerDeleteEventTest.php
@@ -118,7 +118,7 @@ CALSCALE:GREGORIAN
METHOD:REPLY
BEGIN:VEVENT
UID:foobar
-SEQUENCE:2
+SEQUENCE:1
ORGANIZER;CN=Strunk:mailto:strunk at example.org
ATTENDEE;PARTSTAT=DECLINED;CN=One:mailto:one at example.org
END:VEVENT
@@ -132,6 +132,35 @@ ICS
}
+ function testAttendeeDeleteCancelledEvent() {
+
+ $oldMessage = <<<ICS
+BEGIN:VCALENDAR
+VERSION:2.0
+BEGIN:VEVENT
+STATUS:CANCELLED
+UID:foobar
+SEQUENCE:1
+ORGANIZER;CN=Strunk:mailto:strunk at example.org
+ATTENDEE;CN=One:mailto:one at example.org
+ATTENDEE;CN=Two:mailto:two at example.org
+DTSTART:20140716T120000Z
+END:VEVENT
+END:VCALENDAR
+ICS;
+
+
+ $newMessage = null;
+
+ $version = \Sabre\VObject\Version::VERSION;
+
+ $expected = array();
+
+ $result = $this->parse($oldMessage, $newMessage, $expected, 'mailto:one at example.org');
+
+
+ }
+
function testNoCalendar() {
$this->parse(null, null, array(), 'mailto:one at example.org');
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabre-vobject.git
More information about the Pkg-owncloud-commits
mailing list