RemoveLinkSharesNotifier.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl>
  5. *
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Joas Schilling <coding@schilljs.com>
  8. * @author Roeland Jago Douma <roeland@famdouma.nl>
  9. *
  10. * @license GNU AGPL version 3 or any later version
  11. *
  12. * This program is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU Affero General Public License as
  14. * published by the Free Software Foundation, either version 3 of the
  15. * License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  24. *
  25. */
  26. namespace OC\Core\Notification;
  27. use OCP\L10N\IFactory;
  28. use OCP\Notification\INotification;
  29. use OCP\Notification\INotifier;
  30. class RemoveLinkSharesNotifier implements INotifier {
  31. /** @var IFactory */
  32. private $l10nFactory;
  33. public function __construct(IFactory $factory) {
  34. $this->l10nFactory = $factory;
  35. }
  36. /**
  37. * Identifier of the notifier, only use [a-z0-9_]
  38. *
  39. * @return string
  40. * @since 17.0.0
  41. */
  42. public function getID(): string {
  43. return 'core';
  44. }
  45. /**
  46. * Human readable name describing the notifier
  47. *
  48. * @return string
  49. * @since 17.0.0
  50. */
  51. public function getName(): string {
  52. return $this->l10nFactory->get('core')->t('Nextcloud Server');
  53. }
  54. public function prepare(INotification $notification, string $languageCode): INotification {
  55. if ($notification->getApp() !== 'core') {
  56. throw new \InvalidArgumentException();
  57. }
  58. $l = $this->l10nFactory->get('core', $languageCode);
  59. if ($notification->getSubject() === 'repair_exposing_links') {
  60. $notification->setParsedSubject($l->t('Some of your link shares have been removed'));
  61. $notification->setParsedMessage($l->t('Due to a security bug we had to remove some of your link shares. Please see the link for more information.'));
  62. $notification->setLink('https://nextcloud.com/security/advisory/?id=NC-SA-2019-003');
  63. return $notification;
  64. }
  65. throw new \InvalidArgumentException('Invalid subject');
  66. }
  67. }