mirror of
https://github.com/nextcloud/server.git
synced 2026-02-20 00:12:30 -05:00
improve admin notification experience
- do not stack notifications, replace them - and replace them once a day only - with LDAP it might end in total spam terror (also push) otherwise Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
parent
50d4963772
commit
7d3457ec73
1 changed files with 27 additions and 8 deletions
|
|
@ -215,19 +215,38 @@ class Registry implements IRegistry {
|
|||
return $userCount;
|
||||
}
|
||||
|
||||
private function notifyAboutReachedUserLimit(IManager $notificationManager) {
|
||||
private function notifyAboutReachedUserLimit(IManager $notificationManager): void {
|
||||
$admins = $this->groupManager->get('admin')->getUsers();
|
||||
foreach ($admins as $admin) {
|
||||
$notification = $notificationManager->createNotification();
|
||||
|
||||
$notification->setApp('core')
|
||||
->setUser($admin->getUID())
|
||||
->setDateTime(new \DateTime())
|
||||
->setObject('user_limit_reached', '1')
|
||||
->setSubject('user_limit_reached');
|
||||
$notification = $notificationManager->createNotification();
|
||||
$notification->setApp('core')
|
||||
->setObject('user_limit_reached', '1')
|
||||
->setSubject('user_limit_reached');
|
||||
|
||||
if ($notificationManager->getCount($notification) > 0
|
||||
&& !$this->reIssue()
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
$notificationManager->markProcessed($notification);
|
||||
$notification->setDateTime(new \DateTime());
|
||||
|
||||
foreach ($admins as $admin) {
|
||||
$notification->setUser($admin->getUID());
|
||||
$notificationManager->notify($notification);
|
||||
}
|
||||
|
||||
$this->logger->warning('The user limit was reached and the new user was not created', ['app' => 'lib']);
|
||||
}
|
||||
|
||||
protected function reIssue(): bool {
|
||||
$lastNotification = (int)$this->config->getAppValue('lib', 'last_subscription_reminder', '0');
|
||||
|
||||
if ((time() - $lastNotification) >= 86400) {
|
||||
$this->config->setAppValue('lib', 'last_subscription_reminder', (string)time());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue