Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Correctly handle the classification of events in the activity stream
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Jan 8, 2019
commit 32d76c7c9220367db87793b0b1d5c90189381e7a
10 changes: 9 additions & 1 deletion apps/dav/lib/CalDAV/Activity/Backend.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

use OCA\DAV\CalDAV\Activity\Provider\Calendar;
use OCA\DAV\CalDAV\Activity\Provider\Event;
use OCA\DAV\CalDAV\CalDavBackend;
use OCP\Activity\IEvent;
use OCP\Activity\IManager as IActivityManager;
use OCP\IGroup;
Expand Down Expand Up @@ -415,6 +416,7 @@ public function onTouchCalendarObject($action, array $calendarData, array $share
$currentUser = $owner;
}

$classification = $objectData['classification'] ?? CalDavBackend::CLASSIFICATION_PUBLIC;
$object = $this->getObjectNameAndType($objectData);
$action = $action . '_' . $object['type'];

Expand All @@ -434,6 +436,11 @@ public function onTouchCalendarObject($action, array $calendarData, array $share
$users[] = $owner;

foreach ($users as $user) {
if ($classification === CalDavBackend::CLASSIFICATION_PRIVATE && $user !== $owner) {
// Private events are only shown to the owner
continue;
}

$event->setAffectedUser($user)
->setSubject(
$user === $currentUser ? $action . '_self' : $action,
Expand All @@ -446,7 +453,8 @@ public function onTouchCalendarObject($action, array $calendarData, array $share
],
'object' => [
'id' => $object['id'],
'name' => $object['name'],
'name' => $classification === CalDavBackend::CLASSIFICATION_CONFIDENTIAL && $user !== $owner ? 'Busy' : $object['name'],
'classified' => $classification === CalDavBackend::CLASSIFICATION_CONFIDENTIAL && $user !== $owner,
],
]
);
Expand Down
13 changes: 11 additions & 2 deletions apps/dav/lib/CalDAV/Activity/Provider/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

namespace OCA\DAV\CalDAV\Activity\Provider;

use OCA\DAV\CalDAV\CalDavBackend;
use OCP\Activity\IEvent;
use OCP\Activity\IEventMerger;
use OCP\Activity\IManager;
Expand Down Expand Up @@ -131,14 +132,14 @@ protected function getParameters(IEvent $event) {
return [
'actor' => $this->generateUserParameter($parameters['actor']),
'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_DELETE . '_event_self':
case self::SUBJECT_OBJECT_UPDATE . '_event_self':
return [
'calendar' => $this->generateCalendarParameter($parameters['calendar'], $this->l),
'event' => $this->generateObjectParameter($parameters['object']),
'event' => $this->generateClassifiedObjectParameter($parameters['object']),
];
}
}
Expand Down Expand Up @@ -168,4 +169,12 @@ protected function getParameters(IEvent $event) {

throw new \InvalidArgumentException();
}

private function generateClassifiedObjectParameter(array $eventData) {
$parameter = $this->generateObjectParameter($eventData);
if ($eventData['classified']) {
$parameter['name'] = $this->l->t('Busy');
}
return $parameter;
}
}