This repository has been archived by the owner on Dec 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from owncloud/feat/notifications-user-disable
feat: send notification when license limit was exceeded
- Loading branch information
Showing
5 changed files
with
123 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?php | ||
|
||
$app = new \OCA\QNAP\Application(); | ||
$app->registerNotifier(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
/** | ||
* @author Vincent Petry <[email protected]> | ||
* | ||
* @copyright Copyright (c) 2016, ownCloud GmbH | ||
* @license AGPL-3.0 | ||
* | ||
* This code is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License, version 3, | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License, version 3, | ||
* along with this program. If not, see <http://www.gnu.org/licenses/> | ||
* | ||
*/ | ||
|
||
namespace OCA\QNAP; | ||
|
||
use OCP\AppFramework\App; | ||
|
||
class Application extends App { | ||
public function __construct(array $urlParams = []) { | ||
parent::__construct('qnap', $urlParams); | ||
} | ||
|
||
/** | ||
* Registers the notifier | ||
*/ | ||
public function registerNotifier() { | ||
$manager = $this->getContainer()->getServer()->getNotificationManager(); | ||
$manager->registerNotifier(function () { | ||
return $this->getContainer()->query(Notifier::class); | ||
}, function () { | ||
$l = \OC::$server->getL10N('qnap'); | ||
return [ | ||
'id' => 'qnap', | ||
'name' => $l->t('QNAP'), | ||
]; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace OCA\QNAP; | ||
|
||
use OCP\L10N\IFactory; | ||
use OCP\Notification\INotification; | ||
use OCP\Notification\INotifier; | ||
|
||
class Notifier implements INotifier { | ||
|
||
/** | ||
* @var IFactory | ||
*/ | ||
private $l10NFactory; | ||
|
||
public function __construct(IFactory $l10NFactory) { | ||
$this->l10NFactory = $l10NFactory; | ||
} | ||
|
||
public function prepare(INotification $notification, $languageCode) { | ||
if ($notification->getApp() !== 'qnap') { | ||
throw new \InvalidArgumentException(); | ||
} | ||
|
||
if ($notification->getSubject() !== 'qnap-license-exceeded') { | ||
return $notification; | ||
} | ||
$l = $this->l10NFactory->get('qnap', $languageCode); | ||
|
||
$message = (string)$l->t('The maximum user limit was exceeded. '); | ||
$message .= (string)$l->t('To add more users, purchase a license from https://software.qnap.com/owncloud.html'); | ||
|
||
$notification->setParsedSubject($l->t('Action Required: Your ownCloud licenses\' user limit was exceeded')); | ||
$notification->setParsedMessage($message); | ||
|
||
return $notification; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters