Fix unshare actions for author != owner
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
9a7c522cc6
commit
35ce4c772c
2 changed files with 54 additions and 16 deletions
|
@ -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',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue