diff options
author | Daniel Rudolf <github.com@daniel-rudolf.de> | 2021-03-27 17:18:56 +0300 |
---|---|---|
committer | Daniel Rudolf <github.com@daniel-rudolf.de> | 2021-03-27 17:48:50 +0300 |
commit | d3ba33b644b5d098090ad2d9cd48ad1a28878ba2 (patch) | |
tree | f5bb4b3465d9379a788e330d43bdd816c140bcf8 /lib/Service/ShareService.php | |
parent | 25688c584d7c0ec73411e80a6e8ed7c3ee053bc3 (diff) |
Move ShareController::sendInvitation() logic to ShareService
Signed-off-by: Daniel Rudolf <github.com@daniel-rudolf.de>
Diffstat (limited to 'lib/Service/ShareService.php')
-rw-r--r-- | lib/Service/ShareService.php | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/lib/Service/ShareService.php b/lib/Service/ShareService.php index c1cf37f6..4d576687 100644 --- a/lib/Service/ShareService.php +++ b/lib/Service/ShareService.php @@ -67,6 +67,9 @@ class ShareService { /** @var Acl */ private $acl; + /** @var NotificationService */ + private $notificationService; + public function __construct( string $AppName, LoggerInterface $logger, @@ -76,7 +79,8 @@ class ShareService { ShareMapper $shareMapper, Share $share, MailService $mailService, - Acl $acl + Acl $acl, + NotificationService $notificationService ) { $this->appName = $AppName; $this->logger = $logger; @@ -87,6 +91,7 @@ class ShareService { $this->share = $share; $this->mailService = $mailService; $this->acl = $acl; + $this->notificationService = $notificationService; } /** @@ -347,4 +352,24 @@ class ShareService { } return $token; } + + /** + * Sent invitation mails for a share + * Additionally send notification via notifications + */ + public function sendInvitation(string $token): array { + $share = $this->get($token); + if ($share->getType() === Share::TYPE_USER) { + $this->notificationService->sendInvitation($share->getPollId(), $share->getUserId()); + // TODO: skip this atm, to send invitations as mail too, if user is a site user + // $sentResult = ['sentMails' => [new User($share->getuserId())]]; + // $this->shareService->setInvitationSent($token); + } elseif ($share->getType() === Share::TYPE_GROUP) { + foreach ($share->getMembers() as $member) { + $this->notificationService->sendInvitation($share->getPollId(), $member->getId()); + } + } + + return $this->mailService->sendInvitation($token); + } } |