diff options
author | Morris Jobke <hey@morrisjobke.de> | 2020-12-02 10:07:34 +0100 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2020-12-02 15:20:03 +0100 |
commit | c0a05c0412e11fd80adc2059b28c8963ba4252dc (patch) | |
tree | a2d9542e302c7bae3e6c148de96e101cb7e69749 /lib/private/Support | |
parent | d87705a8941511a4e3bf8f6c97d6e0f36a42799e (diff) | |
download | nextcloud-server-c0a05c0412e11fd80adc2059b28c8963ba4252dc.tar.gz nextcloud-server-c0a05c0412e11fd80adc2059b28c8963ba4252dc.zip |
Add notification for user limit
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'lib/private/Support')
-rw-r--r-- | lib/private/Support/Subscription/Registry.php | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/lib/private/Support/Subscription/Registry.php b/lib/private/Support/Subscription/Registry.php index ba9c4099b9b..72bae2adc8e 100644 --- a/lib/private/Support/Subscription/Registry.php +++ b/lib/private/Support/Subscription/Registry.php @@ -31,8 +31,10 @@ namespace OC\Support\Subscription; use OC\User\Backend; use OCP\AppFramework\QueryException; use OCP\IConfig; +use OCP\IGroupManager; use OCP\IServerContainer; use OCP\IUserManager; +use OCP\Notification\IManager; use OCP\Support\Subscription\Exception\AlreadyRegisteredException; use OCP\Support\Subscription\IRegistry; use OCP\Support\Subscription\ISubscription; @@ -54,17 +56,25 @@ class Registry implements IRegistry { private $container; /** @var IUserManager */ private $userManager; + /** @var IGroupManager */ + private $groupManager; /** @var LoggerInterface */ private $logger; + /** @var IManager */ + private $notificationManager; public function __construct(IConfig $config, IServerContainer $container, IUserManager $userManager, - LoggerInterface $logger) { + IGroupManager $groupManager, + LoggerInterface $logger, + IManager $notificationManager) { $this->config = $config; $this->container = $container; $this->userManager = $userManager; + $this->groupManager = $groupManager; $this->logger = $logger; + $this->notificationManager = $notificationManager; } private function getSubscription(): ?ISubscription { @@ -208,7 +218,18 @@ class Registry implements IRegistry { } private function notifyAboutReachedUserLimit() { - // TODO notify admin about reached user limit + $admins = $this->groupManager->get('admin')->getUsers(); + foreach ($admins as $admin) { + $notification = $this->notificationManager->createNotification(); + + $notification->setApp('core') + ->setUser($admin->getUID()) + ->setDateTime(new \DateTime()) + ->setObject('user_limit_reached', '1') + ->setSubject('user_limit_reached'); + $this->notificationManager->notify($notification); + } + $this->logger->warning('The user limit was reached and the new user was not created', ['app' => 'lib']); } } |