Correctly handle the classification of events in the activity stream

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2019-01-08 17:46:07 +01:00
parent 35a372dadd
commit 32d76c7c92
No known key found for this signature in database
GPG Key ID: 7076EA9751AACDDA
2 changed files with 20 additions and 3 deletions

View File

@ -27,6 +27,7 @@ namespace OCA\DAV\CalDAV\Activity;
use OCA\DAV\CalDAV\Activity\Provider\Calendar; use OCA\DAV\CalDAV\Activity\Provider\Calendar;
use OCA\DAV\CalDAV\Activity\Provider\Event; use OCA\DAV\CalDAV\Activity\Provider\Event;
use OCA\DAV\CalDAV\CalDavBackend;
use OCP\Activity\IEvent; use OCP\Activity\IEvent;
use OCP\Activity\IManager as IActivityManager; use OCP\Activity\IManager as IActivityManager;
use OCP\IGroup; use OCP\IGroup;
@ -415,6 +416,7 @@ class Backend {
$currentUser = $owner; $currentUser = $owner;
} }
$classification = $objectData['classification'] ?? CalDavBackend::CLASSIFICATION_PUBLIC;
$object = $this->getObjectNameAndType($objectData); $object = $this->getObjectNameAndType($objectData);
$action = $action . '_' . $object['type']; $action = $action . '_' . $object['type'];
@ -434,6 +436,11 @@ class Backend {
$users[] = $owner; $users[] = $owner;
foreach ($users as $user) { foreach ($users as $user) {
if ($classification === CalDavBackend::CLASSIFICATION_PRIVATE && $user !== $owner) {
// Private events are only shown to the owner
continue;
}
$event->setAffectedUser($user) $event->setAffectedUser($user)
->setSubject( ->setSubject(
$user === $currentUser ? $action . '_self' : $action, $user === $currentUser ? $action . '_self' : $action,
@ -446,7 +453,8 @@ class Backend {
], ],
'object' => [ 'object' => [
'id' => $object['id'], 'id' => $object['id'],
'name' => $object['name'], 'name' => $classification === CalDavBackend::CLASSIFICATION_CONFIDENTIAL && $user !== $owner ? 'Busy' : $object['name'],
'classified' => $classification === CalDavBackend::CLASSIFICATION_CONFIDENTIAL && $user !== $owner,
], ],
] ]
); );

View File

@ -23,6 +23,7 @@
namespace OCA\DAV\CalDAV\Activity\Provider; namespace OCA\DAV\CalDAV\Activity\Provider;
use OCA\DAV\CalDAV\CalDavBackend;
use OCP\Activity\IEvent; use OCP\Activity\IEvent;
use OCP\Activity\IEventMerger; use OCP\Activity\IEventMerger;
use OCP\Activity\IManager; use OCP\Activity\IManager;
@ -131,14 +132,14 @@ class Event extends Base {
return [ return [
'actor' => $this->generateUserParameter($parameters['actor']), 'actor' => $this->generateUserParameter($parameters['actor']),
'calendar' => $this->generateCalendarParameter($parameters['calendar'], $this->l), 'calendar' => $this->generateCalendarParameter($parameters['calendar'], $this->l),
'event' => $this->generateObjectParameter($parameters['object']), 'event' => $this->generateClassifiedObjectParameter($parameters['object']),
]; ];
case self::SUBJECT_OBJECT_ADD . '_event_self': case self::SUBJECT_OBJECT_ADD . '_event_self':
case self::SUBJECT_OBJECT_DELETE . '_event_self': case self::SUBJECT_OBJECT_DELETE . '_event_self':
case self::SUBJECT_OBJECT_UPDATE . '_event_self': case self::SUBJECT_OBJECT_UPDATE . '_event_self':
return [ return [
'calendar' => $this->generateCalendarParameter($parameters['calendar'], $this->l), 'calendar' => $this->generateCalendarParameter($parameters['calendar'], $this->l),
'event' => $this->generateObjectParameter($parameters['object']), 'event' => $this->generateClassifiedObjectParameter($parameters['object']),
]; ];
} }
} }
@ -168,4 +169,12 @@ class Event extends Base {
throw new \InvalidArgumentException(); throw new \InvalidArgumentException();
} }
private function generateClassifiedObjectParameter(array $eventData) {
$parameter = $this->generateObjectParameter($eventData);
if ($eventData['classified']) {
$parameter['name'] = $this->l->t('Busy');
}
return $parameter;
}
} }