Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implementing Push App #17016

Closed
wants to merge 16 commits into from
2 changes: 1 addition & 1 deletion 3rdparty
Submodule 3rdparty updated 1 files
+1 −0 composer.json
19 changes: 19 additions & 0 deletions lib/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
19 changes: 19 additions & 0 deletions lib/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
126 changes: 126 additions & 0 deletions lib/private/Push/Model/Helper/PushCallback.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<?php
declare(strict_types=1);


/**
* Push - Nextcloud Push Service
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Maxence Lange <maxence@artificial-owl.com>
* @copyright 2019, Maxence Lange <maxence@artificial-owl.com>
* @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 <http://www.gnu.org/licenses/>.
*
*/


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
]
);
}

}

151 changes: 151 additions & 0 deletions lib/private/Push/Model/Helper/PushEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
<?php
declare(strict_types=1);


/**
* Push - Nextcloud Push Service
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Maxence Lange <maxence@artificial-owl.com>
* @copyright 2019, Maxence Lange <maxence@artificial-owl.com>
* @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 <http://www.gnu.org/licenses/>.
*
*/


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()
]
);
}

}

Loading