Browse Source
Introduce a Read-Only state for conversations
Introduce a Read-Only state for conversations
Signed-off-by: Joas Schilling <coding@schilljs.com>pull/1640/head
No known key found for this signature in database
GPG Key ID: 7076EA9751AACDDA
13 changed files with 213 additions and 39 deletions
-
2appinfo/info.xml
-
2appinfo/routes.php
-
6docs/api-v1.md
-
1lib/Capabilities.php
-
56lib/Controller/AEnvironmentAwareController.php
-
19lib/Controller/ChatController.php
-
21lib/Controller/RoomController.php
-
2lib/Manager.php
-
31lib/Middleware/Exceptions/ReadOnlyException.php
-
41lib/Middleware/InjectionMiddleware.php
-
58lib/Migration/Version5099Date20190319134820.php
-
11lib/Room.php
-
2tests/php/CapabilitiesTest.php
@ -0,0 +1,56 @@ |
|||
<?php |
|||
declare(strict_types=1); |
|||
/** |
|||
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch> |
|||
* @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com> |
|||
* |
|||
* @author Lukas Reschke <lukas@statuscode.ch> |
|||
* @author Joas Schilling <coding@schilljs.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 OCA\Spreed\Controller; |
|||
|
|||
use OCA\Spreed\Participant; |
|||
use OCA\Spreed\Room; |
|||
use OCP\AppFramework\OCSController; |
|||
|
|||
abstract class AEnvironmentAwareController extends OCSController { |
|||
|
|||
/** @var Room */ |
|||
protected $room; |
|||
/** @var Participant */ |
|||
protected $participant; |
|||
|
|||
public function setRoom(Room $room): void { |
|||
$this->room = $room; |
|||
} |
|||
|
|||
public function getRoom(): ?Room { |
|||
return $this->room; |
|||
} |
|||
|
|||
public function setParticipant(Participant $participant): void { |
|||
$this->participant = $participant; |
|||
} |
|||
|
|||
public function getParticipant(): ?Participant { |
|||
return $this->participant; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,31 @@ |
|||
<?php |
|||
declare(strict_types=1); |
|||
/** |
|||
* @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.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 OCA\Spreed\Middleware\Exceptions; |
|||
|
|||
use OCP\AppFramework\Http; |
|||
|
|||
class ReadOnlyException extends \Exception { |
|||
public function __construct() { |
|||
parent::__construct('The conversation is read-only', Http::STATUS_FORBIDDEN); |
|||
} |
|||
} |
|||
@ -0,0 +1,58 @@ |
|||
<?php |
|||
declare(strict_types=1); |
|||
/** |
|||
* @copyright Copyright (c) 2019, Joas Schilling <coding@schilljs.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 OCA\Spreed\Migration; |
|||
|
|||
use Closure; |
|||
use Doctrine\DBAL\Types\Type; |
|||
use OCP\DB\ISchemaWrapper; |
|||
use OCP\Migration\SimpleMigrationStep; |
|||
use OCP\Migration\IOutput; |
|||
|
|||
class Version5099Date20190319134820 extends SimpleMigrationStep { |
|||
|
|||
/** |
|||
* @param IOutput $output |
|||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|||
* @param array $options |
|||
* @return null|ISchemaWrapper |
|||
*/ |
|||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|||
/** @var ISchemaWrapper $schema */ |
|||
$schema = $schemaClosure(); |
|||
|
|||
if ($schema->hasTable('talk_rooms')) { |
|||
$table = $schema->getTable('talk_rooms'); |
|||
|
|||
if (!$table->hasColumn('read_only')) { |
|||
$table->addColumn('read_only', Type::INTEGER, [ |
|||
'notnull' => true, |
|||
'length' => 6, |
|||
'default' => 0, |
|||
]); |
|||
} |
|||
} |
|||
|
|||
return $schema; |
|||
} |
|||
|
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue