diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Capabilities.php | 7 | ||||
-rw-r--r-- | lib/Chat/Parser/SystemMessage.php | 16 | ||||
-rw-r--r-- | lib/Controller/CallController.php | 4 | ||||
-rw-r--r-- | lib/Controller/PageController.php | 5 | ||||
-rw-r--r-- | lib/Controller/SignalingController.php | 21 | ||||
-rw-r--r-- | lib/Events/SilentModifyParticipantEvent.php | 27 | ||||
-rw-r--r-- | lib/Notification/Listener.php | 12 | ||||
-rw-r--r-- | lib/Service/ParticipantService.php | 9 | ||||
-rw-r--r-- | lib/Signaling/BackendNotifier.php | 2 |
9 files changed, 73 insertions, 30 deletions
diff --git a/lib/Capabilities.php b/lib/Capabilities.php index 37f85fee2..57650a54d 100644 --- a/lib/Capabilities.php +++ b/lib/Capabilities.php @@ -102,8 +102,10 @@ class Capabilities implements IPublicCapability { 'conversation-permissions', 'rich-object-list-media', 'rich-object-delete', + 'unified-search', 'chat-permission', 'silent-send', + 'silent-call', 'send-call-notification', ], 'config' => [ @@ -119,7 +121,10 @@ class Capabilities implements IPublicCapability { ], 'conversations' => [], 'previews' => [ - 'max-gif-size' => (int)$this->serverConfig->getAppValue('spreed', 'max-gif-size', '3145728') + 'max-gif-size' => (int)$this->serverConfig->getAppValue('spreed', 'max-gif-size', '3145728'), + ], + 'signaling' => [ + 'session-ping-limit' => max(0, (int)$this->serverConfig->getAppValue('spreed', 'session-ping-limit', '200')), ], ], ]; diff --git a/lib/Chat/Parser/SystemMessage.php b/lib/Chat/Parser/SystemMessage.php index e8165712a..68a794406 100644 --- a/lib/Chat/Parser/SystemMessage.php +++ b/lib/Chat/Parser/SystemMessage.php @@ -716,6 +716,21 @@ class SystemMessage { ]; } + if ($room->getType() !== Room::TYPE_ONE_TO_ONE) { + // Can happen if a user was remove from a one-to-one room. + return [ + $this->l->t('You tried to call {user}'), + [ + 'user' => [ + 'type' => 'highlight', + 'id' => 'deleted_user', + 'name' => $room->getName(), + ], + ], + 'call_tried', + ]; + } + $participants = json_decode($room->getName(), true); $other = ''; foreach ($participants as $participant) { @@ -723,6 +738,7 @@ class SystemMessage { $other = $participant; } } + return [ $this->l->t('You tried to call {user}'), [ diff --git a/lib/Controller/CallController.php b/lib/Controller/CallController.php index 26797eae5..f55b62bc7 100644 --- a/lib/Controller/CallController.php +++ b/lib/Controller/CallController.php @@ -111,7 +111,7 @@ class CallController extends AEnvironmentAwareController { * @param int|null $forcePermissions * @return DataResponse */ - public function joinCall(?int $flags = null, ?int $forcePermissions = null): DataResponse { + public function joinCall(?int $flags = null, ?int $forcePermissions = null, bool $silent = false): DataResponse { $this->participantService->ensureOneToOneRoomIsFilled($this->room); $session = $this->participant->getSession(); @@ -128,7 +128,7 @@ class CallController extends AEnvironmentAwareController { $this->roomService->setPermissions($this->room, 'call', Attendee::PERMISSIONS_MODIFY_SET, $forcePermissions, true); } - $this->participantService->changeInCall($this->room, $this->participant, $flags); + $this->participantService->changeInCall($this->room, $this->participant, $flags, false, $silent); return new DataResponse(); } diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index 2ee61ccc3..0cada87b2 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -25,6 +25,7 @@ declare(strict_types=1); namespace OCA\Talk\Controller; +use OCA\Talk\AppInfo\Application; use OCA\Talk\Exceptions\ParticipantNotFoundException; use OCA\Talk\Exceptions\RoomNotFoundException; use OCA\Talk\Config; @@ -251,7 +252,9 @@ class PageController extends Controller { } $this->eventDispatcher->dispatch('\OCP\Collaboration\Resources::loadAdditionalScripts', new GenericEvent()); - $response = new TemplateResponse($this->appName, 'index'); + $response = new TemplateResponse($this->appName, 'index', [ + 'app' => Application::APP_ID, + ]); $csp = new ContentSecurityPolicy(); $csp->addAllowedConnectDomain('*'); $csp->addAllowedMediaDomain('blob:'); diff --git a/lib/Controller/SignalingController.php b/lib/Controller/SignalingController.php index 784036792..4f9bc62ba 100644 --- a/lib/Controller/SignalingController.php +++ b/lib/Controller/SignalingController.php @@ -729,22 +729,6 @@ class SignalingController extends OCSController { } private function backendPing(array $request): DataResponse { - try { - $room = $this->manager->getRoomByToken($request['roomid']); - } catch (RoomNotFoundException $e) { - $this->logger->debug('Tried to ping non existing room {token}', [ - 'token' => $request['roomid'], - 'app' => 'spreed-hpb', - ]); - return new DataResponse([ - 'type' => 'error', - 'error' => [ - 'code' => 'no_such_room', - 'message' => 'No such room.', - ], - ]); - } - $pingSessionIds = []; $now = $this->timeFactory->getTime(); foreach ($request['entries'] as $entry) { @@ -760,12 +744,11 @@ class SignalingController extends OCSController { 'type' => 'room', 'room' => [ 'version' => '1.0', - 'roomid' => $room->getToken(), ], ]; - $this->logger->debug('Pinged {numSessions} sessions in room {token}', [ + $this->logger->debug('Pinged {numSessions} sessions {token}', [ 'numSessions' => count($pingSessionIds), - 'token' => $request['roomid'], + 'token' => !empty($request['roomid']) ? ('in room ' . $request['roomid']) : '', 'app' => 'spreed-hpb', ]); return new DataResponse($response); diff --git a/lib/Events/SilentModifyParticipantEvent.php b/lib/Events/SilentModifyParticipantEvent.php new file mode 100644 index 000000000..1ac9d3806 --- /dev/null +++ b/lib/Events/SilentModifyParticipantEvent.php @@ -0,0 +1,27 @@ +<?php + +declare(strict_types=1); +/** + * @copyright Copyright (c) 2022 Vitor Mattos <vitor@php.rio> + * + * @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\Events; + +class SilentModifyParticipantEvent extends ModifyParticipantEvent { +} diff --git a/lib/Notification/Listener.php b/lib/Notification/Listener.php index f6913e67a..7ab0d5274 100644 --- a/lib/Notification/Listener.php +++ b/lib/Notification/Listener.php @@ -28,6 +28,7 @@ use OCA\Talk\Events\AddParticipantsEvent; use OCA\Talk\Events\JoinRoomUserEvent; use OCA\Talk\Events\RoomEvent; use OCA\Talk\Events\SendCallNotificationEvent; +use OCA\Talk\Events\SilentModifyParticipantEvent; use OCA\Talk\Model\Attendee; use OCA\Talk\Room; use OCA\Talk\Service\ParticipantService; @@ -90,7 +91,8 @@ class Listener implements IEventListener { $listener = static function (RoomEvent $event): void { $listener = Server::get(self::class); - $listener->checkCallNotifications($event->getRoom()); + $silent = $event instanceof SilentModifyParticipantEvent; + $listener->checkCallNotifications($event->getRoom(), $silent); }; $dispatcher->addListener(Room::EVENT_BEFORE_SESSION_JOIN_CALL, $listener); @@ -188,10 +190,12 @@ class Listener implements IEventListener { /** * Call notification: "{user} wants to talk with you" - * - * @param Room $room */ - public function checkCallNotifications(Room $room): void { + public function checkCallNotifications(Room $room, bool $silent = false): void { + if ($silent) { + $this->shouldSendCallNotification = false; + return; + } if ($room->getActiveSince() instanceof \DateTime) { // Call already active => No new notifications $this->shouldSendCallNotification = false; diff --git a/lib/Service/ParticipantService.php b/lib/Service/ParticipantService.php index 274ed2986..852e33d7f 100644 --- a/lib/Service/ParticipantService.php +++ b/lib/Service/ParticipantService.php @@ -43,6 +43,7 @@ use OCA\Talk\Events\RemoveParticipantEvent; use OCA\Talk\Events\RemoveUserEvent; use OCA\Talk\Events\RoomEvent; use OCA\Talk\Events\SendCallNotificationEvent; +use OCA\Talk\Events\SilentModifyParticipantEvent; use OCA\Talk\Exceptions\ForbiddenException; use OCA\Talk\Exceptions\InvalidPasswordException; use OCA\Talk\Exceptions\ParticipantNotFoundException; @@ -947,7 +948,7 @@ class ParticipantService { $this->dispatcher->dispatch(Room::EVENT_AFTER_END_CALL_FOR_EVERYONE, $event); } - public function changeInCall(Room $room, Participant $participant, int $flags, bool $endCallForEveryone = false): void { + public function changeInCall(Room $room, Participant $participant, int $flags, bool $endCallForEveryone = false, bool $silent = false): void { $session = $participant->getSession(); if (!$session instanceof Session) { return; @@ -962,7 +963,11 @@ class ParticipantService { } if ($flags !== Participant::FLAG_DISCONNECTED) { - $event = new ModifyParticipantEvent($room, $participant, 'inCall', $flags, $session->getInCall()); + if ($silent) { + $event = new SilentModifyParticipantEvent($room, $participant, 'inCall', $flags, $session->getInCall(), $silent); + } else { + $event = new ModifyParticipantEvent($room, $participant, 'inCall', $flags, $session->getInCall(), $silent); + } $this->dispatcher->dispatch(Room::EVENT_BEFORE_SESSION_JOIN_CALL, $event); } else { if ($endCallForEveryone) { diff --git a/lib/Signaling/BackendNotifier.php b/lib/Signaling/BackendNotifier.php index a1c0547d1..139107a9d 100644 --- a/lib/Signaling/BackendNotifier.php +++ b/lib/Signaling/BackendNotifier.php @@ -129,7 +129,7 @@ class BackendNotifier { $hash = hash_hmac('sha256', $random . $body, $this->config->getSignalingSecret()); $headers['Spreed-Signaling-Random'] = $random; $headers['Spreed-Signaling-Checksum'] = $hash; - $headers['Spreed-Signaling-Backend'] = $this->urlGenerator->getBaseUrl(); + $headers['Spreed-Signaling-Backend'] = $this->urlGenerator->getAbsoluteURL(''); $params = [ 'headers' => $headers, |