IManager.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2016, ownCloud, Inc.
  5. *
  6. * @author Joas Schilling <coding@schilljs.com>
  7. * @author Roeland Jago Douma <roeland@famdouma.nl>
  8. *
  9. * @license AGPL-3.0
  10. *
  11. * This code is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License, version 3,
  13. * as published by the Free Software Foundation.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License, version 3,
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>
  22. *
  23. */
  24. namespace OCP\Notification;
  25. /**
  26. * Interface IManager
  27. *
  28. * @since 9.0.0
  29. */
  30. interface IManager extends IApp, INotifier {
  31. /**
  32. * @param string $appClass The service must implement IApp, otherwise a
  33. * \InvalidArgumentException is thrown later
  34. * @since 17.0.0
  35. */
  36. public function registerApp(string $appClass): void;
  37. /**
  38. * @param \Closure $service The service must implement INotifier, otherwise a
  39. * \InvalidArgumentException is thrown later
  40. * @param \Closure $info An array with the keys 'id' and 'name' containing
  41. * the app id and the app name
  42. * @deprecated 17.0.0 use registerNotifierService instead.
  43. * @since 8.2.0 - Parameter $info was added in 9.0.0
  44. */
  45. public function registerNotifier(\Closure $service, \Closure $info);
  46. /**
  47. * @param string $notifierService The service must implement INotifier, otherwise a
  48. * \InvalidArgumentException is thrown later
  49. * @since 17.0.0
  50. * @deprecated 22.0.0 use the IBootStrap registration context
  51. */
  52. public function registerNotifierService(string $notifierService): void;
  53. /**
  54. * @return INotifier[]
  55. * @since 9.0.0
  56. */
  57. public function getNotifiers(): array;
  58. /**
  59. * @return INotification
  60. * @since 9.0.0
  61. */
  62. public function createNotification(): INotification;
  63. /**
  64. * @return bool
  65. * @since 9.0.0
  66. */
  67. public function hasNotifiers(): bool;
  68. /**
  69. * @param bool $preparingPushNotification
  70. * @since 14.0.0
  71. */
  72. public function setPreparingPushNotification(bool $preparingPushNotification): void;
  73. /**
  74. * @return bool
  75. * @since 14.0.0
  76. */
  77. public function isPreparingPushNotification(): bool;
  78. /**
  79. * @since 18.0.0
  80. */
  81. public function dismissNotification(INotification $notification): void;
  82. /**
  83. * Start deferring notifications until `flush()` is called
  84. *
  85. * The calling app should only "flush" when it got returned true on the defer call,
  86. * otherwise another app is deferring the sending already.
  87. * @return bool
  88. * @since 20.0.0
  89. */
  90. public function defer(): bool;
  91. /**
  92. * Send all deferred notifications that have been stored since `defer()` was called
  93. *
  94. * @since 20.0.0
  95. */
  96. public function flush(): void;
  97. /**
  98. * Whether the server can use the hosted push notification service
  99. *
  100. * We want to keep offering our push notification service for free, but large
  101. * users overload our infrastructure. For this reason we have to rate-limit the
  102. * use of push notifications. If you need this feature, consider using Nextcloud Enterprise.
  103. *
  104. * @since 23.0.0
  105. */
  106. public function isFairUseOfFreePushService(): bool;
  107. }