diff options
author | Joas Schilling <coding@schilljs.com> | 2018-11-23 15:04:16 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2018-12-04 18:42:07 +0300 |
commit | 11c39b6c1678397680174c7d687698590b67cf10 (patch) | |
tree | 1fcc177259bcee6bb4909ca83e27f40c6fc08d61 /apps/sharebymail/lib | |
parent | 441496a5a579a30d21c9545d32429281de66bd24 (diff) |
Unshare from mail activity is missing
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/sharebymail/lib')
-rw-r--r-- | apps/sharebymail/lib/Activity.php | 53 | ||||
-rw-r--r-- | apps/sharebymail/lib/ShareByMailProvider.php | 11 |
2 files changed, 62 insertions, 2 deletions
diff --git a/apps/sharebymail/lib/Activity.php b/apps/sharebymail/lib/Activity.php index df9cb36e0d7..9cd0bd6a1e7 100644 --- a/apps/sharebymail/lib/Activity.php +++ b/apps/sharebymail/lib/Activity.php @@ -60,6 +60,8 @@ class Activity implements IProvider { const SUBJECT_SHARED_EMAIL_BY = 'shared_with_email_by'; const SUBJECT_SHARED_EMAIL_PASSWORD_SEND = 'shared_with_email_password_send'; const SUBJECT_SHARED_EMAIL_PASSWORD_SEND_SELF = 'shared_with_email_password_send_self'; + const SUBJECT_UNSHARED_EMAIL_SELF = 'unshared_with_email_self'; + const SUBJECT_UNSHARED_EMAIL_BY = 'unshared_with_email_by'; /** * @param IFactory $languageFactory @@ -137,6 +139,32 @@ class Activity implements IProvider { } else { $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg'))); } + } else if ($event->getSubject() === self::SUBJECT_UNSHARED_EMAIL_SELF) { + $event->setParsedSubject($this->l->t('Unshared from %1$s', [ + $parsedParameters['email']['name'], + ])) + ->setRichSubject($this->l->t('Unshared from {email}'), [ + 'email' => $parsedParameters['email'], + ]); + if ($this->activityManager->getRequirePNG()) { + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.png'))); + } else { + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg'))); + } + } else if ($event->getSubject() === self::SUBJECT_UNSHARED_EMAIL_BY) { + $event->setParsedSubject($this->l->t('Unshared from %1$s by %2$s', [ + $parsedParameters['email']['name'], + $parsedParameters['actor']['name'], + ])) + ->setRichSubject($this->l->t('Unshared from {email} by {actor}'), [ + 'email' => $parsedParameters['email'], + 'actor' => $parsedParameters['actor'], + ]); + if ($this->activityManager->getRequirePNG()) { + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.png'))); + } else { + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg'))); + } } else if ($event->getSubject() === self::SUBJECT_SHARED_EMAIL_PASSWORD_SEND) { $event->setParsedSubject($this->l->t('Password for mail share sent to %1$s', [ $parsedParameters['email']['name'] @@ -196,6 +224,29 @@ class Activity implements IProvider { } else { $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg'))); } + } else if ($event->getSubject() === self::SUBJECT_UNSHARED_EMAIL_SELF) { + $event->setParsedSubject($this->l->t('You unshared %1$s from %2$s by mail', [ + $parsedParameters['file']['path'], + $parsedParameters['email']['name'], + ])) + ->setRichSubject($this->l->t('You unshared {file} from {email} by mail'), $parsedParameters); + if ($this->activityManager->getRequirePNG()) { + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.png'))); + } else { + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg'))); + } + } else if ($event->getSubject() === self::SUBJECT_UNSHARED_EMAIL_BY) { + $event->setParsedSubject($this->l->t('%3$s unshared %1$s from %2$s by mail', [ + $parsedParameters['file']['path'], + $parsedParameters['email']['name'], + $parsedParameters['actor']['name'], + ])) + ->setRichSubject($this->l->t('{actor} unshared {file} from {email} by mail'), $parsedParameters); + if ($this->activityManager->getRequirePNG()) { + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.png'))); + } else { + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg'))); + } } else if ($event->getSubject() === self::SUBJECT_SHARED_EMAIL_PASSWORD_SEND) { $event->setParsedSubject($this->l->t('Password to access %1$s was sent to %2s', [ $parsedParameters['file']['path'], @@ -231,11 +282,13 @@ class Activity implements IProvider { switch ($subject) { case self::SUBJECT_SHARED_EMAIL_SELF: + case self::SUBJECT_UNSHARED_EMAIL_SELF: return [ 'file' => $this->generateFileParameter((int) $event->getObjectId(), $parameters[0]), 'email' => $this->generateEmailParameter($parameters[1]), ]; case self::SUBJECT_SHARED_EMAIL_BY: + case self::SUBJECT_UNSHARED_EMAIL_BY: return [ 'file' => $this->generateFileParameter((int) $event->getObjectId(), $parameters[0]), 'email' => $this->generateEmailParameter($parameters[1]), diff --git a/apps/sharebymail/lib/ShareByMailProvider.php b/apps/sharebymail/lib/ShareByMailProvider.php index b11a9349371..c74c5eb1a7f 100644 --- a/apps/sharebymail/lib/ShareByMailProvider.php +++ b/apps/sharebymail/lib/ShareByMailProvider.php @@ -243,13 +243,14 @@ class ShareByMailProvider implements IShareProvider { * create activity if a file/folder was shared by mail * * @param IShare $share + * @param string $type */ - protected function createShareActivity(IShare $share) { + protected function createShareActivity(IShare $share, string $type = 'share') { $userFolder = $this->rootFolder->getUserFolder($share->getSharedBy()); $this->publishActivity( - Activity::SUBJECT_SHARED_EMAIL_SELF, + $type === 'share' ? Activity::SUBJECT_SHARED_EMAIL_SELF : Activity::SUBJECT_UNSHARED_EMAIL_SELF, [$userFolder->getRelativePath($share->getNode()->getPath()), $share->getSharedWith()], $share->getSharedBy(), $share->getNode()->getId(), @@ -262,6 +263,7 @@ class ShareByMailProvider implements IShareProvider { $nodes = $ownerFolder->getById($fileId); $ownerPath = $nodes[0]->getPath(); $this->publishActivity( + $type === 'share' ? Activity::SUBJECT_SHARED_EMAIL_BY : Activity::SUBJECT_UNSHARED_EMAIL_BY, Activity::SUBJECT_SHARED_EMAIL_BY, [$ownerFolder->getRelativePath($ownerPath), $share->getSharedWith(), $share->getSharedBy()], $share->getShareOwner(), @@ -751,6 +753,11 @@ class ShareByMailProvider implements IShareProvider { * @param IShare $share */ public function delete(IShare $share) { + try { + $this->createShareActivity($share, 'unshare'); + } catch (\Exception $e) { + } + $this->removeShareFromTable($share->getId()); } |