diff options
author | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2018-10-26 13:16:05 +0300 |
---|---|---|
committer | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2018-11-07 17:57:37 +0300 |
commit | 294be0c05e81754e88f0b16807798536e4e54a13 (patch) | |
tree | 3e6c452ed7e34e1bd5cfd76e00673bc9964fa7dd /lib/Notification/Notifier.php | |
parent | d612e845f92dfe086771aea47f70a295486b0526 (diff) |
Get shared with e-mail from the share instead of from the room name
This prepares the code for future changes in which the password could be
requested for other types of shares.
Note that the notification of a password request is just a regular call
notification; thus, the share is not provided in the notification
parameters and it has to be got from the ID of the object associated to
the room (as in "share:password" rooms the object ID is the share
token).
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'lib/Notification/Notifier.php')
-rw-r--r-- | lib/Notification/Notifier.php | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/Notification/Notifier.php b/lib/Notification/Notifier.php index 6e59221c7..17f6ec4b5 100644 --- a/lib/Notification/Notifier.php +++ b/lib/Notification/Notifier.php @@ -37,6 +37,8 @@ use OCP\L10N\IFactory; use OCP\Notification\INotification; use OCP\Notification\INotifier; use OCP\RichObjectStrings\Definitions; +use OCP\Share\Exceptions\ShareNotFound; +use OCP\Share\IManager as IShareManager; class Notifier implements INotifier { @@ -49,6 +51,9 @@ class Notifier implements INotifier { /** @var IUserManager */ protected $userManager; + /** @var IShareManager */ + private $shareManager; + /** @var Manager */ protected $manager; @@ -64,6 +69,7 @@ class Notifier implements INotifier { public function __construct(IFactory $lFactory, IURLGenerator $url, IUserManager $userManager, + IShareManager $shareManager, Manager $manager, ICommentsManager $commentManager, MessageParser $messageParser, @@ -71,6 +77,7 @@ class Notifier implements INotifier { $this->lFactory = $lFactory; $this->url = $url; $this->userManager = $userManager; + $this->shareManager = $shareManager; $this->manager = $manager; $this->commentManager = $commentManager; $this->messageParser = $messageParser; @@ -450,7 +457,13 @@ class Notifier implements INotifier { throw new \InvalidArgumentException('Unknown object type'); } - $sharedWith = $room->getName(); + try { + $share = $this->shareManager->getShareByToken($room->getObjectId()); + } catch (ShareNotFound $e) { + throw new \InvalidArgumentException('Unknown share'); + } + + $sharedWith = $share->getSharedWith(); $notification ->setParsedSubject(str_replace('{email}', $sharedWith, $l->t('{email} requested the password to access a share'))) |