| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,92 @@ |
| 1 |
+<?php |
|
| 2 |
+/** |
|
| 3 |
+ * @copyright 2021 Double Bastion LLC <www.doublebastion.com> |
|
| 4 |
+ * |
|
| 5 |
+ * @author Double Bastion LLC |
|
| 6 |
+ * |
|
| 7 |
+ * @license GNU AGPL version 3 or any later version |
|
| 8 |
+ * |
|
| 9 |
+ * This program is free software; you can redistribute it and/or |
|
| 10 |
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE |
|
| 11 |
+ * License as published by the Free Software Foundation; either |
|
| 12 |
+ * version 3 of the License, or any later version. |
|
| 13 |
+ * |
|
| 14 |
+ * This program is distributed in the hope that it will be useful, |
|
| 15 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 16 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 17 |
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details. |
|
| 18 |
+ * |
|
| 19 |
+ * You should have received a copy of the GNU Affero General Public |
|
| 20 |
+ * License along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
| 21 |
+ * |
|
| 22 |
+ */ |
|
| 23 |
+ |
|
| 24 |
+declare(strict_types=1); |
|
| 25 |
+ |
|
| 26 |
+namespace OCA\SMSRelentless\Notification; |
|
| 27 |
+ |
|
| 28 |
+use OCP\IURLGenerator; |
|
| 29 |
+use OCP\L10N\IFactory; |
|
| 30 |
+use OCP\Notification\INotification; |
|
| 31 |
+use OCP\Notification\INotifier; |
|
| 32 |
+ |
|
| 33 |
+class Notifier implements INotifier {
|
|
| 34 |
+ |
|
| 35 |
+ /** @var IFactory */ |
|
| 36 |
+ protected $l10nFactory; |
|
| 37 |
+ |
|
| 38 |
+ /** @var IURLGenerator */ |
|
| 39 |
+ protected $url; |
|
| 40 |
+ |
|
| 41 |
+ /** |
|
| 42 |
+ * Notifier constructor. |
|
| 43 |
+ * |
|
| 44 |
+ * @param IFactory $l10nFactory |
|
| 45 |
+ * @param IURLGenerator $url |
|
| 46 |
+ */ |
|
| 47 |
+ public function __construct(IFactory $l10nFactory, IURLGenerator $url) {
|
|
| 48 |
+ $this->l10nFactory = $l10nFactory; |
|
| 49 |
+ $this->url = $url; |
|
| 50 |
+ } |
|
| 51 |
+ |
|
| 52 |
+ /** |
|
| 53 |
+ * Identifier of the notifier, only use [a-z0-9_] |
|
| 54 |
+ * |
|
| 55 |
+ * @return string |
|
| 56 |
+ * @since 17.0.0 |
|
| 57 |
+ */ |
|
| 58 |
+ public function getID(): string {
|
|
| 59 |
+ return 'sms_relentless'; |
|
| 60 |
+ } |
|
| 61 |
+ |
|
| 62 |
+ /** |
|
| 63 |
+ * Human readable name describing the notifier |
|
| 64 |
+ * |
|
| 65 |
+ * @return string |
|
| 66 |
+ * @since 17.0.0 |
|
| 67 |
+ */ |
|
| 68 |
+ public function getName(): string {
|
|
| 69 |
+ return $this->l10nFactory->get('sms_relentless')->t('New SMS message');
|
|
| 70 |
+ } |
|
| 71 |
+ |
|
| 72 |
+ /** |
|
| 73 |
+ * @param INotification $notification |
|
| 74 |
+ * @param string $languageCode The code of the language that should be used to prepare the notification |
|
| 75 |
+ * @return INotification |
|
| 76 |
+ * @throws \InvalidArgumentException When the notification was not prepared by a notifier |
|
| 77 |
+ */ |
|
| 78 |
+ public function prepare(INotification $notification, string $languageCode): INotification {
|
|
| 79 |
+ if ($notification->getApp() !== 'sms_relentless') {
|
|
| 80 |
+ // It's not my app, so, throw an exception |
|
| 81 |
+ throw new \InvalidArgumentException(); |
|
| 82 |
+ } |
|
| 83 |
+ |
|
| 84 |
+ // Read the language from the notification |
|
| 85 |
+ $l = $this->l10nFactory->get('sms_relentless', $languageCode);
|
|
| 86 |
+ |
|
| 87 |
+ $notification->setParsedSubject($l->t('New SMS message from SMS Relentless'))
|
|
| 88 |
+ ->setIcon($this->url->getAbsoluteURL($this->url->imagePath('sms_relentless', 'sms_relentless_dark.svg')));
|
|
| 89 |
+ |
|
| 90 |
+ return $notification; |
|
| 91 |
+ } |
|
| 92 |
+} |
| 1 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,92 +0,0 @@ |
| 1 |
-<?php |
|
| 2 |
-/** |
|
| 3 |
- * @copyright 2021 Double Bastion LLC <www.doublebastion.com> |
|
| 4 |
- * |
|
| 5 |
- * @author Double Bastion LLC |
|
| 6 |
- * |
|
| 7 |
- * @license GNU AGPL version 3 or any later version |
|
| 8 |
- * |
|
| 9 |
- * This program is free software; you can redistribute it and/or |
|
| 10 |
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE |
|
| 11 |
- * License as published by the Free Software Foundation; either |
|
| 12 |
- * version 3 of the License, or any later version. |
|
| 13 |
- * |
|
| 14 |
- * This program is distributed in the hope that it will be useful, |
|
| 15 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 16 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 17 |
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details. |
|
| 18 |
- * |
|
| 19 |
- * You should have received a copy of the GNU Affero General Public |
|
| 20 |
- * License along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
| 21 |
- * |
|
| 22 |
- */ |
|
| 23 |
- |
|
| 24 |
-declare(strict_types=1); |
|
| 25 |
- |
|
| 26 |
-namespace OCA\SMSRelentless\Notification; |
|
| 27 |
- |
|
| 28 |
-use OCP\IURLGenerator; |
|
| 29 |
-use OCP\L10N\IFactory; |
|
| 30 |
-use OCP\Notification\INotification; |
|
| 31 |
-use OCP\Notification\INotifier; |
|
| 32 |
- |
|
| 33 |
-class Notifier implements INotifier {
|
|
| 34 |
- |
|
| 35 |
- /** @var IFactory */ |
|
| 36 |
- protected $l10nFactory; |
|
| 37 |
- |
|
| 38 |
- /** @var IURLGenerator */ |
|
| 39 |
- protected $url; |
|
| 40 |
- |
|
| 41 |
- /** |
|
| 42 |
- * Notifier constructor. |
|
| 43 |
- * |
|
| 44 |
- * @param IFactory $l10nFactory |
|
| 45 |
- * @param IURLGenerator $url |
|
| 46 |
- */ |
|
| 47 |
- public function __construct(IFactory $l10nFactory, IURLGenerator $url) {
|
|
| 48 |
- $this->l10nFactory = $l10nFactory; |
|
| 49 |
- $this->url = $url; |
|
| 50 |
- } |
|
| 51 |
- |
|
| 52 |
- /** |
|
| 53 |
- * Identifier of the notifier, only use [a-z0-9_] |
|
| 54 |
- * |
|
| 55 |
- * @return string |
|
| 56 |
- * @since 17.0.0 |
|
| 57 |
- */ |
|
| 58 |
- public function getID(): string {
|
|
| 59 |
- return 'sms_relentless'; |
|
| 60 |
- } |
|
| 61 |
- |
|
| 62 |
- /** |
|
| 63 |
- * Human readable name describing the notifier |
|
| 64 |
- * |
|
| 65 |
- * @return string |
|
| 66 |
- * @since 17.0.0 |
|
| 67 |
- */ |
|
| 68 |
- public function getName(): string {
|
|
| 69 |
- return $this->l10nFactory->get('sms_relentless')->t('New SMS message');
|
|
| 70 |
- } |
|
| 71 |
- |
|
| 72 |
- /** |
|
| 73 |
- * @param INotification $notification |
|
| 74 |
- * @param string $languageCode The code of the language that should be used to prepare the notification |
|
| 75 |
- * @return INotification |
|
| 76 |
- * @throws \InvalidArgumentException When the notification was not prepared by a notifier |
|
| 77 |
- */ |
|
| 78 |
- public function prepare(INotification $notification, string $languageCode): INotification {
|
|
| 79 |
- if ($notification->getApp() !== 'sms_relentless') {
|
|
| 80 |
- // It's not my app, so, throw an exception |
|
| 81 |
- throw new \InvalidArgumentException(); |
|
| 82 |
- } |
|
| 83 |
- |
|
| 84 |
- // Read the language from the notification |
|
| 85 |
- $l = $this->l10nFactory->get('sms_relentless', $languageCode);
|
|
| 86 |
- |
|
| 87 |
- $notification->setParsedSubject($l->t('New SMS message from SMS Relentless'))
|
|
| 88 |
- ->setIcon($this->url->imagePath('sms_relentless', 'sms_relentless_dark.svg'));
|
|
| 89 |
- |
|
| 90 |
- return $notification; |
|
| 91 |
- } |
|
| 92 |
-} |
| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,92 @@ |
| 1 |
+<?php |
|
| 2 |
+/** |
|
| 3 |
+ * @copyright 2021 Double Bastion LLC <www.doublebastion.com> |
|
| 4 |
+ * |
|
| 5 |
+ * @author Double Bastion LLC |
|
| 6 |
+ * |
|
| 7 |
+ * @license GNU AGPL version 3 or any later version |
|
| 8 |
+ * |
|
| 9 |
+ * This program is free software; you can redistribute it and/or |
|
| 10 |
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE |
|
| 11 |
+ * License as published by the Free Software Foundation; either |
|
| 12 |
+ * version 3 of the License, or any later version. |
|
| 13 |
+ * |
|
| 14 |
+ * This program is distributed in the hope that it will be useful, |
|
| 15 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 16 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 17 |
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details. |
|
| 18 |
+ * |
|
| 19 |
+ * You should have received a copy of the GNU Affero General Public |
|
| 20 |
+ * License along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
| 21 |
+ * |
|
| 22 |
+ */ |
|
| 23 |
+ |
|
| 24 |
+declare(strict_types=1); |
|
| 25 |
+ |
|
| 26 |
+namespace OCA\SMSRelentless\Notification; |
|
| 27 |
+ |
|
| 28 |
+use OCP\IURLGenerator; |
|
| 29 |
+use OCP\L10N\IFactory; |
|
| 30 |
+use OCP\Notification\INotification; |
|
| 31 |
+use OCP\Notification\INotifier; |
|
| 32 |
+ |
|
| 33 |
+class Notifier implements INotifier {
|
|
| 34 |
+ |
|
| 35 |
+ /** @var IFactory */ |
|
| 36 |
+ protected $l10nFactory; |
|
| 37 |
+ |
|
| 38 |
+ /** @var IURLGenerator */ |
|
| 39 |
+ protected $url; |
|
| 40 |
+ |
|
| 41 |
+ /** |
|
| 42 |
+ * Notifier constructor. |
|
| 43 |
+ * |
|
| 44 |
+ * @param IFactory $l10nFactory |
|
| 45 |
+ * @param IURLGenerator $url |
|
| 46 |
+ */ |
|
| 47 |
+ public function __construct(IFactory $l10nFactory, IURLGenerator $url) {
|
|
| 48 |
+ $this->l10nFactory = $l10nFactory; |
|
| 49 |
+ $this->url = $url; |
|
| 50 |
+ } |
|
| 51 |
+ |
|
| 52 |
+ /** |
|
| 53 |
+ * Identifier of the notifier, only use [a-z0-9_] |
|
| 54 |
+ * |
|
| 55 |
+ * @return string |
|
| 56 |
+ * @since 17.0.0 |
|
| 57 |
+ */ |
|
| 58 |
+ public function getID(): string {
|
|
| 59 |
+ return 'sms_relentless'; |
|
| 60 |
+ } |
|
| 61 |
+ |
|
| 62 |
+ /** |
|
| 63 |
+ * Human readable name describing the notifier |
|
| 64 |
+ * |
|
| 65 |
+ * @return string |
|
| 66 |
+ * @since 17.0.0 |
|
| 67 |
+ */ |
|
| 68 |
+ public function getName(): string {
|
|
| 69 |
+ return $this->l10nFactory->get('sms_relentless')->t('New SMS message');
|
|
| 70 |
+ } |
|
| 71 |
+ |
|
| 72 |
+ /** |
|
| 73 |
+ * @param INotification $notification |
|
| 74 |
+ * @param string $languageCode The code of the language that should be used to prepare the notification |
|
| 75 |
+ * @return INotification |
|
| 76 |
+ * @throws \InvalidArgumentException When the notification was not prepared by a notifier |
|
| 77 |
+ */ |
|
| 78 |
+ public function prepare(INotification $notification, string $languageCode): INotification {
|
|
| 79 |
+ if ($notification->getApp() !== 'sms_relentless') {
|
|
| 80 |
+ // It's not my app, so, throw an exception |
|
| 81 |
+ throw new \InvalidArgumentException(); |
|
| 82 |
+ } |
|
| 83 |
+ |
|
| 84 |
+ // Read the language from the notification |
|
| 85 |
+ $l = $this->l10nFactory->get('sms_relentless', $languageCode);
|
|
| 86 |
+ |
|
| 87 |
+ $notification->setParsedSubject($l->t('New SMS message from SMS Relentless'))
|
|
| 88 |
+ ->setIcon($this->url->imagePath('sms_relentless', 'sms_relentless_dark.svg'));
|
|
| 89 |
+ |
|
| 90 |
+ return $notification; |
|
| 91 |
+ } |
|
| 92 |
+} |