-
Notifications
You must be signed in to change notification settings - Fork 508
Implement Recieving Room Shares #5775
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Signed-off-by: Gary Kim <[email protected]>
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ | |
|
|
||
| namespace OCA\Talk\BackgroundJob; | ||
|
|
||
| use OCA\Talk\Federation\FederationManager; | ||
| use OCA\Talk\Service\ParticipantService; | ||
| use OCP\AppFramework\Utility\ITimeFactory; | ||
| use OCP\BackgroundJob\TimedJob; | ||
|
|
@@ -46,6 +47,9 @@ class RemoveEmptyRooms extends TimedJob { | |
| /** @var LoggerInterface */ | ||
| protected $logger; | ||
|
|
||
| /** @var FederationManager */ | ||
| protected $federationManager; | ||
|
|
||
| protected $numDeletedRooms = 0; | ||
|
|
||
| public function __construct(ITimeFactory $timeFactory, | ||
|
|
@@ -77,7 +81,7 @@ public function callback(Room $room): void { | |
| return; | ||
| } | ||
|
|
||
| if ($this->participantService->getNumberOfActors($room) === 0 && $room->getObjectType() !== 'file') { | ||
| if ($this->participantService->getNumberOfActors($room) === 0 && $room->getObjectType() !== 'file' && $this->federationManager->getNumberOfInvitations($room) === 0) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When there is no local user in the room anymore it should be delete. Or is this for the share-receiving side?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is for the share-receiving side. When a share for an unknown room is received, it is created on the rooms table then the invitation put in the invitations table so don't delete rooms that have pending invitations for it. |
||
| $room->deleteRoom(); | ||
| $this->numDeletedRooms++; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
| /** | ||
| * @copyright Copyright (c) 2021, Gary Kim <[email protected]> | ||
| * | ||
| * @author Gary Kim <[email protected]> | ||
| * | ||
| * @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\Talk\Controller; | ||
|
|
||
| use OCA\Talk\AppInfo\Application; | ||
| use OCA\Talk\Exceptions\UnauthorizedException; | ||
| use OCA\Talk\Federation\FederationManager; | ||
| use OCP\AppFramework\Db\MultipleObjectsReturnedException; | ||
| use OCP\AppFramework\Http\DataResponse; | ||
| use OCP\AppFramework\OCSController; | ||
| use OCP\DB\Exception as DBException; | ||
| use OCP\IRequest; | ||
| use OCP\IUser; | ||
| use OCP\IUserSession; | ||
|
|
||
| class FederationController extends OCSController { | ||
| /** @var FederationManager */ | ||
| private $federationManager; | ||
|
|
||
| /** @var IUserSession */ | ||
| private $userSession; | ||
|
|
||
| public function __construct(IRequest $request, FederationManager $federationManager, IUserSession $userSession) { | ||
| parent::__construct(Application::APP_ID, $request); | ||
| $this->federationManager = $federationManager; | ||
| $this->userSession = $userSession; | ||
| } | ||
|
|
||
| /** | ||
| * @NoAdminRequired | ||
| * | ||
| * @param int $id | ||
| * @return DataResponse | ||
| * @throws UnauthorizedException | ||
| * @throws DBException | ||
| * @throws MultipleObjectsReturnedException | ||
| */ | ||
| public function acceptShare(int $id): DataResponse { | ||
| $user = $this->userSession->getUser(); | ||
| if (!$user instanceof IUser) { | ||
| throw new UnauthorizedException(); | ||
| } | ||
| $this->federationManager->acceptRemoteRoomShare($user, $id); | ||
| return new DataResponse(); | ||
| } | ||
|
|
||
| /** | ||
| * @NoAdminRequired | ||
| * | ||
| * @param int $id | ||
| * @return DataResponse | ||
| * @throws UnauthorizedException | ||
| * @throws DBException | ||
| * @throws MultipleObjectsReturnedException | ||
| */ | ||
| public function rejectShare(int $id): DataResponse { | ||
| $user = $this->userSession->getUser(); | ||
| if (!$user instanceof IUser) { | ||
| throw new UnauthorizedException(); | ||
| } | ||
| $this->federationManager->rejectRemoteRoomShare($user, $id); | ||
| return new DataResponse(); | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.