diff options
author | Joas Schilling <coding@schilljs.com> | 2017-10-16 18:31:43 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2017-10-16 18:41:33 +0200 |
commit | bdb0265644b43ba807dcc4ed1655fde6bb8c6174 (patch) | |
tree | 50de7c6e5d4add6de390bbc0fd03fa0ef4ec3099 /apps/dav/lib/CalDAV | |
parent | c25be8d83cb25fa25cea28bc5eae307308292aa3 (diff) | |
download | nextcloud-server-bdb0265644b43ba807dcc4ed1655fde6bb8c6174.tar.gz nextcloud-server-bdb0265644b43ba807dcc4ed1655fde6bb8c6174.zip |
Fix missing translation of "Personal" calendar in activities
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/dav/lib/CalDAV')
-rw-r--r-- | apps/dav/lib/CalDAV/Activity/Backend.php | 66 | ||||
-rw-r--r-- | apps/dav/lib/CalDAV/Activity/Provider/Base.php | 28 | ||||
-rw-r--r-- | apps/dav/lib/CalDAV/Activity/Provider/Calendar.php | 56 | ||||
-rw-r--r-- | apps/dav/lib/CalDAV/Activity/Provider/Event.php | 26 | ||||
-rw-r--r-- | apps/dav/lib/CalDAV/Activity/Provider/Todo.php | 30 |
5 files changed, 176 insertions, 30 deletions
diff --git a/apps/dav/lib/CalDAV/Activity/Backend.php b/apps/dav/lib/CalDAV/Activity/Backend.php index f8cc82407fd..c1a68c1682c 100644 --- a/apps/dav/lib/CalDAV/Activity/Backend.php +++ b/apps/dav/lib/CalDAV/Activity/Backend.php @@ -135,8 +135,12 @@ class Backend { ->setSubject( $user === $currentUser ? $action . '_self' : $action, [ - $currentUser, - $calendarData['{DAV:}displayname'], + 'actor' => $currentUser, + 'calendar' => [ + 'id' => (int) $calendarData['id'], + 'uri' => $calendarData['uri'], + 'name' => $calendarData['{DAV:}displayname'], + ], ] ); $this->activityManager->publish($event); @@ -187,8 +191,13 @@ class Backend { if ($owner !== $principal[2]) { $parameters = [ - $principal[2], - $calendarData['{DAV:}displayname'], + 'actor' => $event->getAuthor(), + 'calendar' => [ + 'id' => (int) $calendarData['id'], + 'uri' => $calendarData['uri'], + 'name' => $calendarData['{DAV:}displayname'], + ], + 'user' => $principal[2], ]; if ($owner === $event->getAuthor()) { @@ -201,7 +210,6 @@ class Backend { $this->activityManager->publish($event); $subject = Calendar::SUBJECT_UNSHARE_USER . '_by'; - $parameters[] = $event->getAuthor(); } $event->setAffectedUser($owner) @@ -212,8 +220,13 @@ class Backend { $this->triggerActivityGroup($principal[2], $event, $calendarData, Calendar::SUBJECT_UNSHARE_USER); $parameters = [ - $principal[2], - $calendarData['{DAV:}displayname'], + 'actor' => $event->getAuthor(), + 'calendar' => [ + 'id' => (int) $calendarData['id'], + 'uri' => $calendarData['uri'], + 'name' => $calendarData['{DAV:}displayname'], + ], + 'group' => $principal[2], ]; if ($owner === $event->getAuthor()) { @@ -224,7 +237,6 @@ class Backend { $this->activityManager->publish($event); $subject = Calendar::SUBJECT_UNSHARE_GROUP . '_by'; - $parameters[] = $event->getAuthor(); } $event->setAffectedUser($owner) @@ -250,8 +262,13 @@ class Backend { if ($owner !== $principal[2]) { $parameters = [ - $principal[2], - $calendarData['{DAV:}displayname'], + 'actor' => $event->getAuthor(), + 'calendar' => [ + 'id' => (int) $calendarData['id'], + 'uri' => $calendarData['uri'], + 'name' => $calendarData['{DAV:}displayname'], + ], + 'user' => $principal[2], ]; if ($owner === $event->getAuthor()) { @@ -262,7 +279,6 @@ class Backend { $this->activityManager->publish($event); $subject = Calendar::SUBJECT_SHARE_USER . '_by'; - $parameters[] = $event->getAuthor(); } $event->setAffectedUser($owner) @@ -273,8 +289,13 @@ class Backend { $this->triggerActivityGroup($principal[2], $event, $calendarData, Calendar::SUBJECT_SHARE_USER); $parameters = [ - $principal[2], - $calendarData['{DAV:}displayname'], + 'actor' => $event->getAuthor(), + 'calendar' => [ + 'id' => (int) $calendarData['id'], + 'uri' => $calendarData['uri'], + 'name' => $calendarData['{DAV:}displayname'], + ], + 'group' => $principal[2], ]; if ($owner === $event->getAuthor()) { @@ -285,7 +306,6 @@ class Backend { $this->activityManager->publish($event); $subject = Calendar::SUBJECT_SHARE_GROUP . '_by'; - $parameters[] = $event->getAuthor(); } $event->setAffectedUser($owner) @@ -347,8 +367,12 @@ class Backend { ->setSubject( $user === $event->getAuthor() && $subjectSelf ? $subjectSelf : $subject, [ - $event->getAuthor(), - $properties['{DAV:}displayname'], + 'actor' => $event->getAuthor(), + 'calendar' => [ + 'id' => (int) $properties['id'], + 'uri' => $properties['uri'], + 'name' => $properties['{DAV:}displayname'], + ], ] ); @@ -401,9 +425,13 @@ class Backend { ->setSubject( $user === $currentUser ? $action . '_self' : $action, [ - $currentUser, - $calendarData['{DAV:}displayname'], - [ + 'actor' => $event->getAuthor(), + 'calendar' => [ + 'id' => (int) $calendarData['id'], + 'uri' => $calendarData['uri'], + 'name' => $calendarData['{DAV:}displayname'], + ], + 'object' => [ 'id' => $object['id'], 'name' => $object['name'], ], diff --git a/apps/dav/lib/CalDAV/Activity/Provider/Base.php b/apps/dav/lib/CalDAV/Activity/Provider/Base.php index 72fdd681b8a..983d05310ac 100644 --- a/apps/dav/lib/CalDAV/Activity/Provider/Base.php +++ b/apps/dav/lib/CalDAV/Activity/Provider/Base.php @@ -21,8 +21,10 @@ namespace OCA\DAV\CalDAV\Activity\Provider; +use OCA\DAV\CalDAV\CalDavBackend; use OCP\Activity\IEvent; use OCP\Activity\IProvider; +use OCP\IL10N; use OCP\IUser; use OCP\IUserManager; @@ -64,7 +66,7 @@ abstract class Base implements IProvider { protected function generateObjectParameter($eventData) { if (!is_array($eventData) || !isset($eventData['id']) || !isset($eventData['name'])) { throw new \InvalidArgumentException(); - }; + } return [ 'type' => 'calendar-event', @@ -74,11 +76,33 @@ abstract class Base implements IProvider { } /** + * @param array $data + * @param IL10N $l + * @return array + */ + protected function generateCalendarParameter($data, IL10N $l) { + if ($data['uri'] === CalDavBackend::PERSONAL_CALENDAR_URI && + $data['name'] === CalDavBackend::PERSONAL_CALENDAR_NAME) { + return [ + 'type' => 'calendar', + 'id' => $data['id'], + 'name' => $l->t('Personal'), + ]; + } + + return [ + 'type' => 'calendar', + 'id' => $data['id'], + 'name' => $data['name'], + ]; + } + + /** * @param int $id * @param string $name * @return array */ - protected function generateCalendarParameter($id, $name) { + protected function generateLegacyCalendarParameter($id, $name) { return [ 'type' => 'calendar', 'id' => $id, diff --git a/apps/dav/lib/CalDAV/Activity/Provider/Calendar.php b/apps/dav/lib/CalDAV/Activity/Provider/Calendar.php index 36d425ecf63..1efdbb13b8c 100644 --- a/apps/dav/lib/CalDAV/Activity/Provider/Calendar.php +++ b/apps/dav/lib/CalDAV/Activity/Provider/Calendar.php @@ -156,6 +156,52 @@ class Calendar extends Base { $subject = $event->getSubject(); $parameters = $event->getSubjectParameters(); + // Nextcloud 13+ + if (isset($parameters['calendar'])) { + switch ($subject) { + case self::SUBJECT_ADD: + case self::SUBJECT_ADD . '_self': + case self::SUBJECT_DELETE: + case self::SUBJECT_DELETE . '_self': + case self::SUBJECT_UPDATE: + case self::SUBJECT_UPDATE . '_self': + case self::SUBJECT_SHARE_USER: + case self::SUBJECT_UNSHARE_USER: + case self::SUBJECT_UNSHARE_USER . '_self': + return [ + 'actor' => $this->generateUserParameter($parameters['actor']), + 'calendar' => $this->generateCalendarParameter($parameters['calendar'], $this->l), + ]; + case self::SUBJECT_SHARE_USER . '_you': + case self::SUBJECT_UNSHARE_USER . '_you': + return [ + 'calendar' => $this->generateCalendarParameter($parameters['calendar'], $this->l), + 'user' => $this->generateUserParameter($parameters['user']), + ]; + case self::SUBJECT_SHARE_USER . '_by': + case self::SUBJECT_UNSHARE_USER . '_by': + return [ + 'actor' => $this->generateUserParameter($parameters['actor']), + 'calendar' => $this->generateCalendarParameter($parameters['calendar'], $this->l), + 'user' => $this->generateUserParameter($parameters['user']), + ]; + case self::SUBJECT_SHARE_GROUP . '_you': + case self::SUBJECT_UNSHARE_GROUP . '_you': + return [ + 'calendar' => $this->generateCalendarParameter($parameters['calendar'], $this->l), + 'group' => $this->generateGroupParameter($parameters['group']), + ]; + case self::SUBJECT_SHARE_GROUP . '_by': + case self::SUBJECT_UNSHARE_GROUP . '_by': + return [ + 'actor' => $this->generateUserParameter($parameters['actor']), + 'calendar' => $this->generateCalendarParameter($parameters['calendar'], $this->l), + 'group' => $this->generateGroupParameter($parameters['group']), + ]; + } + } + + // Legacy switch ($subject) { case self::SUBJECT_ADD: case self::SUBJECT_ADD . '_self': @@ -168,32 +214,32 @@ class Calendar extends Base { case self::SUBJECT_UNSHARE_USER . '_self': return [ 'actor' => $this->generateUserParameter($parameters[0]), - 'calendar' => $this->generateCalendarParameter((int)$event->getObjectId(), $parameters[1]), + 'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]), ]; case self::SUBJECT_SHARE_USER . '_you': case self::SUBJECT_UNSHARE_USER . '_you': return [ 'user' => $this->generateUserParameter($parameters[0]), - 'calendar' => $this->generateCalendarParameter((int)$event->getObjectId(), $parameters[1]), + 'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]), ]; case self::SUBJECT_SHARE_USER . '_by': case self::SUBJECT_UNSHARE_USER . '_by': return [ 'user' => $this->generateUserParameter($parameters[0]), - 'calendar' => $this->generateCalendarParameter((int)$event->getObjectId(), $parameters[1]), + 'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]), 'actor' => $this->generateUserParameter($parameters[2]), ]; case self::SUBJECT_SHARE_GROUP . '_you': case self::SUBJECT_UNSHARE_GROUP . '_you': return [ 'group' => $this->generateGroupParameter($parameters[0]), - 'calendar' => $this->generateCalendarParameter((int)$event->getObjectId(), $parameters[1]), + 'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]), ]; case self::SUBJECT_SHARE_GROUP . '_by': case self::SUBJECT_UNSHARE_GROUP . '_by': return [ 'group' => $this->generateGroupParameter($parameters[0]), - 'calendar' => $this->generateCalendarParameter((int)$event->getObjectId(), $parameters[1]), + 'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]), 'actor' => $this->generateUserParameter($parameters[2]), ]; } diff --git a/apps/dav/lib/CalDAV/Activity/Provider/Event.php b/apps/dav/lib/CalDAV/Activity/Provider/Event.php index 2c2e3d01c28..dafd2404d2f 100644 --- a/apps/dav/lib/CalDAV/Activity/Provider/Event.php +++ b/apps/dav/lib/CalDAV/Activity/Provider/Event.php @@ -118,20 +118,42 @@ class Event extends Base { $subject = $event->getSubject(); $parameters = $event->getSubjectParameters(); + // Nextcloud 13+ + if (isset($parameters['calendar'])) { + switch ($subject) { + case self::SUBJECT_OBJECT_ADD . '_event': + case self::SUBJECT_OBJECT_DELETE . '_event': + case self::SUBJECT_OBJECT_UPDATE . '_event': + return [ + 'actor' => $this->generateUserParameter($parameters['actor']), + 'calendar' => $this->generateCalendarParameter($parameters['calendar'], $this->l), + 'event' => $this->generateObjectParameter($parameters['object']), + ]; + case self::SUBJECT_OBJECT_ADD . '_event_self': + case self::SUBJECT_OBJECT_DELETE . '_event_self': + case self::SUBJECT_OBJECT_UPDATE . '_event_self': + return [ + 'calendar' => $this->generateCalendarParameter($parameters['calendar'], $this->l), + 'event' => $this->generateObjectParameter($parameters['object']), + ]; + } + } + + // Legacy switch ($subject) { case self::SUBJECT_OBJECT_ADD . '_event': case self::SUBJECT_OBJECT_DELETE . '_event': case self::SUBJECT_OBJECT_UPDATE . '_event': return [ 'actor' => $this->generateUserParameter($parameters[0]), - 'calendar' => $this->generateCalendarParameter((int)$event->getObjectId(), $parameters[1]), + 'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]), 'event' => $this->generateObjectParameter($parameters[2]), ]; case self::SUBJECT_OBJECT_ADD . '_event_self': case self::SUBJECT_OBJECT_DELETE . '_event_self': case self::SUBJECT_OBJECT_UPDATE . '_event_self': return [ - 'calendar' => $this->generateCalendarParameter((int)$event->getObjectId(), $parameters[1]), + 'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]), 'event' => $this->generateObjectParameter($parameters[2]), ]; } diff --git a/apps/dav/lib/CalDAV/Activity/Provider/Todo.php b/apps/dav/lib/CalDAV/Activity/Provider/Todo.php index a665caa0e6a..0f9cd640537 100644 --- a/apps/dav/lib/CalDAV/Activity/Provider/Todo.php +++ b/apps/dav/lib/CalDAV/Activity/Provider/Todo.php @@ -87,6 +87,32 @@ class Todo extends Event { $subject = $event->getSubject(); $parameters = $event->getSubjectParameters(); + // Nextcloud 13+ + if (isset($parameters['calendar'])) { + switch ($subject) { + case self::SUBJECT_OBJECT_ADD . '_todo': + case self::SUBJECT_OBJECT_DELETE . '_todo': + case self::SUBJECT_OBJECT_UPDATE . '_todo': + case self::SUBJECT_OBJECT_UPDATE . '_todo_completed': + case self::SUBJECT_OBJECT_UPDATE . '_todo_needs_action': + return [ + 'actor' => $this->generateUserParameter($parameters['actor']), + 'calendar' => $this->generateCalendarParameter($parameters['calendar'], $this->l), + 'todo' => $this->generateObjectParameter($parameters['object']), + ]; + case self::SUBJECT_OBJECT_ADD . '_todo_self': + case self::SUBJECT_OBJECT_DELETE . '_todo_self': + case self::SUBJECT_OBJECT_UPDATE . '_todo_self': + case self::SUBJECT_OBJECT_UPDATE . '_todo_completed_self': + case self::SUBJECT_OBJECT_UPDATE . '_todo_needs_action_self': + return [ + 'calendar' => $this->generateCalendarParameter($parameters['calendar'], $this->l), + 'todo' => $this->generateObjectParameter($parameters['object']), + ]; + } + } + + // Legacy switch ($subject) { case self::SUBJECT_OBJECT_ADD . '_todo': case self::SUBJECT_OBJECT_DELETE . '_todo': @@ -95,7 +121,7 @@ class Todo extends Event { case self::SUBJECT_OBJECT_UPDATE . '_todo_needs_action': return [ 'actor' => $this->generateUserParameter($parameters[0]), - 'calendar' => $this->generateCalendarParameter((int)$event->getObjectId(), $parameters[1]), + 'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]), 'todo' => $this->generateObjectParameter($parameters[2]), ]; case self::SUBJECT_OBJECT_ADD . '_todo_self': @@ -104,7 +130,7 @@ class Todo extends Event { case self::SUBJECT_OBJECT_UPDATE . '_todo_completed_self': case self::SUBJECT_OBJECT_UPDATE . '_todo_needs_action_self': return [ - 'calendar' => $this->generateCalendarParameter((int)$event->getObjectId(), $parameters[1]), + 'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]), 'todo' => $this->generateObjectParameter($parameters[2]), ]; } |