diff --git a/3rdparty b/3rdparty index 49ccfbb28661b..b87afe46ba2aa 160000 --- a/3rdparty +++ b/3rdparty @@ -1 +1 @@ -Subproject commit 49ccfbb28661b9ef7743c1725cd2571259215929 +Subproject commit b87afe46ba2aafd64df7c61419bffac4065c165d diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 52dab1ddf3f74..e9615acedd5e3 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -363,6 +363,18 @@ 'OCP\\Preview\\IProvider' => $baseDir . '/lib/public/Preview/IProvider.php', 'OCP\\Preview\\IProviderV2' => $baseDir . '/lib/public/Preview/IProviderV2.php', 'OCP\\Preview\\IVersionedPreviewFile' => $baseDir . '/lib/public/Preview/IVersionedPreviewFile.php', + 'OCP\\Push\\Exceptions\\ItemNotFoundException' => $baseDir . '/lib/public/Push/Exceptions/ItemNotFoundException.php', + 'OCP\\Push\\Exceptions\\PushInstallException' => $baseDir . '/lib/public/Push/Exceptions/PushInstallException.php', + 'OCP\\Push\\Exceptions\\UnknownStreamTypeException' => $baseDir . '/lib/public/Push/Exceptions/UnknownStreamTypeException.php', + 'OCP\\Push\\Helper\\IPushHelper' => $baseDir . '/lib/public/Push/Helper/IPushHelper.php', + 'OCP\\Push\\IPushManager' => $baseDir . '/lib/public/Push/IPushManager.php', + 'OCP\\Push\\Model\\Helper\\IPushCallback' => $baseDir . '/lib/public/Push/Model/Helper/IPushCallback.php', + 'OCP\\Push\\Model\\Helper\\IPushEvent' => $baseDir . '/lib/public/Push/Model/Helper/IPushEvent.php', + 'OCP\\Push\\Model\\Helper\\IPushNotification' => $baseDir . '/lib/public/Push/Model/Helper/IPushNotification.php', + 'OCP\\Push\\Model\\IPushItem' => $baseDir . '/lib/public/Push/Model/IPushItem.php', + 'OCP\\Push\\Model\\IPushRecipients' => $baseDir . '/lib/public/Push/Model/IPushRecipients.php', + 'OCP\\Push\\Model\\IPushWrapper' => $baseDir . '/lib/public/Push/Model/IPushWrapper.php', + 'OCP\\Push\\Service\\IPushService' => $baseDir . '/lib/public/Push/Service/IPushService.php', 'OCP\\Remote\\Api\\IApiCollection' => $baseDir . '/lib/public/Remote/Api/IApiCollection.php', 'OCP\\Remote\\Api\\IApiFactory' => $baseDir . '/lib/public/Remote/Api/IApiFactory.php', 'OCP\\Remote\\Api\\ICapabilitiesApi' => $baseDir . '/lib/public/Remote/Api/ICapabilitiesApi.php', @@ -1056,6 +1068,13 @@ 'OC\\Preview\\Watcher' => $baseDir . '/lib/private/Preview/Watcher.php', 'OC\\Preview\\WatcherConnector' => $baseDir . '/lib/private/Preview/WatcherConnector.php', 'OC\\Preview\\XBitmap' => $baseDir . '/lib/private/Preview/XBitmap.php', + 'OC\\Push\\Model\\Helper\\PushCallback' => $baseDir . '/lib/private/Push/Model/Helper/PushCallback.php', + 'OC\\Push\\Model\\Helper\\PushEvent' => $baseDir . '/lib/private/Push/Model/Helper/PushEvent.php', + 'OC\\Push\\Model\\Helper\\PushNotification' => $baseDir . '/lib/private/Push/Model/Helper/PushNotification.php', + 'OC\\Push\\Model\\PushItem' => $baseDir . '/lib/private/Push/Model/PushItem.php', + 'OC\\Push\\Model\\PushRecipients' => $baseDir . '/lib/private/Push/Model/PushRecipients.php', + 'OC\\Push\\Model\\PushWrapper' => $baseDir . '/lib/private/Push/Model/PushWrapper.php', + 'OC\\Push\\PushManager' => $baseDir . '/lib/private/Push/PushManager.php', 'OC\\RedisFactory' => $baseDir . '/lib/private/RedisFactory.php', 'OC\\Remote\\Api\\ApiBase' => $baseDir . '/lib/private/Remote/Api/ApiBase.php', 'OC\\Remote\\Api\\ApiCollection' => $baseDir . '/lib/private/Remote/Api/ApiCollection.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index b4d564af319b7..e08c7348530a6 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -397,6 +397,18 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OCP\\Preview\\IProvider' => __DIR__ . '/../../..' . '/lib/public/Preview/IProvider.php', 'OCP\\Preview\\IProviderV2' => __DIR__ . '/../../..' . '/lib/public/Preview/IProviderV2.php', 'OCP\\Preview\\IVersionedPreviewFile' => __DIR__ . '/../../..' . '/lib/public/Preview/IVersionedPreviewFile.php', + 'OCP\\Push\\Exceptions\\ItemNotFoundException' => __DIR__ . '/../../..' . '/lib/public/Push/Exceptions/ItemNotFoundException.php', + 'OCP\\Push\\Exceptions\\PushInstallException' => __DIR__ . '/../../..' . '/lib/public/Push/Exceptions/PushInstallException.php', + 'OCP\\Push\\Exceptions\\UnknownStreamTypeException' => __DIR__ . '/../../..' . '/lib/public/Push/Exceptions/UnknownStreamTypeException.php', + 'OCP\\Push\\Helper\\IPushHelper' => __DIR__ . '/../../..' . '/lib/public/Push/Helper/IPushHelper.php', + 'OCP\\Push\\IPushManager' => __DIR__ . '/../../..' . '/lib/public/Push/IPushManager.php', + 'OCP\\Push\\Model\\Helper\\IPushCallback' => __DIR__ . '/../../..' . '/lib/public/Push/Model/Helper/IPushCallback.php', + 'OCP\\Push\\Model\\Helper\\IPushEvent' => __DIR__ . '/../../..' . '/lib/public/Push/Model/Helper/IPushEvent.php', + 'OCP\\Push\\Model\\Helper\\IPushNotification' => __DIR__ . '/../../..' . '/lib/public/Push/Model/Helper/IPushNotification.php', + 'OCP\\Push\\Model\\IPushItem' => __DIR__ . '/../../..' . '/lib/public/Push/Model/IPushItem.php', + 'OCP\\Push\\Model\\IPushRecipients' => __DIR__ . '/../../..' . '/lib/public/Push/Model/IPushRecipients.php', + 'OCP\\Push\\Model\\IPushWrapper' => __DIR__ . '/../../..' . '/lib/public/Push/Model/IPushWrapper.php', + 'OCP\\Push\\Service\\IPushService' => __DIR__ . '/../../..' . '/lib/public/Push/Service/IPushService.php', 'OCP\\Remote\\Api\\IApiCollection' => __DIR__ . '/../../..' . '/lib/public/Remote/Api/IApiCollection.php', 'OCP\\Remote\\Api\\IApiFactory' => __DIR__ . '/../../..' . '/lib/public/Remote/Api/IApiFactory.php', 'OCP\\Remote\\Api\\ICapabilitiesApi' => __DIR__ . '/../../..' . '/lib/public/Remote/Api/ICapabilitiesApi.php', @@ -1090,6 +1102,13 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OC\\Preview\\Watcher' => __DIR__ . '/../../..' . '/lib/private/Preview/Watcher.php', 'OC\\Preview\\WatcherConnector' => __DIR__ . '/../../..' . '/lib/private/Preview/WatcherConnector.php', 'OC\\Preview\\XBitmap' => __DIR__ . '/../../..' . '/lib/private/Preview/XBitmap.php', + 'OC\\Push\\Model\\Helper\\PushCallback' => __DIR__ . '/../../..' . '/lib/private/Push/Model/Helper/PushCallback.php', + 'OC\\Push\\Model\\Helper\\PushEvent' => __DIR__ . '/../../..' . '/lib/private/Push/Model/Helper/PushEvent.php', + 'OC\\Push\\Model\\Helper\\PushNotification' => __DIR__ . '/../../..' . '/lib/private/Push/Model/Helper/PushNotification.php', + 'OC\\Push\\Model\\PushItem' => __DIR__ . '/../../..' . '/lib/private/Push/Model/PushItem.php', + 'OC\\Push\\Model\\PushRecipients' => __DIR__ . '/../../..' . '/lib/private/Push/Model/PushRecipients.php', + 'OC\\Push\\Model\\PushWrapper' => __DIR__ . '/../../..' . '/lib/private/Push/Model/PushWrapper.php', + 'OC\\Push\\PushManager' => __DIR__ . '/../../..' . '/lib/private/Push/PushManager.php', 'OC\\RedisFactory' => __DIR__ . '/../../..' . '/lib/private/RedisFactory.php', 'OC\\Remote\\Api\\ApiBase' => __DIR__ . '/../../..' . '/lib/private/Remote/Api/ApiBase.php', 'OC\\Remote\\Api\\ApiCollection' => __DIR__ . '/../../..' . '/lib/private/Remote/Api/ApiCollection.php', diff --git a/lib/private/Push/Model/Helper/PushCallback.php b/lib/private/Push/Model/Helper/PushCallback.php new file mode 100644 index 0000000000000..4d5fc2b3f25af --- /dev/null +++ b/lib/private/Push/Model/Helper/PushCallback.php @@ -0,0 +1,126 @@ + + * @copyright 2019, Maxence Lange + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * 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 + * along with this program. If not, see . + * + */ + + +namespace OC\Push\Model\Helper; + + +use daita\NcSmallPhpTools\Traits\TArrayTools; +use JsonSerializable; +use OC\Push\Model\PushRecipients; +use OCP\Push\Model\Helper\IPushCallback; + + +/** + * Class PushCallback + * + * @since 18.0.0 + * + * @package OC\Push\Model\Helper + */ +class PushCallback extends PushRecipients implements IPushCallback, JsonSerializable { + + + use TArrayTools; + + + /** @var array */ + private $payload = ''; + + + /** + * PushCallback constructor. + * + * @param string $app + * @param string $source + * + * @since 18.0.0 + */ + public function __construct(string $app = '', string $source = '') { + $this->setApp($app); + $this->setSource($source); + } + + + /** + * @return array + * + * @since 18.0.0 + */ + public function getPayload(): array { + if ($this->payload instanceof JsonSerializable) { + return $this->payload->jsonSerialize(); + } + + return $this->payload; + } + + /** + * @param array $payload + * + * @return IPushCallback + * + * @since 18.0.0 + */ + public function setPayload(array $payload): IPushCallback { + $this->payload = $payload; + + return $this; + } + + /** + * @param JsonSerializable $payload + * + * @return self + * + * @since 18.0.0 + */ + public function setPayloadSerializable(JsonSerializable $payload): IPushCallback { + $this->payload = $payload; + + return $this; + } + + + /** + * @return array + */ + public function jsonSerialize(): array { + return array_merge( + parent::jsonSerialize(), + [ + 'app' => $this->getApp(), + 'source' => $this->getSource(), + 'payload' => $this->payload + ] + ); + } + +} + diff --git a/lib/private/Push/Model/Helper/PushEvent.php b/lib/private/Push/Model/Helper/PushEvent.php new file mode 100644 index 0000000000000..6ff0b31f8bc2e --- /dev/null +++ b/lib/private/Push/Model/Helper/PushEvent.php @@ -0,0 +1,151 @@ + + * @copyright 2019, Maxence Lange + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * 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 + * along with this program. If not, see . + * + */ + + +namespace OC\Push\Model\Helper; + + +use daita\NcSmallPhpTools\Traits\TArrayTools; +use JsonSerializable; +use OC\Push\Model\PushRecipients; +use OCP\Push\Model\Helper\IPushEvent; + + +/** + * Class PushEvent + * + * @since 18.0.0 + * + * @package OC\Push\Model\Helper + */ +class PushEvent extends PushRecipients implements IPushEvent, JsonSerializable { + + + use TArrayTools; + + /** @var string */ + private $command = ''; + + /** @var array */ + private $payload = []; + + + /** + * PushEvent constructor. + * + * @param string $app + * @param string $command + * + * @since 18.0.0 + */ + public function __construct($app = '', $command = '') { + $this->setApp($app); + $this->command = $command; + } + + + /** + * @return string + * + * @since 18.0.0 + */ + public function getCommand(): string { + return $this->command; + } + + /** + * @param string $command + * + * @return IPushEvent + * + * @since 18.0.0 + */ + public function setCommand(string $command): IPushEvent { + $this->command = $command; + + return $this; + } + + + /** + * @return array + * + * @since 18.0.0 + */ + public function getPayload(): array { + if ($this->payload instanceof JsonSerializable) { + return $this->payload->jsonSerialize(); + } + + return $this->payload; + } + + /** + * @param array $payload + * + * @return IPushEvent + * + * @since 18.0.0 + */ + public function setPayload(array $payload): IPushEvent { + $this->payload = $payload; + + return $this; + } + + /** + * @param JsonSerializable $payload + * + * @return IPushEvent + * + * @since 18.0.0 + */ + public function setPayloadSerializable(JsonSerializable $payload): IPushEvent { + $this->payload = $payload->jsonSerialize(); + + return $this; + } + + + /** + * @return array + */ + public function jsonSerialize(): array { + return array_merge( + parent::jsonSerialize(), + [ + 'app' => $this->getApp(), + 'command' => $this->getCommand(), + 'payload' => $this->getPayload() + ] + ); + } + +} + diff --git a/lib/private/Push/Model/Helper/PushNotification.php b/lib/private/Push/Model/Helper/PushNotification.php new file mode 100644 index 0000000000000..c6385387d9c2d --- /dev/null +++ b/lib/private/Push/Model/Helper/PushNotification.php @@ -0,0 +1,214 @@ + + * @copyright 2019, Maxence Lange + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * 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 + * along with this program. If not, see . + * + */ + + +namespace OC\Push\Model\Helper; + + +use daita\NcSmallPhpTools\Traits\TArrayTools; +use JsonSerializable; +use OC\Push\Model\PushRecipients; +use OCP\Push\Model\Helper\IPushNotification; +use OCP\Push\Model\IPushItem; + + +/** + * Class PushNotification + * + * @since 18.0.0 + * + * @package OC\Push\Model\Helper + */ +class PushNotification extends PushRecipients implements IPushNotification, JsonSerializable { + + + use TArrayTools; + + + /** @var string */ + private $message = ''; + + /** @var string */ + private $level = ''; + + /** @var string */ + private $link = ''; + + /** @var int */ + private $ttl = -1; + + + /** + * PushNotification constructor. + * + * @param string $app + * @param int $ttl + * + * @since 18.0.0 + */ + public function __construct($app = '', $ttl = IPushItem::TTL_INSTANT) { + $this->setApp($app); + $this->ttl = $ttl; + } + + + /** + * @return string + * + * @since 18.0.0 + */ + public function getTitle(): string { + return $this->getSource(); + } + + /** + * @param string $title + * + * @return IPushNotification + * + * @since 18.0.0 + */ + public function setTitle(string $title): IPushNotification { + $this->setSource($title); + + return $this; + } + + + /** + * @return string + * + * @since 18.0.0 + */ + public function getMessage(): string { + return $this->message; + } + + /** + * @param string $message + * + * @return IPushNotification + * + * @since 18.0.0 + */ + public function setMessage(string $message): IPushNotification { + $this->message = $message; + + return $this; + } + + + /** + * @return string + * + * @since 18.0.0 + */ + public function getLevel(): string { + return $this->level; + } + + /** + * @param string $level + * + * @return IPushNotification + * + * @since 18.0.0 + */ + public function setLevel(string $level): IPushNotification { + $this->level = $level; + + return $this; + } + + + /** + * @return string + * + * @since 18.0.0 + */ + public function getLink(): string { + return $this->link; + } + + /** + * @param string $link + * + * @return IPushNotification + * + * @since 18.0.0 + */ + public function setLink(string $link): IPushNotification { + $this->link = $link; + + return $this; + } + + + /** + * @return int + * + * @since 18.0.0 + */ + public function getTtl(): int { + return $this->ttl; + } + + /** + * @param int $ttl + * + * @return IPushNotification + * + * @since 18.0.0 + */ + public function setTtl(int $ttl): IPushNotification { + $this->ttl = $ttl; + + return $this; + } + + + /** + * @return array + */ + public function jsonSerialize(): array { + return array_merge( + parent::jsonSerialize(), + [ + 'app' => $this->getApp(), + 'title' => $this->getTitle(), + 'type' => $this->getMessage(), + 'source' => $this->getLevel(), + 'link' => $this->getLink(), + 'ttl' => $this->getTtl() + ] + ); + } + +} + diff --git a/lib/private/Push/Model/PushItem.php b/lib/private/Push/Model/PushItem.php new file mode 100644 index 0000000000000..260f83e0e873a --- /dev/null +++ b/lib/private/Push/Model/PushItem.php @@ -0,0 +1,467 @@ + + * @copyright 2019, Maxence Lange + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * 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 + * along with this program. If not, see . + * + */ + + +namespace OC\Push\Model; + + +use daita\NcSmallPhpTools\Traits\TArrayTools; +use daita\NcSmallPhpTools\Traits\TStringTools; +use JsonSerializable; +use OCP\Push\Model\IPushItem; + + +/** + * Class PushItem + * + * @since 18.0.0 + * + * @package OC\Push\Model + */ +class PushItem implements IPushItem, JsonSerializable { + + + use TArrayTools; + use TStringTools; + + + /** @var int */ + private $id = 0; + + /** @var string */ + private $token = ''; + + /** @var string */ + private $app = ''; + + /** @var string */ + private $source = ''; + + /** @var string */ + private $keyword = ''; + + /** @var array */ + private $payload = []; + + /** @var array */ + private $meta = []; + + /** @var string */ + private $type = ''; + + /** @var int */ + private $ttl = -1; + + /** @var int */ + private $creation = 0; + + + /** + * PushItem constructor. + * + * @param string $app + * @param string $type + * + * @since 18.0.0 + */ + public function __construct($app = '', $type = '') { + $this->app = $app; + $this->type = $type; + + $this->token = $this->uuid(11); + } + + + /** + * @param int $id + * + * @return PushItem + * + * @since 18.0.0 + */ + public function setId(int $id): IPushItem { + $this->id = $id; + + return $this; + } + + /** + * @return int + * + * @since 18.0.0 + */ + public function getId(): int { + return $this->id; + } + + + /** + * @return string + * + * @since 18.0.0 + */ + public function getToken(): string { + return $this->token; + } + + /** + * @param string $token + * + * @return PushItem + * + * @since 18.0.0 + */ + public function setToken(string $token): IPushItem { + $this->token = $token; + + return $this; + } + + + /** + * @return string + * + * @since 18.0.0 + */ + public function getApp(): string { + return $this->app; + } + + /** + * @param string $app + * + * @return IPushItem + * + * @since 18.0.0 + */ + public function setApp(string $app): IPushItem { + $this->app = $app; + + return $this; + } + + + /** + * @return string + * + * @since 18.0.0 + */ + public function getSource(): string { + return $this->source; + } + + /** + * @param string $source + * + * @return IPushItem + * + * @since 18.0.0 + */ + public function setSource(string $source): IPushItem { + $this->source = $source; + + return $this; + } + + + /** + * @return string + * + * @since 18.0.0 + */ + public function getKeyword(): string { + return $this->keyword; + } + + /** + * @param string $keyword + * + * @return IPushItem + * + * @since 18.0.0 + */ + public function setKeyword(string $keyword): IPushItem { + $this->keyword = $keyword; + + return $this; + } + + + /** + * @return array + * + * @since 18.0.0 + */ + public function getPayload(): array { + if ($this->payload instanceof JsonSerializable) { + return $this->payload->jsonSerialize(); + } + + return $this->payload; + } + + /** + * @param array $payload + * + * @return IPushItem + * + * @since 18.0.0 + */ + public function setPayload(array $payload): IPushItem { + $this->payload = $payload; + + return $this; + } + + /** + * @param JsonSerializable $payload + * + * @return IPushItem + * + * @since 18.0.0 + */ + public function setPayloadSerializable(JsonSerializable $payload): IPushItem { + $this->payload = $payload; + + return $this; + } + + + /** + * @return string + * + * @since 18.0.0 + */ + public function getType(): string { + return $this->type; + } + + /** + * @param string $type + * + * @return PushItem + * + * @since 18.0.0 + */ + public function setType(string $type): IPushItem { + $this->type = $type; + + return $this; + } + + + /** + * @return int + * + * @since 18.0.0 + */ + public function getTtl(): int { + return $this->ttl; + } + + /** + * @param int $ttl + * + * @return PushItem + * + * @since 18.0.0 + */ + public function setTtl(int $ttl): IPushItem { + $this->ttl = $ttl; + + return $this; + } + + + /** + * @param array $meta + * + * @return IPushItem + * + * @since 18.0.0 + */ + public function setMeta(array $meta): IPushItem { + $this->meta = $meta; + + return $this; + } + + /** + * @param string $k + * @param string $v + * + * @return IPushItem + * + * @since 18.0.0 + */ + public function addMeta(string $k, string $v): IPushItem { + $this->meta[$k] = $v; + + return $this; + } + + /** + * @param string $k + * @param bool $v + * + * @return IPushItem + * + * @since 18.0.0 + */ + public function addMetaBool(string $k, bool $v): IPushItem { + $this->meta[$k] = $v; + + return $this; + } + + /** + * @param string $k + * @param int $v + * + * @return IPushItem + * + * @since 18.0.0 + */ + public function addMetaInt(string $k, int $v): IPushItem { + $this->meta[$k] = $v; + + return $this; + } + + /** + * @param string $k + * @param array $v + * + * @return IPushItem + * + * @since 18.0.0 + */ + public function addMetaArray(string $k, array $v): IPushItem { + $this->meta[$k] = $v; + + return $this; + } + + /** + * @param string $k + * @param string $v + * + * @return IPushItem + * + * @since 18.0.0 + */ + public function addMetaArrayEntry(string $k, string $v): IPushItem { + if (!array_key_exists($k, $this->meta)) { + $this->meta[$k] = []; + } + + if (!in_array($v, $this->meta[$k])) { + $this->meta[$k][] = $v; + } + + return $this; + } + + + /** + * @return array + * + * @since 18.0.0 + */ + public function getMeta(): array { + return $this->meta; + } + + + /** + * @return int + * + * @since 18.0.0 + */ + public function getCreation(): int { + return $this->creation; + } + + /** + * @param int $creation + * + * @return PushItem + * + * @since 18.0.0 + */ + public function setCreation(int $creation): IPushItem { + $this->creation = $creation; + + return $this; + } + + + /** + * @param array $import + * + * @return IPushItem + * + * @since 18.0.0 + */ + public function import(array $import): IPushItem { + $this->setId($this->getInt('id', $import, 0)); + $this->setToken($this->get('token', $import, '')); + $this->setType($this->get('type', $import, '')); + $this->setApp($this->get('app', $import, '')); + $this->setTtl($this->getInt('ttl', $import, -1)); + $this->setPayload($this->getArray('payload', $import, [])); + $this->setSource($this->get('source', $import)); + $this->setKeyword($this->get('keyword', $import)); + $this->setMeta($this->getArray('meta', $import)); + $this->setCreation($this->getInt('creation', $import)); + + return $this; + } + + + /** + * @return array + */ + public function jsonSerialize(): array { + return [ + 'id' => $this->getId(), + 'token' => $this->getToken(), + 'app' => $this->getApp(), + 'type' => $this->getType(), + 'source' => $this->getSource(), + 'keyword' => $this->getKeyword(), + 'payload' => $this->getPayload(), + 'meta' => $this->getMeta(), + 'ttl' => $this->getTtl(), + 'creation' => $this->getCreation() + ]; + } + +} + diff --git a/lib/private/Push/Model/PushRecipients.php b/lib/private/Push/Model/PushRecipients.php new file mode 100644 index 0000000000000..54812adbdeadf --- /dev/null +++ b/lib/private/Push/Model/PushRecipients.php @@ -0,0 +1,471 @@ + + * @copyright 2019, Maxence Lange + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * 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 + * along with this program. If not, see . + * + */ + + +namespace OC\Push\Model; + + +use JsonSerializable; +use OCP\Push\Model\IPushRecipients; + + +/** + * Class PushRecipients + * + * @since 18.0.0 + * + * @package OC\Push\Model\Helper + */ +class PushRecipients implements IPushRecipients, JsonSerializable { + + + /** @var string */ + private $app = ''; + + /** @var string */ + private $source = ''; + + /** @var string */ + private $keyword = ''; + + /** @var array */ + private $meta = []; + + /** @var array */ + private $users = []; + + /** @var array */ + private $removedUsers = []; + + /** @var array */ + private $groups = []; + + /** @var array */ + private $removedGroups = []; + + /** @var array */ + private $filteredApps = []; + + /** @var array */ + private $limitToApps = []; + + + /** + * @return string + * + * @since 18.0.0 + */ + public function getApp(): string { + return $this->app; + } + + /** + * @param string $app + * + * @return IPushRecipients + * + * @since 18.0.0 + */ + public function setApp(string $app): IPushRecipients { + $this->app = $app; + + return $this; + } + + + /** + * @return string + * + * @since 18.0.0 + */ + public function getSource(): string { + return $this->source; + } + + /** + * @param string $source + * + * @return IPushRecipients + * + * @since 18.0.0 + */ + public function setSource(string $source): IPushRecipients { + $this->source = $source; + + return $this; + } + + + /** + * @return string + * + * @since 18.0.0 + */ + public function getKeyword(): string { + return $this->keyword; + } + + /** + * @param string $keyword + * + * @return IPushRecipients + * + * @since 18.0.0 + */ + public function setKeyword(string $keyword): IPushRecipients { + $this->keyword = $keyword; + + return $this; + } + + + /** + * @return array + * + * @since 18.0.0 + */ + public function getMeta(): array { + return $this->meta; + } + + /** + * @param array $meta + * + * @return IPushRecipients + * + * @since 18.0.0 + */ + public function setMeta(array $meta): IPushRecipients { + $this->meta = $meta; + + return $this; + } + + /** + * @param string $k + * @param string $v + * + * @return IPushRecipients + * + * @since 18.0.0 + */ + public function addMeta(string $k, string $v): IPushRecipients { + $this->meta[$k] = $v; + + return $this; + } + + /** + * @param string $k + * @param int $v + * + * @return IPushRecipients + * + * @since 18.0.0 + */ + public function addMetaInt(string $k, int $v): IPushRecipients { + $this->meta[$k] = $v; + + return $this; + } + + /** + * @param string $k + * @param array $v + * + * @return IPushRecipients + * + * @since 18.0.0 + */ + public function addMetaArray(string $k, array $v): IPushRecipients { + $this->meta[$k] = $v; + + return $this; + } + + /** + * @param string $k + * @param string $v + * + * @return IPushRecipients + * + * @since 18.0.0 + */ + public function addMetaArrayEntry(string $k, string $v): IPushRecipients { + if (!array_key_exists($k, $this->meta)) { + $this->meta[$k] = []; + } + + if (!in_array($v, $this->meta[$k])) { + $this->meta[$k][] = $v; + } + + return $this; + } + + /** + * @param string $k + * @param bool $v + * + * @return IPushRecipients + * + * @since 18.0.0 + */ + public function addMetaBool(string $k, bool $v): IPushRecipients { + $this->meta[$k] = $v; + + return $this; + } + + + /** + * @param string $user + * + * @return IPushRecipients + * + * @since 18.0.0 + */ + public function addUser(string $user): IPushRecipients { + array_push($this->users, $user); + + return $this; + } + + /** + * @param string[] $users + * + * @return IPushRecipients + * + * @since 18.0.0 + */ + public function addUsers(array $users): IPushRecipients { + $this->users = array_merge($this->users, $users); + + return $this; + } + + /** + * @param string $user + * + * @return IPushRecipients + * + * @since 18.0.0 + */ + public function removeUser(string $user): IPushRecipients { + return $this->removeUsers([$user]); + } + + /** + * @param string[] $users + * + * @return IPushRecipients + * + * @since 18.0.0 + */ + public function removeUsers(array $users): IPushRecipients { + $this->removedUsers = array_merge($this->removedUsers, $users); + + + return $this; + } + + + /** + * @param string $group + * + * @return IPushRecipients + * + * @since 18.0.0 + */ + public function addGroup(string $group): IPushRecipients { + array_push($this->groups, $group); + + return $this; + } + + /** + * @param string[] $groups + * + * @return IPushRecipients + * + * @since 18.0.0 + */ + public function addGroups(array $groups): IPushRecipients { + $this->groups = array_merge($this->groups, $groups); + + return $this; + } + + /** + * @param string $group + * + * @return IPushRecipients + * + * @since 18.0.0 + */ + public function removeGroup(string $group): IPushRecipients { + return $this->removeGroups([$group]); + } + + /** + * @param string[] $groups + * + * @return IPushRecipients + * + * @since 18.0.0 + */ + public function removeGroups(array $groups): IPushRecipients { + $this->removedGroups = array_merge($this->removedGroups, $groups); + + return $this; + } + + + /** + * @return string[] + * + * @since 18.0.0 + */ + public function getUsers(): array { + return $this->users; + } + + /** + * @return string[] + * + * @since 18.0.0 + */ + public function getGroups(): array { + return $this->groups; + } + + + /** + * @return string[] + * + * @since 18.0.0 + */ + public function getRemovedUsers(): array { + return $this->removedUsers; + } + + /** + * @return string[] + * + * @since 18.0.0 + */ + public function getRemovedGroups(): array { + return $this->removedGroups; + } + + + /** + * @param string $app + * + * @return IPushRecipients + * + * @since 18.0.0 + */ + public function filterApp(string $app): IPushRecipients { + return $this->filterApps([$app]); + } + + /** + * @param string[] $apps + * + * @return IPushRecipients + * + * @since 18.0.0 + */ + public function filterApps(array $apps): IPushRecipients { + $this->filteredApps = array_merge($this->filteredApps, $apps); + + return $this; + } + + /** + * @return string[] + * + * @since 18.0.0 + */ + public function getFilteredApps(): array { + return $this->filteredApps; + } + + + /** + * @param string $app + * + * @return IPushRecipients + * + * @since 18.0.0 + */ + public function limitToApp(string $app): IPushRecipients { + return $this->limitToApps([$app]); + } + + /** + * @param string[] $apps + * + * @return IPushRecipients + * + * @since 18.0.0 + */ + public function limitToApps(array $apps): IPushRecipients { + $this->limitToApps = array_merge($this->limitToApps, $apps); + + return $this; + } + + /** + * @return string[] + * + * @since 18.0.0 + */ + public function getLimitedToApps(): array { + return $this->limitToApps; + } + + + /** + * @return array + */ + public function jsonSerialize(): array { + return [ + '_users' => $this->getUsers(), + '_groups' => $this->getGroups(), + '_removedUsers' => $this->getRemovedUsers(), + '_removedGroups' => $this->getRemovedGroups(), + '_filteredApps' => $this->getFilteredApps(), + '_limitToApps' => $this->getLimitedToApps() + ]; + } + +} + diff --git a/lib/private/Push/Model/PushWrapper.php b/lib/private/Push/Model/PushWrapper.php new file mode 100644 index 0000000000000..e030afbee026f --- /dev/null +++ b/lib/private/Push/Model/PushWrapper.php @@ -0,0 +1,194 @@ + + * @copyright 2019, Maxence Lange + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * 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 + * along with this program. If not, see . + * + */ + + +namespace OC\Push\Model; + + +use daita\NcSmallPhpTools\Traits\TArrayTools; +use JsonSerializable; +use OCP\Push\Model\IPushItem; +use OCP\Push\Model\IPushWrapper; + + +/** + * Class PushManager + * + * @since 18.0.0 + * + * @package OC\Push\Model + */ +class PushWrapper implements IPushWrapper, JsonSerializable { + + + use TArrayTools; + + + /** @var IPushItem */ + private $item; + + /** @var array */ + private $recipients = []; + + /** @var int */ + private $creation = 0; + + + /** + * PushWrapper constructor. + * + * @param IPushItem $item + * + * @since 18.0.0 + */ + public function __construct($item = null) { + if ($item !== null && $item instanceof IPushItem) { + $this->item = $item; + } + + return $this; + } + + + /** + * @return bool + * + * @since 18.0.0 + */ + public function hasItem(): bool { + return ($this->item !== null); + } + + /** + * @return IPushItem + * + * @since 18.0.0 + */ + public function getItem(): IPushItem { + return $this->item; + } + + /** + * @param IPushItem $item + * + * @return IPushWrapper + * + * @since 18.0.0 + */ + public function setItem(IPushItem $item): IPushWrapper { + $this->item = $item; + + return $this; + } + + + /** + * @return string[] + * + * @since 18.0.0 + */ + public function getRecipients(): array { + return $this->recipients; + } + + /** + * @param array $recipients + * + * @return IPushWrapper + * + * @since 18.0.0 + */ + public function setRecipients(array $recipients): IPushWrapper { + $this->recipients = []; + $this->addRecipients($recipients); + + return $this; + } + + /** + * @param string $recipient + * + * @return IPushWrapper + * + * @since 18.0.0 + */ + public function addRecipient(string $recipient): IPushWrapper { + if (!in_array($recipient, $this->recipients) && $recipient !== '') { + $this->recipients[] = $recipient; + } + + return $this; + } + + /** + * @param array $recipients + * + * @return IPushWrapper + * + * @since 18.0.0 + */ + public function addRecipients(array $recipients): IPushWrapper { + foreach ($recipients as $recipient) { + $this->addRecipient($recipient); + } + + return $this; + } + + + /** + * @param array $import + * + * @return self + * + * @since 18.0.0 + */ + public function import(array $import): IPushWrapper { + $item = new PushItem(); + $item->import($this->getArray('item', $import, [])); + + $this->setItem($item); + $this->setRecipients($this->getArray('recipients', $import, [])); + + return $this; + } + + + /** + * @return array + */ + public function jsonSerialize(): array { + return [ + 'item' => ($this->hasItem()) ? $this->getItem() : null, + 'recipients' => $this->getRecipients() + ]; + } + +} + diff --git a/lib/private/Push/PushManager.php b/lib/private/Push/PushManager.php new file mode 100644 index 0000000000000..c65a57ebc79cc --- /dev/null +++ b/lib/private/Push/PushManager.php @@ -0,0 +1,128 @@ + + * @copyright 2019, Maxence Lange + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * 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 + * along with this program. If not, see . + * + */ + + +namespace OC\Push; + + +use OCP\Push\Exceptions\PushInstallException; +use OCP\Push\Helper\IPushHelper; +use OCP\Push\IPushManager; +use OCP\Push\Service\IPushService; + + +/** + * Class PushManager + * + * @since 18.0.0 + * + * @package OC\Push + */ +class PushManager implements IPushManager { + + + /** @var IPushService */ + private $pushService; + + /** @var IPushHelper */ + private $pushHelper; + + + /** + * @param IPushService $pushService + * @param IPushHelper $pushHelper + * + * @since 18.0.0 + */ + public function registerPushService(IPushService $pushService, IPushHelper $pushHelper): void { + $this->pushService = $pushService; + $this->pushHelper = $pushHelper; + } + + + /** + * @return bool + * + * @since 18.0.0 + */ + public function isAvailable(): bool { + try { + $this->checkRegistration(); + + return true; + } catch (PushInstallException $e) { + } + + return false; + } + + + /** + * @return IPushService + * @throws PushInstallException + * + * @since 18.0.0 + */ + public function getPushService(): IPushService { + $this->checkRegistration(); + + return $this->pushService; + } + + + /** + * @return IPushHelper + * @throws PushInstallException + * + * @since 18.0.0 + */ + public function getPushHelper(): IPushHelper { + $this->checkRegistration(); + + return $this->pushHelper; + } + + + /** + * check if an IPushService and IPushHelper have been registered + * + * @throws PushInstallException + * + * @since 18.0.0 + */ + private function checkRegistration() { + if ($this->pushService === null || $this->pushHelper === null) { + throw new PushInstallException( + 'Nextcloud Push is not available. Please check the Nextcloud Push App is installed and enabled' + ); + } + } + +} + diff --git a/lib/private/Server.php b/lib/private/Server.php index bce4f0feaef69..f055836a8657f 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -101,6 +101,7 @@ use OC\Notification\Manager; use OC\OCS\DiscoveryService; use OC\Preview\GeneratorHelper; +use OC\Push\PushManager; use OC\Remote\Api\ApiFactory; use OC\Remote\InstanceFactory; use OC\RichObjectStrings\Validator; @@ -158,6 +159,7 @@ use OCP\RichObjectStrings\IValidator; use OCP\Security\IContentSecurityPolicyManager; use OCP\Share\IShareHelper; +use OCP\Push\IPushManager; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\GenericEvent; @@ -1185,6 +1187,7 @@ public function __construct($webRoot, \OC\Config $config) { $this->registerAlias(IDashboardManager::class, DashboardManager::class); $this->registerAlias(IFullTextSearchManager::class, FullTextSearchManager::class); + $this->registerAlias(IPushManager::class, PushManager::class); $this->registerService(\OC\Security\IdentityProof\Manager::class, function (Server $c) { return new \OC\Security\IdentityProof\Manager( diff --git a/lib/public/Push/Exceptions/ItemNotFoundException.php b/lib/public/Push/Exceptions/ItemNotFoundException.php new file mode 100644 index 0000000000000..9e8b81463e0f8 --- /dev/null +++ b/lib/public/Push/Exceptions/ItemNotFoundException.php @@ -0,0 +1,44 @@ + + * @copyright 2020, Maxence Lange + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * 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 + * along with this program. If not, see . + * + */ + + +namespace OCP\Push\Exceptions; + +use Exception; + +/** + * @since 18.0.0 + * + * Class PushInstallException + * + * @package OCP\Push\Exceptions + */ +class ItemNotFoundException extends Exception { +} + + diff --git a/lib/public/Push/Exceptions/PushInstallException.php b/lib/public/Push/Exceptions/PushInstallException.php new file mode 100644 index 0000000000000..4f68dc6c8411c --- /dev/null +++ b/lib/public/Push/Exceptions/PushInstallException.php @@ -0,0 +1,44 @@ + + * @copyright 2020, Maxence Lange + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * 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 + * along with this program. If not, see . + * + */ + + +namespace OCP\Push\Exceptions; + +use Exception; + + +/** + * @since 18.0.0 + * + * Class PushInstallException + * + * @package OCP\Push\Exceptions + */ +class PushInstallException extends Exception { +} + diff --git a/lib/public/Push/Exceptions/UnknownStreamTypeException.php b/lib/public/Push/Exceptions/UnknownStreamTypeException.php new file mode 100644 index 0000000000000..dbc798536d04b --- /dev/null +++ b/lib/public/Push/Exceptions/UnknownStreamTypeException.php @@ -0,0 +1,45 @@ + + * @copyright 2020, Maxence Lange + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * 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 + * along with this program. If not, see . + * + */ + + +namespace OCP\Push\Exceptions; + +use Exception; + + +/** + * @since 18.0.0 + * + * Class PushInstallException + * + * @package OCP\Push\Exceptions + */ +class UnknownStreamTypeException extends Exception { +} + + diff --git a/lib/public/Push/Helper/IPushHelper.php b/lib/public/Push/Helper/IPushHelper.php new file mode 100644 index 0000000000000..919d8759f1856 --- /dev/null +++ b/lib/public/Push/Helper/IPushHelper.php @@ -0,0 +1,138 @@ + + * @copyright 2020, Maxence Lange + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * 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 + * along with this program. If not, see . + * + */ + + +namespace OCP\Push\Helper; + + +use OCP\Push\Model\Helper\IPushCallback; +use OCP\Push\Model\Helper\IPushEvent; +use OCP\Push\Model\Helper\IPushNotification; +use OCP\Push\Model\IPushWrapper; + + +/** + * Interface IPushHelper + * + * this Interface is used to quickly generate and save items, based on basic templates: + * - IPushNotification + * - IPushEvent + * - IPushCallback + * + * A PushHelper is registered by the Push App (when installed) + * + * @since 18.0.0 + * + * @package OCP\Push\Helper + */ +interface IPushHelper { + + + /** + * test the Push App integration, sending a test notification to $userId + * + * @param string $userId + * + * @return IPushWrapper + * + * @since 18.0.0 + */ + public function test(string $userId): IPushWrapper; + + + /** + * Using an IPushCallback, generates a IPushWrapper and save it in database. + * + * @param IPushCallback $callback + * + * @return IPushWrapper + * + * @since 18.0.0 + */ + public function toCallback(IPushCallback $callback): IPushWrapper; + + /** + * Generates a IPushWrapper from an IPushCallback + * + * @param IPushCallback $callback + * + * @return IPushWrapper + * + * @since 18.0.0 + */ + public function generateFromCallback(IPushCallback $callback): IPushWrapper; + + + /** + * Using an IPushNotification, generates a IPushWrapper and save it in database. + * + * @param IPushNotification $notification + * + * @return IPushWrapper + * + * @since 18.0.0 + */ + public function pushNotification(IPushNotification $notification): IPushWrapper; + + /** + * Generates a IPushWrapper from an IPushNotification + * + * @param IPushNotification $notification + * + * @return IPushWrapper + * + * @since 18.0.0 + */ + public function generateFromNotification(IPushNotification $notification): IPushWrapper; + + + /** + * Using an IPushEvent, generates a IPushWrapper and save it in database. + * + * @param IPushEvent $event + * + * @return IPushWrapper + * + * @since 18.0.0 + */ + public function broadcastEvent(IPushEvent $event): IPushWrapper; + + /** + * Generates a IPushWrapper from an IPushEvent + * + * @param IPushEvent $event + * + * @return IPushWrapper + * + * @since 18.0.0 + */ + public function generateFromEvent(IPushEvent $event): IPushWrapper; + +} + diff --git a/lib/public/Push/IPushManager.php b/lib/public/Push/IPushManager.php new file mode 100644 index 0000000000000..07bbc1d15fcc7 --- /dev/null +++ b/lib/public/Push/IPushManager.php @@ -0,0 +1,103 @@ + + * @copyright 2020, Maxence Lange + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * 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 + * along with this program. If not, see . + * + */ + + +namespace OCP\Push; + + +use OCP\Push\Exceptions\PushInstallException; +use OCP\Push\Helper\IPushHelper; +use OCP\Push\Service\IPushService; + + +/** + * Interface IPushManager + * + * IPushManager is a service available in Core that can be integrated within any app: + * + * use OCP\Push\IPushManager; + * public function __construct(IPushManager $pushManager) { + * $this->pushManager = $pushManager; + * } + * + * Once defined, it will be used to obtains more services from the Push App, if the App is available. + * + * @since 18.0.0 + * + * @package OCP\Push + */ +interface IPushManager { + + + /** + * Register a IPushService and IPushHelper. + * This is used by the Push App itself. + * + * @param IPushService $pushService + * @param IPushHelper $pushHelper + * + * @since 18.0.0 + * + */ + public function registerPushService(IPushService $pushService, IPushHelper $pushHelper): void; + + + /** + * returns if the Push App is available or not. + * + * @return bool + * + * @since 18.0.0 + */ + public function isAvailable(): bool; + + + /** + * returns the registered IPushService + * + * @return IPushService + * @throws PushInstallException + * + * @since 18.0.0 + */ + public function getPushService(): IPushService; + + + /** + * returns the registered IPushHelper + * + * @return IPushHelper + * @throws PushInstallException + * @since 18.0.0 + * + */ + public function getPushHelper(): IPushHelper; + +} + diff --git a/lib/public/Push/Model/Helper/IPushCallback.php b/lib/public/Push/Model/Helper/IPushCallback.php new file mode 100644 index 0000000000000..eaaa96caf0b94 --- /dev/null +++ b/lib/public/Push/Model/Helper/IPushCallback.php @@ -0,0 +1,85 @@ + + * @copyright 2020, Maxence Lange + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * 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 + * along with this program. If not, see . + * + */ + + +namespace OCP\Push\Model\Helper; + + +use JsonSerializable; +use OCP\Push\Model\IPushRecipients; + + +/** + * Interface IPushCallback + * + * Template used to generate an IPushItem with type=Callback + * + * @since 18.0.0 + * + * @package OCP\Push\Helper + */ +interface IPushCallback extends IPushRecipients { + + + const TYPE = 'Callback'; + + + /** + * get the payload + * + * @return array + * + * @since 18.0.0 + */ + public function getPayload(): array; + + /** + * set the payload + * + * @param array $payload + * + * @return self + * + * @since 18.0.0 + */ + public function setPayload(array $payload): self; + + /** + * set a serializable object as the payload + * + * @param JsonSerializable $payload + * + * @return self + * + * @since 18.0.0 + */ + public function setPayloadSerializable(JsonSerializable $payload): self; + +} + diff --git a/lib/public/Push/Model/Helper/IPushEvent.php b/lib/public/Push/Model/Helper/IPushEvent.php new file mode 100644 index 0000000000000..093acb503ce42 --- /dev/null +++ b/lib/public/Push/Model/Helper/IPushEvent.php @@ -0,0 +1,106 @@ + + * @copyright 2020, Maxence Lange + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * 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 + * along with this program. If not, see . + * + */ + + +namespace OCP\Push\Model\Helper; + + +use JsonSerializable; +use OCP\Push\Model\IPushRecipients; + + +/** + * Interface IPushEvent + * + * Template used to generate an IPushItem with type=Event + * + * @since 18.0.0 + * + * @package OCP\Push\Helper + */ +interface IPushEvent extends IPushRecipients { + + + const TYPE = 'Event'; + + + /** + * get the Javascript method that will be called on the front-end + * + * @return string + * + * @since 18.0.0 + */ + public function getCommand(): string; + + /** + * set the Javascript method that will be called on the front-end + * + * @param string $title + * + * @return self + * + * @since 18.0.0 + */ + public function setCommand(string $title): self; + + + /** + * get the payload + * + * @return array + * + * @since 18.0.0 + */ + public function getPayload(): array; + + /** + * set the payload + * + * @param array $payload + * + * @return self + * + * @since 18.0.0 + */ + public function setPayload(array $payload): self; + + /** + * set a serializable object as the payload + * + * @param JsonSerializable $payload + * + * @return self + * + * @since 18.0.0 + */ + public function setPayloadSerializable(JsonSerializable $payload): self; + +} + diff --git a/lib/public/Push/Model/Helper/IPushNotification.php b/lib/public/Push/Model/Helper/IPushNotification.php new file mode 100644 index 0000000000000..bb04a842d14b6 --- /dev/null +++ b/lib/public/Push/Model/Helper/IPushNotification.php @@ -0,0 +1,166 @@ + + * @copyright 2020, Maxence Lange + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * 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 + * along with this program. If not, see . + * + */ + + +namespace OCP\Push\Model\Helper; + + +use OCP\Push\Model\IPushRecipients; + + +/** + * Interface IPushNotification + * + * Template used to generate an IPushItem with type=Notification + * + * @since 18.0.0 + * + * @package OCP\Push\Helper + */ +interface IPushNotification extends IPushRecipients { + + + const TYPE = 'Notification'; + + const LEVEL_SUCCESS = 'success'; + const LEVEL_MESSAGE = 'message'; + const LEVEL_WARNING = 'warning'; + const LEVEL_ERROR = 'error'; + + + /** + * get the title of the notification + * + * @return string + * + * @since 18.0.0 + */ + public function getTitle(): string; + + /** + * set the title of the notification + * + * @param string $title + * + * @return self + * + * @since 18.0.0 + */ + public function setTitle(string $title): self; + + + /** + * get the message of the notification + * + * @return string + * + * @since 18.0.0 + */ + public function getMessage(): string; + + /** + * set the message of the notification + * + * @param string $message + * + * @return self + * + * @since 18.0.0 + */ + public function setMessage(string $message): self; + + + /** + * get the link to open on a click on the notification + * + * @return string + * + * @since 18.0.0 + */ + public function getLink(): string; + + /** + * set the link to open on a click on the notification + * + * @param string $link + * + * @return self + * + * @since 18.0.0 + */ + public function setLink(string $link): self; + + + /** + * get the level of the notification. + * + * @return string + * + * @since 18.0.0 + */ + public function getLevel(): string; + + /** + * set the level of the notification: + * - IPushNotification::LEVEL_SUCCESS + * - IPushNotification::LEVEL_MESSAGE + * - IPushNotification::LEVEL_WARNING + * - IPushNotification::LEVEL_ERROR + * + * @param string $level + * + * @return self + * + * @since 18.0.0 + */ + public function setLevel(string $level): self; + + + /** + * get the Time To Live + * + * @return int + * + * @since 18.0.0 + */ + public function getTtl(): int; + + /** + * set the Time To Live + * + * @param int $ttl + * + * @return self + * + * @since 18.0.0 + */ + public function setTtl(int $ttl): self; + +} + diff --git a/lib/public/Push/Model/IPushItem.php b/lib/public/Push/Model/IPushItem.php new file mode 100644 index 0000000000000..3d01f3eeeb21c --- /dev/null +++ b/lib/public/Push/Model/IPushItem.php @@ -0,0 +1,331 @@ + + * @copyright 2020, Maxence Lange + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * 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 + * along with this program. If not, see . + * + */ + + +namespace OCP\Push\Model; + + +use JsonSerializable; + + +/** + * Interface IPushItem + * + * Main data object of the Push App, a IPushItem contains all data corresponding to a single event, but its + * recipient. There is no way to set a list of recipients to an IPushItem on its own, which is not an issue when + * reading/updating. + * However, when writing/creating a new IPushItem, it must be wrapped in a IPushWrapper. + * + * @since 18.0.0 + * + * @package OCP\Push + */ +interface IPushItem { + + + const TTL_INSTANT = 15; + const TTL_FEW_MINUTES = 180; + const TTL_FEW_HOURS = 7200; + const TTL_DAY = 24 * 3600; + const TTL_LONG = 24 * 3600 * 8; + const TTL_GODLIKE = 0; + + + /** + * returns the Id (database) + * + * @return int + * + * @since 18.0.0 + */ + public function getId(): int; + + + /** + * returns the token + * + * @return string + * + * @since 18.0.0 + */ + public function getToken(): string; + + + /** + * returns the appId + * + * @return string + * + * @since 18.0.0 + */ + public function getApp(): string; + + /** + * set the appId + * + * @param string $app + * + * @return self + * + * @since 18.0.0 + */ + public function setApp(string $app): self; + + + /** + * set the source + * + * @return string + * + * @since 18.0.0 + */ + public function getSource(): string; + + /** + * returns source + * + * @param string $source + * + * @return self + * + * @since 18.0.0 + */ + public function setSource(string $source): self; + + + /** + * returns the payload of the item + * + * @return array + * + * @since 18.0.0 + */ + public function getPayload(): array; + + /** + * set the payload of the item + * + * @param array $payload + * + * @return self + * + * @since 18.0.0 + */ + public function setPayload(array $payload): self; + + /** + * set a Serializable object as payload + * + * @param JsonSerializable $payload + * + * @return IPushItem + * + * @since 18.0.0 + */ + public function setPayloadSerializable(JsonSerializable $payload): self; + + + /** + * get keyword (used to identify the item) + * + * @return string + * + * @since 18.0.0 + */ + public function getKeyword(): string; + + /** + * set keyword (used to identify the item) + * + * @param string $keyword + * + * @return self + * + * @since 18.0.0 + */ + public function setKeyword(string $keyword): self; + + + /** + * get type + * + * @return string + * + * @since 18.0.0 + */ + public function getType(): string; + + /** + * set type of the item (Callback, Notification, Event, ...) + * + * @param string $type + * + * @return self + * + * @since 18.0.0 + */ + public function setType(string $type): self; + + + /** + * get Time To Live + * + * @return int + * + * @since 18.0.0 + */ + public function getTtl(): int; + + /** + * set Time To Live + * + * @param int $ttl + * + * @return self + * + * @since 18.0.0 + */ + public function setTtl(int $ttl): self; + + + /** + * set meta for the item + * + * @param array $meta + * + * @return IPushItem + * + * @since 18.0.0 + */ + public function setMeta(array $meta): self; + + /** + * add a meta + * + * @param string $k + * @param string $v + * + * @return IPushItem + * + * @since 18.0.0 + */ + public function addMeta(string $k, string $v): self; + + /** + * add a meta (int) + * + * @param string $k + * @param int $v + * + * @return IPushItem + * + * @since 18.0.0 + */ + public function addMetaInt(string $k, int $v): self; + + /** + * add a meta (bool) + * + * @param string $k + * @param bool $v + * + * @return IPushItem + * + * @since 18.0.0 + */ + public function addMetaBool(string $k, bool $v): self; + + /** + * add a meta (array) + * + * @param string $k + * @param array $v + * + * @return IPushItem + * + * @since 18.0.0 + */ + public function addMetaArray(string $k, array $v): self; + + /** + * add an entry to an existing array within meta + * + * @param string $k + * @param string $v + * + * @return IPushItem + * + * @since 18.0.0 + */ + public function addMetaArrayEntry(string $k, string $v): self; + + /** + * returns all meta about the item + * + * @return array + * + * @since 18.0.0 + */ + public function getMeta(): array; + + + /** + * set creation timestamp + * + * @param int $timestamp + * + * @return self + * + * @since 18.0.0 + */ + public function setCreation(int $timestamp): self; + + /** + * returns creation timestamp + * + * @return int + * + * @since 18.0.0 + */ + public function getCreation(): int; + + + /** + * fill the current IPushItem with data from a formatted array + * + * @param array $import + * + * @return self + * + * @since 18.0.0 + */ + public function import(array $import): self; + +} + diff --git a/lib/public/Push/Model/IPushRecipients.php b/lib/public/Push/Model/IPushRecipients.php new file mode 100644 index 0000000000000..d7d029bd80176 --- /dev/null +++ b/lib/public/Push/Model/IPushRecipients.php @@ -0,0 +1,382 @@ + + * @copyright 2020, Maxence Lange + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * 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 + * along with this program. If not, see . + * + */ + + +namespace OCP\Push\Model; + + +/** + * Interface IPushRecipients + * + * This interface extends templates used by the IPushHelper to generate IPushItem + * It contains the base to manage: + * - appId and source + * - meta + * - recipients (users, groups) + * - blacklist and whitelist of apps + * + * @since 18.0.0 + * + * @package OCP\Push + */ +interface IPushRecipients { + + + /** + * returns the appId + * + * @return string + * + * @since 18.0.0 + */ + public function getApp(): string; + + /** + * set the appId + * + * @param string $app + * + * @return IPushRecipients + * + * @since 18.0.0 + */ + public function setApp(string $app): self; + + + /** + * set the source + * + * @return string + * + * @since 18.0.0 + */ + public function getSource(): string; + + /** + * returns the source + * + * @param string $source + * + * @return IPushRecipients + * + * @since 18.0.0 + */ + public function setSource(string $source): self; + + + /** + * set keyword + * + * @return string + * + * @since 18.0.0 + */ + public function getKeyword(): string; + + /** + * returns keyword + * + * @param string $keyword + * + * @return IPushRecipients + * + * @since 18.0.0 + */ + public function setKeyword(string $keyword): self; + + + /** + * returns all meta about the item + * + * @return array + * + * @since 18.0.0 + */ + public function getMeta(): array; + + /** + * set meta for the item + * + * @param array $meta + * + * @return IPushRecipients + * + * @since 18.0.0 + */ + public function setMeta(array $meta): self; + + /** + * add a meta + * + * @param string $k + * @param string $v + * + * @return IPushRecipients + * + * @since 18.0.0 + */ + public function addMeta(string $k, string $v): self; + + /** + * add a meta (int) + * + * @param string $k + * @param int $v + * + * @return IPushRecipients + * + * @since 18.0.0 + */ + public function addMetaInt(string $k, int $v): self; + + /** + * add a meta (array) + * + * @param string $k + * @param array $v + * + * @return IPushRecipients + * + * @since 18.0.0 + */ + public function addMetaArray(string $k, array $v): self; + + /** + * add an entry to an existing array within meta + * + * @param string $k + * @param string $v + * + * @return IPushRecipients + * + * @since 18.0.0 + */ + public function addMetaArrayEntry(string $k, string $v): self; + + /** + * add meta (bool) + * + * @param string $k + * @param bool $v + * + * @return IPushRecipients + * + * @since 18.0.0 + */ + public function addMetaBool(string $k, bool $v): self; + + + /** + * add a user to the list of recipients + * + * @param string $user + * + * @return IPushRecipients + * + * @since 18.0.0 + */ + public function addUser(string $user): self; + + /** + * add a list of users to the list of recipients + * + * @param string[] $users + * + * @return IPushRecipients + * + * @since 18.0.0 + */ + public function addUsers(array $users): self; + + /** + * remote a user from the list of recipients + * + * @param string $user + * + * @return IPushRecipients + * + * @since 18.0.0 + */ + public function removeUser(string $user): self; + + /** + * remote multiple users from the list of recipients + * + * @param string[] $users + * + * @return IPushRecipients + * + * @since 18.0.0 + */ + public function removeUsers(array $users): self; + + + /** + * add a group to the list of recipients + * + * @param string $group + * + * @return IPushRecipients + * + * @since 18.0.0 + */ + public function addGroup(string $group): self; + + /** + * add multiple groups to the list of recipients + * + * @param array $groups + * + * @return IPushRecipients + * + * @since 18.0.0 + */ + public function addGroups(array $groups): self; + + /** + * remove a group from the list of recipients + * + * @param string $group + * + * @return IPushRecipients + * + * @since 18.0.0 + */ + public function removeGroup(string $group): self; + + /** + * remove multiple groups from the list of recipients + * + * @param string[] $groups + * + * @return IPushRecipients + * + * @since 18.0.0 + */ + public function removeGroups(array $groups): self; + + + /** + * returns all users set a recipients + * + * @return string[] + */ + public function getUsers(): array; + + /** + * returns all groups set as recipients + * + * @return string[] + */ + public function getGroups(): array; + + /** + * returns all users that should be removed from the list of recipients + * + * @return string[] + * + * @since 18.0.0 + */ + public function getRemovedUsers(): array; + + /** + * returns all groups that should be removed from the list of recipients + * + * @return string[] + * + * @since 18.0.0 + */ + public function getRemovedGroups(): array; + + + /** + * add a single app to the list of black-listed apps + * + * @param string $app + * + * @return IPushRecipients + * + * @since 18.0.0 + */ + public function filterApp(string $app): self; + + /** + * add multiple apps to the list of black-listed apps + * + * @param string[] $apps + * + * @return IPushRecipients + * + * @since 18.0.0 + */ + public function filterApps(array $apps): self; + + /** + * returns black-listed apps + * + * @return string[] + * + * @since 18.0.0 + */ + public function getFilteredApps(): array; + + + /** + * add a single app to the list of white-listed apps + * + * @param string $app + * + * @return IPushRecipients + * + * @since 18.0.0 + */ + public function limitToApp(string $app): self; + + /** + * add multiple apps to the list of white-listed apps + * + * @param string[] $apps + * + * @return IPushRecipients + * + * @since 18.0.0 + */ + public function limitToApps(array $apps): self; + + /** + * returns white-listed apps + * + * @return string[] + * + * @since 18.0.0 + */ + public function getLimitedToApps(): array; + +} + diff --git a/lib/public/Push/Model/IPushWrapper.php b/lib/public/Push/Model/IPushWrapper.php new file mode 100644 index 0000000000000..4708795a14cfa --- /dev/null +++ b/lib/public/Push/Model/IPushWrapper.php @@ -0,0 +1,137 @@ + + * @copyright 2020, Maxence Lange + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * 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 + * along with this program. If not, see . + * + */ + + +namespace OCP\Push\Model; + + +/** + * Interface IPushWrapper + * + * An IPushWrapper is the main object to handle and manage IPushItem around the Push App. + * It contains: + * - a single IPushItem: data that will be send to the front-end + * - a list of recipients: Nextcloud local accounts (userId) + * + * The main purpose is to create and store new IPushItems. + * The IPushWrapper is not used when retrieving IPushItem from the database. + * + * @since 18.0.0 + * + * @package OCP\Push + */ +interface IPushWrapper { + + + /** + * returns if the wrapper contains an IPushItem. + * + * @return bool + * + * @since 18.0.0 + */ + public function hasItem(): bool; + + /** + * returns the IPushItem from the wrapper. + * + * @return IPushItem + * + * @since 18.0.0 + */ + public function getItem(): IPushItem; + + /** + * add an IPushItem to the wrapper. + * + * @param IPushItem $item + * + * @return IPushWrapper + * + * @since 18.0.0 + */ + public function setItem(IPushItem $item): self; + + + /** + * returns the list of Nextcloud local accounts (userId) set as recipients + * + * @return string[] + * + * @since 18.0.0 + */ + public function getRecipients(): array; + + /** + * set the list of recipients for the wrappers, based on Nextcloud local accounts (userId) + * + * @param string[] $recipients + * + * @return self + * + * @since 18.0.0 + */ + public function setRecipients(array $recipients): self; + + /** + * Add a single Nextcloud local account (userId) to the list of recipients + * + * @param string $recipient + * + * @return IPushWrapper + * + * @since 18.0.0 + */ + public function addRecipient(string $recipient): self; + + /** + * Add multiple Nextcloud local accounts (userId) to the list of recipients + * + * @param string[] $recipients + * + * @return IPushWrapper + * + * @since 18.0.0 + */ + public function addRecipients(array $recipients): self; + + + /** + * fill the current IPushWrapper with data from a formatted array + * + * @param array $import + * + * @return self + * + * @since 18.0.0 + */ + public function import(array $import): self; + +} + diff --git a/lib/public/Push/Service/IPushService.php b/lib/public/Push/Service/IPushService.php new file mode 100644 index 0000000000000..b3ff12d900c2d --- /dev/null +++ b/lib/public/Push/Service/IPushService.php @@ -0,0 +1,105 @@ + + * @copyright 2020, Maxence Lange + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * 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 + * along with this program. If not, see . + * + */ + + +namespace OCP\Push\Service; + + +use OCP\Push\Exceptions\ItemNotFoundException; +use OCP\Push\Exceptions\UnknownStreamTypeException; +use OCP\Push\Model\IPushItem; +use OCP\Push\Model\IPushRecipients; +use OCP\Push\Model\IPushWrapper; + + +/** + * Interface IPushService + * + * This interface contains list of tools to manage your events. + * A PushService is registered by the Push App (when installed) + * + * @since 18.0.0 + * + * @package OCP\Push\Service + */ +interface IPushService { + + + /** + * Save the item, contained in the wrapper, in the database. + * If a keyword is specified to the item, any non-published item with the same keyword/appId/userId will + * be deleted. + * + * @param IPushWrapper $wrapper + * + * @since 18.0.0 + */ + public function push(IPushWrapper $wrapper): void; + + /** + * Update the item, if still available in the database. + * + * @param IPushItem $item + * + * @since 18.0.0 + */ + public function update(IPushItem $item): void; + + + /** + * returns the IPushItem identified by its appId, userId and keyword. + * throws an ItemNotFoundException if the item is not available in the database. + * + * @param string $app + * @param string $userId + * @param string $keyword + * + * @return IPushItem + * @throws ItemNotFoundException + * @throws UnknownStreamTypeException + * + * @since 18.0.0 + */ + public function getItemByKeyword(string $app, string $userId, string $keyword): IPushItem; + + + /** + * fill the IPushWrapper with recipients stored in the IPushRecipients + * + * @param IPushWrapper $wrapper + * @param IPushRecipients $recipients + * + * @return mixed + * + * @since 18.0.0 + */ + public function fillRecipients(IPushWrapper $wrapper, IPushRecipients $recipients): void; + +} +