summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2020-12-02 10:07:34 +0100
committerMorris Jobke <hey@morrisjobke.de>2020-12-02 15:20:03 +0100
commitc0a05c0412e11fd80adc2059b28c8963ba4252dc (patch)
treea2d9542e302c7bae3e6c148de96e101cb7e69749 /lib
parentd87705a8941511a4e3bf8f6c97d6e0f36a42799e (diff)
downloadnextcloud-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')
-rw-r--r--lib/composer/composer/autoload_classmap.php2
-rw-r--r--lib/composer/composer/autoload_static.php2
-rw-r--r--lib/private/Support/Subscription/Registry.php25
3 files changed, 25 insertions, 4 deletions
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php
index 4f04d90b22b..59adc25ba65 100644
--- a/lib/composer/composer/autoload_classmap.php
+++ b/lib/composer/composer/autoload_classmap.php
@@ -926,7 +926,7 @@ return array(
'OC\\Core\\Migrations\\Version20000Date20201109081918' => $baseDir . '/core/Migrations/Version20000Date20201109081918.php',
'OC\\Core\\Migrations\\Version20000Date20201109081919' => $baseDir . '/core/Migrations/Version20000Date20201109081919.php',
'OC\\Core\\Migrations\\Version20000Date20201111081915' => $baseDir . '/core/Migrations/Version20000Date20201111081915.php',
- 'OC\\Core\\Notification\\RemoveLinkSharesNotifier' => $baseDir . '/core/Notification/RemoveLinkSharesNotifier.php',
+ 'OC\\Core\\Notification\\CoreNotifier' => $baseDir . '/core/Notification/CoreNotifier.php',
'OC\\Core\\Service\\LoginFlowV2Service' => $baseDir . '/core/Service/LoginFlowV2Service.php',
'OC\\DB\\Adapter' => $baseDir . '/lib/private/DB/Adapter.php',
'OC\\DB\\AdapterMySQL' => $baseDir . '/lib/private/DB/AdapterMySQL.php',
diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php
index 27972767576..43e45e7cd7d 100644
--- a/lib/composer/composer/autoload_static.php
+++ b/lib/composer/composer/autoload_static.php
@@ -955,7 +955,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'OC\\Core\\Migrations\\Version20000Date20201109081918' => __DIR__ . '/../../..' . '/core/Migrations/Version20000Date20201109081918.php',
'OC\\Core\\Migrations\\Version20000Date20201109081919' => __DIR__ . '/../../..' . '/core/Migrations/Version20000Date20201109081919.php',
'OC\\Core\\Migrations\\Version20000Date20201111081915' => __DIR__ . '/../../..' . '/core/Migrations/Version20000Date20201111081915.php',
- 'OC\\Core\\Notification\\RemoveLinkSharesNotifier' => __DIR__ . '/../../..' . '/core/Notification/RemoveLinkSharesNotifier.php',
+ 'OC\\Core\\Notification\\CoreNotifier' => __DIR__ . '/../../..' . '/core/Notification/CoreNotifier.php',
'OC\\Core\\Service\\LoginFlowV2Service' => __DIR__ . '/../../..' . '/core/Service/LoginFlowV2Service.php',
'OC\\DB\\Adapter' => __DIR__ . '/../../..' . '/lib/private/DB/Adapter.php',
'OC\\DB\\AdapterMySQL' => __DIR__ . '/../../..' . '/lib/private/DB/AdapterMySQL.php',
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']);
}
}