diff options
Diffstat (limited to 'lib/private/share/mailnotifications.php')
-rw-r--r-- | lib/private/share/mailnotifications.php | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/lib/private/share/mailnotifications.php b/lib/private/share/mailnotifications.php index 2797e5ed99b..c7747fd38c1 100644 --- a/lib/private/share/mailnotifications.php +++ b/lib/private/share/mailnotifications.php @@ -28,11 +28,12 @@ namespace OC\Share; use DateTime; -use OCP\IConfig; use OCP\IL10N; +use OCP\IUser; use OCP\Mail\IMailer; use OCP\ILogger; use OCP\Defaults; +use OCP\Util; /** * Class MailNotifications @@ -41,16 +42,14 @@ use OCP\Defaults; */ class MailNotifications { - /** @var string sender userId */ - private $userId; + /** @var IUser sender userId */ + private $user; /** @var string sender email address */ private $replyTo; /** @var string */ private $senderDisplayName; /** @var IL10N */ private $l; - /** @var IConfig */ - private $config; /** @var IMailer */ private $mailer; /** @var Defaults */ @@ -59,34 +58,31 @@ class MailNotifications { private $logger; /** - * @param string $uid user id - * @param IConfig $config + * @param IUser $user * @param IL10N $l10n * @param IMailer $mailer * @param ILogger $logger * @param Defaults $defaults */ - public function __construct($uid, - IConfig $config, + public function __construct(IUser $user, IL10N $l10n, IMailer $mailer, ILogger $logger, Defaults $defaults) { $this->l = $l10n; - $this->userId = $uid; - $this->config = $config; + $this->user = $user; $this->mailer = $mailer; $this->logger = $logger; $this->defaults = $defaults; - $this->replyTo = $this->config->getUserValue($this->userId, 'settings', 'email', null); - $this->senderDisplayName = \OCP\User::getDisplayName($this->userId); + $this->replyTo = $this->user->getEMailAddress(); + $this->senderDisplayName = $this->user->getDisplayName(); } /** * inform users if a file was shared with them * - * @param array $recipientList list of recipients + * @param IUser[] $recipientList list of recipients * @param string $itemSource shared item source * @param string $itemType shared item type * @return array list of user to whom the mail send operation failed @@ -95,8 +91,8 @@ class MailNotifications { $noMail = []; foreach ($recipientList as $recipient) { - $recipientDisplayName = \OCP\User::getDisplayName($recipient); - $to = $this->config->getUserValue($recipient, 'settings', 'email', ''); + $recipientDisplayName = $recipient->getDisplayName(); + $to = $recipient->getEMailAddress(); if ($to === '') { $noMail[] = $recipientDisplayName; @@ -233,4 +229,14 @@ class MailNotifications { return [$htmlMail, $plainTextMail]; } + /** + * @param $itemSource + * @param $itemType + * @param IUser $recipient + * @return array + */ + protected function getItemSharedWithUser($itemSource, $itemType, $recipient) { + return Share::getItemSharedWithUser($itemType, $itemSource, $recipient->getUID()); + } + } |