diff --git a/apps/dav/lib/CalDAV/Activity.php b/apps/dav/lib/CalDAV/Activity.php index 10945f887b..d42e9704a8 100644 --- a/apps/dav/lib/CalDAV/Activity.php +++ b/apps/dav/lib/CalDAV/Activity.php @@ -148,9 +148,13 @@ class Activity implements IExtension { case self::SUBJECT_UNSHARE_USER . '_you': return (string) $l->t('You unshared calendar %2$s from %1$s', $params); case self::SUBJECT_UNSHARE_USER . '_by': + return (string) $l->t('%3$s unshared calendar %2$s from %1$s', $params); + case self::SUBJECT_UNSHARE_USER . '_self': return (string) $l->t('%1$s unshared calendar %2$s from themselves', $params); case self::SUBJECT_UNSHARE_GROUP . '_you': return (string) $l->t('You unshared calendar %2$s from group %1$s', $params); + case self::SUBJECT_UNSHARE_GROUP . '_by': + return (string) $l->t('%3$s unshared calendar %2$s from group %1$s', $params); } return false; @@ -178,16 +182,28 @@ class Activity implements IExtension { case self::SUBJECT_UPDATE . '_self': case self::SUBJECT_UNSHARE_USER: case self::SUBJECT_UNSHARE_USER . '_you': + case self::SUBJECT_UNSHARE_USER . '_self': + return [ + 0 => 'username', + //1 => 'calendar', + ]; case self::SUBJECT_UNSHARE_USER . '_by': return [ 0 => 'username', //1 => 'calendar', + 2 => 'username', ]; case self::SUBJECT_UNSHARE_GROUP . '_you': return [ //0 => 'group', //1 => 'calendar', ]; + case self::SUBJECT_UNSHARE_GROUP . '_by': + return [ + //0 => 'group', + //1 => 'calendar', + 2 => 'username', + ]; } } diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php index a707b2c5af..3e1f720cd0 100644 --- a/apps/dav/lib/CalDAV/CalDavBackend.php +++ b/apps/dav/lib/CalDAV/CalDavBackend.php @@ -1823,27 +1823,49 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $this->triggerActivityUnshareUser($principal[2], $event, $properties); if ($owner !== $principal[2]) { + $parameters = [ + $principal[2], + $properties['{DAV:}displayname'], + ]; + + if ($owner === $event->getAuthor()) { + $subject = Activity::SUBJECT_UNSHARE_USER . '_you'; + } else if ($principal[2] === $event->getAuthor()) { + $subject = Activity::SUBJECT_UNSHARE_USER . '_self'; + } else { + $event->setAffectedUser($event->getAuthor()) + ->setSubject(Activity::SUBJECT_UNSHARE_USER . '_you', $parameters); + $aM->publish($event); + + $subject = Activity::SUBJECT_UNSHARE_USER . '_by'; + $parameters[] = $event->getAuthor(); + } + $event->setAffectedUser($owner) - ->setSubject( - $owner === $event->getAuthor() ? Activity::SUBJECT_UNSHARE_USER . '_you' : Activity::SUBJECT_UNSHARE_USER . '_by', - [ - $principal[2], - $properties['{DAV:}displayname'], - ] - ); + ->setSubject($subject, $parameters); $aM->publish($event); } } else if ($principal[1] === 'groups') { $this->triggerActivityUnshareGroup($principal[2], $event, $properties); - $event->setAffectedUser($currentUser) - ->setSubject( - Activity::SUBJECT_UNSHARE_GROUP . '_you', - [ - $principal[2], - $properties['{DAV:}displayname'], - ] - ); + $parameters = [ + $principal[2], + $properties['{DAV:}displayname'], + ]; + + if ($owner === $event->getAuthor()) { + $subject = Activity::SUBJECT_UNSHARE_GROUP . '_you'; + } else { + $event->setAffectedUser($event->getAuthor()) + ->setSubject(Activity::SUBJECT_UNSHARE_GROUP . '_you', $parameters); + $aM->publish($event); + + $subject = Activity::SUBJECT_UNSHARE_GROUP . '_by'; + $parameters[] = $event->getAuthor(); + } + + $event->setAffectedUser($owner) + ->setSubject($subject, $parameters); $aM->publish($event); } } @@ -1856,7 +1878,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription if ($group instanceof IGroup) { foreach ($group->getUsers() as $user) { // Exclude current user - if ($user !== $event->getAuthor()) { + if ($user->getUID() !== $event->getAuthor()) { $this->triggerActivityUnshareUser($user->getUID(), $event, $properties); } }