From 9e8d94d58f4cf230e08fbca95393040c44acbd50 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 18 Oct 2021 16:17:11 +0200 Subject: Replace old type constants with new ones Signed-off-by: Joas Schilling --- lib/Activity/Listener.php | 2 +- lib/Activity/Provider/Base.php | 8 +-- lib/Chat/AutoComplete/SearchPlugin.php | 2 +- lib/Chat/Notifier.php | 4 +- lib/Chat/Parser/UserMention.php | 6 +- lib/Chat/SystemMessage/Listener.php | 12 ++-- .../Resources/ConversationProvider.php | 8 +-- lib/Command/Room/Add.php | 2 +- lib/Command/Room/Create.php | 2 +- lib/Command/Room/Delete.php | 2 +- lib/Command/Room/Demote.php | 2 +- lib/Command/Room/Promote.php | 2 +- lib/Command/Room/Remove.php | 2 +- lib/Command/Room/TRoomCommand.php | 6 +- lib/Command/Room/Update.php | 2 +- lib/Controller/ChatController.php | 4 +- lib/Controller/FilesIntegrationController.php | 4 +- lib/Controller/PageController.php | 8 +-- lib/Controller/PublicShareAuthController.php | 2 +- lib/Controller/RoomController.php | 46 +++++++------- lib/Listener/UserDeletedListener.php | 2 +- lib/Manager.php | 24 +++---- lib/Migration/Version2001Date20170707115443.php | 2 +- lib/Notification/Notifier.php | 22 +++---- lib/Room.php | 30 ++++----- lib/Search/ConversationSearch.php | 8 +-- lib/Search/MessageSearch.php | 4 +- lib/Service/ParticipantService.php | 6 +- lib/Service/RoomService.php | 8 +-- lib/Share/Helper/ShareAPIController.php | 2 +- lib/Share/RoomShareProvider.php | 2 +- tests/php/Activity/Provider/BaseTest.php | 12 ++-- tests/php/Chat/Parser/UserMentionTest.php | 2 +- tests/php/Chat/SystemMessage/ListenerTest.php | 14 ++-- .../Collaboration/Collaborators/RoomPluginTest.php | 62 +++++++++--------- tests/php/Controller/SignalingControllerTest.php | 30 ++++----- tests/php/Notification/NotifierTest.php | 74 +++++++++++----------- tests/php/RoomTest.php | 2 +- tests/php/Service/RoomServiceTest.php | 16 ++--- tests/php/Signaling/BackendNotifierTest.php | 28 ++++---- 40 files changed, 238 insertions(+), 238 deletions(-) diff --git a/lib/Activity/Listener.php b/lib/Activity/Listener.php index 65d98bbed..78f62dad1 100644 --- a/lib/Activity/Listener.php +++ b/lib/Activity/Listener.php @@ -124,7 +124,7 @@ class Listener { $message = 'call_ended'; if ((\count($userIds) + $numGuests) === 1) { - if ($room->getType() !== Room::ONE_TO_ONE_CALL) { + if ($room->getType() !== Room::TYPE_ONE_TO_ONE) { // Single user pinged or guests only => no summary/activity $room->resetActiveSince(); return false; diff --git a/lib/Activity/Provider/Base.php b/lib/Activity/Provider/Base.php index a61a16f01..b1803ceaf 100644 --- a/lib/Activity/Provider/Base.php +++ b/lib/Activity/Provider/Base.php @@ -110,13 +110,13 @@ abstract class Base implements IProvider { protected function getRoom(Room $room, string $userId): array { switch ($room->getType()) { - case Room::ONE_TO_ONE_CALL: + case Room::TYPE_ONE_TO_ONE: $stringType = 'one2one'; break; - case Room::GROUP_CALL: + case Room::TYPE_GROUP: $stringType = 'group'; break; - case Room::PUBLIC_CALL: + case Room::TYPE_PUBLIC: default: $stringType = 'public'; break; @@ -136,7 +136,7 @@ abstract class Base implements IProvider { 'type' => 'call', 'id' => $roomId, 'name' => $l->t('a conversation'), - 'call-type' => Room::UNKNOWN_CALL, + 'call-type' => Room::TYPE_UNKNOWN, ]; } diff --git a/lib/Chat/AutoComplete/SearchPlugin.php b/lib/Chat/AutoComplete/SearchPlugin.php index 347593269..aed0b589c 100644 --- a/lib/Chat/AutoComplete/SearchPlugin.php +++ b/lib/Chat/AutoComplete/SearchPlugin.php @@ -93,7 +93,7 @@ class SearchPlugin implements ISearchPlugin { } $userIds = $guestAttendees = []; - if ($this->room->getType() === Room::ONE_TO_ONE_CALL) { + if ($this->room->getType() === Room::TYPE_ONE_TO_ONE) { // Add potential leavers of one-to-one rooms again. $participants = json_decode($this->room->getName(), true); foreach ($participants as $userId) { diff --git a/lib/Chat/Notifier.php b/lib/Chat/Notifier.php index deb8eb5f5..10382dfd6 100644 --- a/lib/Chat/Notifier.php +++ b/lib/Chat/Notifier.php @@ -184,7 +184,7 @@ class Notifier { } // Also notify default participants in one2one chats or when the admin default is "always" - if ($this->getDefaultGroupNotification() === Participant::NOTIFY_ALWAYS || $chat->getType() === Room::ONE_TO_ONE_CALL) { + if ($this->getDefaultGroupNotification() === Participant::NOTIFY_ALWAYS || $chat->getType() === Room::TYPE_ONE_TO_ONE) { $participants = $this->participantService->getParticipantsByNotificationLevel($chat, Participant::NOTIFY_DEFAULT); foreach ($participants as $participant) { if (!$this->shouldParticipantBeNotified($participant, $comment, $alreadyNotifiedUsers)) { @@ -335,7 +335,7 @@ class Notifier { $participant = $room->getParticipant($userId, false); $notificationLevel = $participant->getAttendee()->getNotificationLevel(); if ($notificationLevel === Participant::NOTIFY_DEFAULT) { - if ($room->getType() === Room::ONE_TO_ONE_CALL) { + if ($room->getType() === Room::TYPE_ONE_TO_ONE) { $notificationLevel = Participant::NOTIFY_ALWAYS; } else { $notificationLevel = $this->getDefaultGroupNotification(); diff --git a/lib/Chat/Parser/UserMention.php b/lib/Chat/Parser/UserMention.php index 269c6f20e..743fb2caa 100644 --- a/lib/Chat/Parser/UserMention.php +++ b/lib/Chat/Parser/UserMention.php @@ -174,11 +174,11 @@ class UserMention { */ protected function getRoomType(Room $room): string { switch ($room->getType()) { - case Room::ONE_TO_ONE_CALL: + case Room::TYPE_ONE_TO_ONE: return 'one2one'; - case Room::GROUP_CALL: + case Room::TYPE_GROUP: return 'group'; - case Room::PUBLIC_CALL: + case Room::TYPE_PUBLIC: return 'public'; default: throw new \InvalidArgumentException('Unknown room type'); diff --git a/lib/Chat/SystemMessage/Listener.php b/lib/Chat/SystemMessage/Listener.php index 67eb04c1c..31f5a4ba6 100644 --- a/lib/Chat/SystemMessage/Listener.php +++ b/lib/Chat/SystemMessage/Listener.php @@ -159,15 +159,15 @@ class Listener implements IEventListener { $dispatcher->addListener(Room::EVENT_AFTER_TYPE_SET, static function (ModifyRoomEvent $event) { $room = $event->getRoom(); - if ($event->getOldValue() === Room::ONE_TO_ONE_CALL) { + if ($event->getOldValue() === Room::TYPE_ONE_TO_ONE) { return; } - if ($event->getNewValue() === Room::PUBLIC_CALL) { + if ($event->getNewValue() === Room::TYPE_PUBLIC) { /** @var self $listener */ $listener = \OC::$server->query(self::class); $listener->sendSystemMessage($room, 'guests_allowed'); - } elseif ($event->getNewValue() === Room::GROUP_CALL) { + } elseif ($event->getNewValue() === Room::TYPE_GROUP) { /** @var self $listener */ $listener = \OC::$server->query(self::class); $listener->sendSystemMessage($room, 'guests_disallowed'); @@ -176,7 +176,7 @@ class Listener implements IEventListener { $dispatcher->addListener(Room::EVENT_AFTER_READONLY_SET, static function (ModifyRoomEvent $event) { $room = $event->getRoom(); - if ($room->getType() === Room::CHANGELOG_CONVERSATION) { + if ($room->getType() === Room::TYPE_CHANGELOG) { return; } @@ -224,7 +224,7 @@ class Listener implements IEventListener { $dispatcher->addListener(Room::EVENT_AFTER_USERS_ADD, static function (AddParticipantsEvent $event) { $room = $event->getRoom(); - if ($room->getType() === Room::ONE_TO_ONE_CALL) { + if ($room->getType() === Room::TYPE_ONE_TO_ONE) { return; } @@ -260,7 +260,7 @@ class Listener implements IEventListener { $dispatcher->addListener(Room::EVENT_AFTER_USER_REMOVE, static function (RemoveUserEvent $event) { $room = $event->getRoom(); - if ($room->getType() === Room::ONE_TO_ONE_CALL) { + if ($room->getType() === Room::TYPE_ONE_TO_ONE) { return; } diff --git a/lib/Collaboration/Resources/ConversationProvider.php b/lib/Collaboration/Resources/ConversationProvider.php index c2ed1ed02..3c30b1428 100644 --- a/lib/Collaboration/Resources/ConversationProvider.php +++ b/lib/Collaboration/Resources/ConversationProvider.php @@ -61,7 +61,7 @@ class ConversationProvider implements IProvider { $iconURL = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('spreed', 'app-dark.svg')); /** * Disabled for now, because it would show a square avatar - * if ($room->getType() === Room::ONE_TO_ONE_CALL) { + * if ($room->getType() === Room::TYPE_ONE_TO_ONE) { * $iconURL = $this->urlGenerator->linkToRouteAbsolute('core.avatar.getAvatar', ['userId' => 'admin', 'size' => 32]); * } */ @@ -113,11 +113,11 @@ class ConversationProvider implements IProvider { */ protected function getRoomType(Room $room): string { switch ($room->getType()) { - case Room::ONE_TO_ONE_CALL: + case Room::TYPE_ONE_TO_ONE: return 'one2one'; - case Room::GROUP_CALL: + case Room::TYPE_GROUP: return 'group'; - case Room::PUBLIC_CALL: + case Room::TYPE_PUBLIC: return 'public'; default: throw new \InvalidArgumentException('Unknown room type'); diff --git a/lib/Command/Room/Add.php b/lib/Command/Room/Add.php index 556b9fba4..377741b37 100644 --- a/lib/Command/Room/Add.php +++ b/lib/Command/Room/Add.php @@ -71,7 +71,7 @@ class Add extends Base { return 1; } - if (!in_array($room->getType(), [Room::GROUP_CALL, Room::PUBLIC_CALL], true)) { + if (!in_array($room->getType(), [Room::TYPE_GROUP, Room::TYPE_PUBLIC], true)) { $output->writeln('Room is no group call.'); return 1; } diff --git a/lib/Command/Room/Create.php b/lib/Command/Room/Create.php index 8e992aaf3..4b5208e2e 100644 --- a/lib/Command/Room/Create.php +++ b/lib/Command/Room/Create.php @@ -120,7 +120,7 @@ class Create extends Base { return 1; } - $roomType = $public ? Room::PUBLIC_CALL : Room::GROUP_CALL; + $roomType = $public ? Room::TYPE_PUBLIC : Room::TYPE_GROUP; try { $room = $this->roomService->createConversation($roomType, $name); } catch (InvalidArgumentException $e) { diff --git a/lib/Command/Room/Delete.php b/lib/Command/Room/Delete.php index 7135277dd..3f5907415 100644 --- a/lib/Command/Room/Delete.php +++ b/lib/Command/Room/Delete.php @@ -57,7 +57,7 @@ class Delete extends Base { return 1; } - if (!in_array($room->getType(), [Room::GROUP_CALL, Room::PUBLIC_CALL], true)) { + if (!in_array($room->getType(), [Room::TYPE_GROUP, Room::TYPE_PUBLIC], true)) { $output->writeln('Room is no group call.'); return 1; } diff --git a/lib/Command/Room/Demote.php b/lib/Command/Room/Demote.php index a7f6a91d8..a150529af 100644 --- a/lib/Command/Room/Demote.php +++ b/lib/Command/Room/Demote.php @@ -63,7 +63,7 @@ class Demote extends Base { return 1; } - if (!in_array($room->getType(), [Room::GROUP_CALL, Room::PUBLIC_CALL], true)) { + if (!in_array($room->getType(), [Room::TYPE_GROUP, Room::TYPE_PUBLIC], true)) { $output->writeln('Room is no group call.'); return 1; } diff --git a/lib/Command/Room/Promote.php b/lib/Command/Room/Promote.php index 945dff62e..72088457b 100644 --- a/lib/Command/Room/Promote.php +++ b/lib/Command/Room/Promote.php @@ -63,7 +63,7 @@ class Promote extends Base { return 1; } - if (!in_array($room->getType(), [Room::GROUP_CALL, Room::PUBLIC_CALL], true)) { + if (!in_array($room->getType(), [Room::TYPE_GROUP, Room::TYPE_PUBLIC], true)) { $output->writeln('Room is no group call.'); return 1; } diff --git a/lib/Command/Room/Remove.php b/lib/Command/Room/Remove.php index 4424307e0..38a7ca4af 100644 --- a/lib/Command/Room/Remove.php +++ b/lib/Command/Room/Remove.php @@ -63,7 +63,7 @@ class Remove extends Base { return 1; } - if (!in_array($room->getType(), [Room::GROUP_CALL, Room::PUBLIC_CALL], true)) { + if (!in_array($room->getType(), [Room::TYPE_GROUP, Room::TYPE_PUBLIC], true)) { $output->writeln('Room is no group call.'); return 1; } diff --git a/lib/Command/Room/TRoomCommand.php b/lib/Command/Room/TRoomCommand.php index ecfa28d9d..b878fbb2e 100644 --- a/lib/Command/Room/TRoomCommand.php +++ b/lib/Command/Room/TRoomCommand.php @@ -127,11 +127,11 @@ trait TRoomCommand { * @throws InvalidArgumentException */ protected function setRoomPublic(Room $room, bool $public): void { - if ($public === ($room->getType() === Room::PUBLIC_CALL)) { + if ($public === ($room->getType() === Room::TYPE_PUBLIC)) { return; } - if (!$room->setType($public ? Room::PUBLIC_CALL : Room::GROUP_CALL)) { + if (!$room->setType($public ? Room::TYPE_PUBLIC : Room::TYPE_GROUP)) { throw new InvalidArgumentException('Unable to change room type.'); } } @@ -179,7 +179,7 @@ trait TRoomCommand { return; } - if (($password !== '') && ($room->getType() !== Room::PUBLIC_CALL)) { + if (($password !== '') && ($room->getType() !== Room::TYPE_PUBLIC)) { throw new InvalidArgumentException('Unable to add password protection to private room.'); } diff --git a/lib/Command/Room/Update.php b/lib/Command/Room/Update.php index a32797455..d8abc64f0 100644 --- a/lib/Command/Room/Update.php +++ b/lib/Command/Room/Update.php @@ -121,7 +121,7 @@ class Update extends Base { return 1; } - if (!in_array($room->getType(), [Room::GROUP_CALL, Room::PUBLIC_CALL], true)) { + if (!in_array($room->getType(), [Room::TYPE_GROUP, Room::TYPE_PUBLIC], true)) { $output->writeln('Room is no group call.'); return 1; } diff --git a/lib/Controller/ChatController.php b/lib/Controller/ChatController.php index 920e6dd57..c0bb8d628 100644 --- a/lib/Controller/ChatController.php +++ b/lib/Controller/ChatController.php @@ -566,7 +566,7 @@ class ChatController extends AEnvironmentAwareController { $isOwnMessage = $isOwnMessage || ($message->getActorType() === Attendee::ACTOR_BRIDGED && $attendee->getActorId() === MatterbridgeManager::BRIDGE_BOT_USERID); if (!$isOwnMessage && (!$this->participant->hasModeratorPermissions(false) - || $this->room->getType() === Room::ONE_TO_ONE_CALL)) { + || $this->room->getType() === Room::TYPE_ONE_TO_ONE)) { // Actor is not a moderator or not the owner of the message return new DataResponse([], Http::STATUS_FORBIDDEN); } @@ -620,7 +620,7 @@ class ChatController extends AEnvironmentAwareController { public function clearHistory(): DataResponse { $attendee = $this->participant->getAttendee(); if (!$this->participant->hasModeratorPermissions(false) - || $this->room->getType() === Room::ONE_TO_ONE_CALL) { + || $this->room->getType() === Room::TYPE_ONE_TO_ONE) { // Actor is not a moderator or not the owner of the message return new DataResponse([], Http::STATUS_FORBIDDEN); } diff --git a/lib/Controller/FilesIntegrationController.php b/lib/Controller/FilesIntegrationController.php index bf38b6431..eeb1a841a 100644 --- a/lib/Controller/FilesIntegrationController.php +++ b/lib/Controller/FilesIntegrationController.php @@ -148,7 +148,7 @@ class FilesIntegrationController extends OCSController { } catch (RoomNotFoundException $e) { $name = $node->getName(); $name = $this->roomService->prepareConversationName($name); - $room = $this->roomService->createConversation(Room::PUBLIC_CALL, $name, null, 'file', $fileId); + $room = $this->roomService->createConversation(Room::TYPE_PUBLIC, $name, null, 'file', $fileId); } return new DataResponse([ @@ -218,7 +218,7 @@ class FilesIntegrationController extends OCSController { } catch (RoomNotFoundException $e) { $name = $share->getNode()->getName(); $name = $this->roomService->prepareConversationName($name); - $room = $this->roomService->createConversation(Room::PUBLIC_CALL, $name, null, 'file', $fileId); + $room = $this->roomService->createConversation(Room::TYPE_PUBLIC, $name, null, 'file', $fileId); } } catch (NotFoundException $e) { return new DataResponse([], Http::STATUS_NOT_FOUND); diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index 7cc11196c..921097446 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -205,7 +205,7 @@ class PageController extends Controller { } // If the room is not a public room, check if the user is in the participants - if ($room->getType() !== Room::PUBLIC_CALL) { + if ($room->getType() !== Room::TYPE_PUBLIC) { $this->manager->getRoomForUser($room->getId(), $this->userId); } } catch (RoomNotFoundException $e) { @@ -243,7 +243,7 @@ class PageController extends Controller { } } } else { - $response = $this->api->createRoom(Room::ONE_TO_ONE_CALL, $callUser); + $response = $this->api->createRoom(Room::TYPE_ONE_TO_ONE, $callUser); if ($response->getStatus() === Http::STATUS_OK || $response->getStatus() === Http::STATUS_CREATED) { $data = $response->getData(); @@ -284,7 +284,7 @@ class PageController extends Controller { protected function guestEnterRoom(string $token, string $password): Response { try { $room = $this->manager->getRoomByToken($token); - if ($room->getType() !== Room::PUBLIC_CALL) { + if ($room->getType() !== Room::TYPE_PUBLIC) { throw new RoomNotFoundException(); } } catch (RoomNotFoundException $e) { @@ -348,7 +348,7 @@ class PageController extends Controller { if ($this->userId === null) { try { $room = $this->manager->getRoomByToken($token); - if ($room->getType() !== Room::PUBLIC_CALL) { + if ($room->getType() !== Room::TYPE_PUBLIC) { throw new RoomNotFoundException(); } return new RedirectResponse($this->url->linkToRoute('spreed.Page.showCall', ['token' => $token])); diff --git a/lib/Controller/PublicShareAuthController.php b/lib/Controller/PublicShareAuthController.php index f75c529d1..390aa4615 100644 --- a/lib/Controller/PublicShareAuthController.php +++ b/lib/Controller/PublicShareAuthController.php @@ -107,7 +107,7 @@ class PublicShareAuthController extends OCSController { $roomName = $this->roomService->prepareConversationName($roomName); // Create the room - $room = $this->roomService->createConversation(Room::PUBLIC_CALL, $roomName, $sharerUser, 'share:password', $shareToken); + $room = $this->roomService->createConversation(Room::TYPE_PUBLIC, $roomName, $sharerUser, 'share:password', $shareToken); $user = $this->userSession->getUser(); $userId = $user instanceof IUser ? $user->getUID() : ''; diff --git a/lib/Controller/RoomController.php b/lib/Controller/RoomController.php index 3b19034c6..0c1af08ab 100644 --- a/lib/Controller/RoomController.php +++ b/lib/Controller/RoomController.php @@ -222,7 +222,7 @@ class RoomController extends AEnvironmentAwareController { && $includeStatus && $this->appManager->isEnabledForUser('user_status')) { $userIds = array_filter(array_map(function (Room $room) { - if ($room->getType() === Room::ONE_TO_ONE_CALL) { + if ($room->getType() === Room::TYPE_ONE_TO_ONE) { $participants = json_decode($room->getName(), true); foreach ($participants as $participant) { if ($participant !== $this->userId) { @@ -507,7 +507,7 @@ class RoomController extends AEnvironmentAwareController { if ($roomData['notificationLevel'] === Participant::NOTIFY_DEFAULT) { if ($currentParticipant->isGuest()) { $roomData['notificationLevel'] = Participant::NOTIFY_NEVER; - } elseif ($room->getType() === Room::ONE_TO_ONE_CALL) { + } elseif ($room->getType() === Room::TYPE_ONE_TO_ONE) { $roomData['notificationLevel'] = Participant::NOTIFY_ALWAYS; } else { $adminSetting = (int) $this->config->getAppValue('spreed', 'default_group_notification', Participant::NOTIFY_DEFAULT); @@ -556,20 +556,20 @@ class RoomController extends AEnvironmentAwareController { $roomData['unreadMentionDirect'] = $lastMentionDirect !== 0 && $lastReadMessage < $lastMentionDirect; $roomData['lastReadMessage'] = $lastReadMessage; - $roomData['canDeleteConversation'] = $room->getType() !== Room::ONE_TO_ONE_CALL + $roomData['canDeleteConversation'] = $room->getType() !== Room::TYPE_ONE_TO_ONE && $currentParticipant->hasModeratorPermissions(false); $roomData['canLeaveConversation'] = true; $roomData['canEnableSIP'] = $this->talkConfig->isSIPConfigured() && !preg_match(Room::SIP_INCOMPATIBLE_REGEX, $room->getToken()) - && ($room->getType() === Room::GROUP_CALL || $room->getType() === Room::PUBLIC_CALL) + && ($room->getType() === Room::TYPE_GROUP || $room->getType() === Room::TYPE_PUBLIC) && $currentParticipant->hasModeratorPermissions(false) && $this->talkConfig->canUserEnableSIP($currentUser); } } // FIXME This should not be done, but currently all the clients use it to get the avatar of the user … - if ($room->getType() === Room::ONE_TO_ONE_CALL) { + if ($room->getType() === Room::TYPE_ONE_TO_ONE) { $participants = json_decode($room->getName(), true); foreach ($participants as $participant) { if ($participant !== $attendee->getActorId()) { @@ -629,7 +629,7 @@ class RoomController extends AEnvironmentAwareController { * @return DataResponse */ public function createRoom(int $roomType, string $invite = '', string $roomName = '', string $source = ''): DataResponse { - if ($roomType !== Room::ONE_TO_ONE_CALL) { + if ($roomType !== Room::TYPE_ONE_TO_ONE) { /** @var IUser $user */ $user = $this->userManager->get($this->userId); @@ -639,9 +639,9 @@ class RoomController extends AEnvironmentAwareController { } switch ($roomType) { - case Room::ONE_TO_ONE_CALL: + case Room::TYPE_ONE_TO_ONE: return $this->createOneToOneRoom($invite); - case Room::GROUP_CALL: + case Room::TYPE_GROUP: if ($invite === '') { return $this->createEmptyRoom($roomName, false); } @@ -649,7 +649,7 @@ class RoomController extends AEnvironmentAwareController { return $this->createCircleRoom($invite); } return $this->createGroupRoom($invite); - case Room::PUBLIC_CALL: + case Room::TYPE_PUBLIC: return $this->createEmptyRoom($roomName); } @@ -726,7 +726,7 @@ class RoomController extends AEnvironmentAwareController { // Create the room $name = $this->roomService->prepareConversationName($targetGroup->getDisplayName()); - $room = $this->roomService->createConversation(Room::GROUP_CALL, $name, $currentUser); + $room = $this->roomService->createConversation(Room::TYPE_GROUP, $name, $currentUser); $this->participantService->addGroup($room, $targetGroup); return new DataResponse($this->formatRoom($room, $room->getParticipant($currentUser->getUID(), false)), Http::STATUS_CREATED); @@ -758,7 +758,7 @@ class RoomController extends AEnvironmentAwareController { // Create the room $name = $this->roomService->prepareConversationName($circle->getName()); - $room = $this->roomService->createConversation(Room::GROUP_CALL, $name, $currentUser); + $room = $this->roomService->createConversation(Room::TYPE_GROUP, $name, $currentUser); $this->participantService->addCircle($room, $circle); return new DataResponse($this->formatRoom($room, $room->getParticipant($currentUser->getUID(), false)), Http::STATUS_CREATED); @@ -777,7 +777,7 @@ class RoomController extends AEnvironmentAwareController { return new DataResponse([], Http::STATUS_NOT_FOUND); } - $roomType = $public ? Room::PUBLIC_CALL : Room::GROUP_CALL; + $roomType = $public ? Room::TYPE_PUBLIC : Room::TYPE_GROUP; // Create the room try { @@ -836,7 +836,7 @@ class RoomController extends AEnvironmentAwareController { * @return DataResponse */ public function renameRoom(string $roomName): DataResponse { - if ($this->room->getType() === Room::ONE_TO_ONE_CALL) { + if ($this->room->getType() === Room::TYPE_ONE_TO_ONE) { return new DataResponse([], Http::STATUS_BAD_REQUEST); } @@ -858,7 +858,7 @@ class RoomController extends AEnvironmentAwareController { * @return DataResponse */ public function setDescription(string $description): DataResponse { - if ($this->room->getType() === Room::ONE_TO_ONE_CALL) { + if ($this->room->getType() === Room::TYPE_ONE_TO_ONE) { return new DataResponse([], Http::STATUS_BAD_REQUEST); } @@ -878,7 +878,7 @@ class RoomController extends AEnvironmentAwareController { * @return DataResponse */ public function deleteRoom(): DataResponse { - if ($this->room->getType() === Room::ONE_TO_ONE_CALL) { + if ($this->room->getType() === Room::TYPE_ONE_TO_ONE) { return new DataResponse([], Http::STATUS_BAD_REQUEST); } @@ -1033,7 +1033,7 @@ class RoomController extends AEnvironmentAwareController { * @return DataResponse */ public function addParticipantToRoom(string $newParticipant, string $source = 'users'): DataResponse { - if ($this->room->getType() === Room::ONE_TO_ONE_CALL || $this->room->getObjectType() === 'share:password') { + if ($this->room->getType() === Room::TYPE_ONE_TO_ONE || $this->room->getObjectType() === 'share:password') { return new DataResponse([], Http::STATUS_BAD_REQUEST); } @@ -1088,7 +1088,7 @@ class RoomController extends AEnvironmentAwareController { $this->participantService->addCircle($this->room, $circle, $participants); } elseif ($source === 'emails') { $data = []; - if ($this->room->setType(Room::PUBLIC_CALL)) { + if ($this->room->setType(Room::TYPE_PUBLIC)) { $data = ['type' => $this->room->getType()]; } @@ -1153,7 +1153,7 @@ class RoomController extends AEnvironmentAwareController { } protected function removeSelfFromRoomLogic(Room $room, Participant $participant): DataResponse { - if ($room->getType() !== Room::ONE_TO_ONE_CALL) { + if ($room->getType() !== Room::TYPE_ONE_TO_ONE) { if ($participant->hasModeratorPermissions(false) && $this->participantService->getNumberOfUsers($room) > 1 && $this->participantService->getNumberOfModerators($room) === 1) { @@ -1161,7 +1161,7 @@ class RoomController extends AEnvironmentAwareController { } } - if ($room->getType() !== Room::CHANGELOG_CONVERSATION && + if ($room->getType() !== Room::TYPE_CHANGELOG && $room->getObjectType() !== 'file' && $this->participantService->getNumberOfUsers($room) === 1 && \in_array($participant->getAttendee()->getParticipantType(), [ @@ -1202,7 +1202,7 @@ class RoomController extends AEnvironmentAwareController { return new DataResponse([], Http::STATUS_NOT_FOUND); } - if ($this->room->getType() === Room::ONE_TO_ONE_CALL) { + if ($this->room->getType() === Room::TYPE_ONE_TO_ONE) { return new DataResponse([], Http::STATUS_BAD_REQUEST); } @@ -1225,7 +1225,7 @@ class RoomController extends AEnvironmentAwareController { * @return DataResponse */ public function makePublic(): DataResponse { - if (!$this->room->setType(Room::PUBLIC_CALL)) { + if (!$this->room->setType(Room::TYPE_PUBLIC)) { return new DataResponse([], Http::STATUS_BAD_REQUEST); } @@ -1239,7 +1239,7 @@ class RoomController extends AEnvironmentAwareController { * @return DataResponse */ public function makePrivate(): DataResponse { - if (!$this->room->setType(Room::GROUP_CALL)) { + if (!$this->room->setType(Room::TYPE_GROUP)) { return new DataResponse([], Http::STATUS_BAD_REQUEST); } @@ -1293,7 +1293,7 @@ class RoomController extends AEnvironmentAwareController { * @return DataResponse */ public function setPassword(string $password): DataResponse { - if ($this->room->getType() !== Room::PUBLIC_CALL) { + if ($this->room->getType() !== Room::TYPE_PUBLIC) { return new DataResponse([], Http::STATUS_FORBIDDEN); } diff --git a/lib/Listener/UserDeletedListener.php b/lib/Listener/UserDeletedListener.php index 47ad1b723..c93a106bd 100644 --- a/lib/Listener/UserDeletedListener.php +++ b/lib/Listener/UserDeletedListener.php @@ -64,7 +64,7 @@ class UserDeletedListener implements IEventListener { foreach ($leftRooms as $room) { // We are changing the room type and name so a potential follow up // user with the same user-id can not reopen the one-to-one conversation. - $room->setType(Room::GROUP_CALL, true); + $room->setType(Room::TYPE_GROUP, true); $room->setName($user->getDisplayName(), ''); } } diff --git a/lib/Manager.php b/lib/Manager.php index 95d281f35..f414c57c0 100644 --- a/lib/Manager.php +++ b/lib/Manager.php @@ -370,7 +370,7 @@ class Manager { $helper = new SelectHelper(); $helper->selectRoomsTable($query); $query->from('talk_rooms', 'r') - ->where($query->expr()->eq('r.type', $query->createNamedParameter(Room::ONE_TO_ONE_CALL))) + ->where($query->expr()->eq('r.type', $query->createNamedParameter(Room::TYPE_ONE_TO_ONE))) ->andWhere($query->expr()->like('r.name', $query->createNamedParameter('%' . $this->db->escapeLikeParameter(json_encode($userId)) . '%'))); $result = $query->execute(); @@ -424,7 +424,7 @@ class Manager { * @return Room[] */ public function getListedRoomsForUser(string $userId, string $term = ''): array { - $allowedRoomTypes = [Room::GROUP_CALL, Room::PUBLIC_CALL]; + $allowedRoomTypes = [Room::TYPE_GROUP, Room::TYPE_PUBLIC]; $allowedListedTypes = [Room::LISTABLE_ALL]; if (!$this->isGuestUser($userId)) { $allowedListedTypes[] = Room::LISTABLE_USERS; @@ -505,7 +505,7 @@ class Manager { $room->setParticipant($row['actor_id'], $this->createParticipantObject($room, $row)); } - if ($userId === null && $room->getType() !== Room::PUBLIC_CALL) { + if ($userId === null && $room->getType() !== Room::TYPE_PUBLIC) { throw new RoomNotFoundException(); } @@ -576,7 +576,7 @@ class Manager { $room->setParticipant($row['actor_id'], $this->createParticipantObject($room, $row)); } - if ($isSIPBridgeRequest || $room->getType() === Room::PUBLIC_CALL) { + if ($isSIPBridgeRequest || $room->getType() === Room::TYPE_PUBLIC) { return $room; } @@ -800,7 +800,7 @@ class Manager { $participant = $this->createParticipantObject($room, $row); $room->setParticipant($row['actor_id'], $participant); - if ($room->getType() === Room::PUBLIC_CALL || !in_array($participant->getAttendee()->getParticipantType(), [Participant::GUEST, Participant::GUEST_MODERATOR, Participant::USER_SELF_JOINED], true)) { + if ($room->getType() === Room::TYPE_PUBLIC || !in_array($participant->getAttendee()->getParticipantType(), [Participant::GUEST, Participant::GUEST_MODERATOR, Participant::USER_SELF_JOINED], true)) { return $room; } @@ -822,7 +822,7 @@ class Manager { $helper = new SelectHelper(); $helper->selectRoomsTable($query); $query->from('talk_rooms', 'r') - ->where($query->expr()->eq('r.type', $query->createNamedParameter(Room::ONE_TO_ONE_CALL, IQueryBuilder::PARAM_INT))) + ->where($query->expr()->eq('r.type', $query->createNamedParameter(Room::TYPE_ONE_TO_ONE, IQueryBuilder::PARAM_INT))) ->andWhere($query->expr()->eq('r.name', $query->createNamedParameter($name))); $result = $query->execute(); @@ -852,7 +852,7 @@ class Manager { $helper = new SelectHelper(); $helper->selectRoomsTable($query); $query->from('talk_rooms', 'r') - ->where($query->expr()->eq('r.type', $query->createNamedParameter(Room::CHANGELOG_CONVERSATION, IQueryBuilder::PARAM_INT))) + ->where($query->expr()->eq('r.type', $query->createNamedParameter(Room::TYPE_CHANGELOG, IQueryBuilder::PARAM_INT))) ->andWhere($query->expr()->eq('r.name', $query->createNamedParameter($userId))); $result = $query->execute(); @@ -860,7 +860,7 @@ class Manager { $result->closeCursor(); if ($row === false) { - $room = $this->createRoom(Room::CHANGELOG_CONVERSATION, $userId); + $room = $this->createRoom(Room::TYPE_CHANGELOG, $userId); $room->setReadOnly(Room::READ_ONLY); $room->setListable(Room::LISTABLE_NONE); @@ -952,20 +952,20 @@ class Manager { if ($room->getObjectType() === 'share:password') { return $this->l->t('Password request: %s', [$room->getName()]); } - if ($room->getType() === Room::CHANGELOG_CONVERSATION) { + if ($room->getType() === Room::TYPE_CHANGELOG) { return $this->l->t('Talk updates ✅'); } - if ($userId === '' && $room->getType() !== Room::PUBLIC_CALL) { + if ($userId === '' && $room->getType() !== Room::TYPE_PUBLIC) { return $this->l->t('Private conversation'); } - if ($room->getType() !== Room::ONE_TO_ONE_CALL && $room->getName() === '') { + if ($room->getType() !== Room::TYPE_ONE_TO_ONE && $room->getName() === '') { $room->setName($this->getRoomNameByParticipants($room)); } // Set the room name to the other participant for one-to-one rooms - if ($room->getType() === Room::ONE_TO_ONE_CALL) { + if ($room->getType() === Room::TYPE_ONE_TO_ONE) { if ($userId === '') { return $this->l->t('Private conversation'); } diff --git a/lib/Migration/Version2001Date20170707115443.php b/lib/Migration/Version2001Date20170707115443.php index 0fc990d21..69316cc02 100644 --- a/lib/Migration/Version2001Date20170707115443.php +++ b/lib/Migration/Version2001Date20170707115443.php @@ -99,7 +99,7 @@ class Version2001Date20170707115443 extends SimpleMigrationStep { $query->select('id') ->from('spreedme_rooms') - ->where($query->expr()->eq('type', $query->createNamedParameter(Room::ONE_TO_ONE_CALL))); + ->where($query->expr()->eq('type', $query->createNamedParameter(Room::TYPE_ONE_TO_ONE))); $result = $query->execute(); $one2oneRooms = []; diff --git a/lib/Notification/Notifier.php b/lib/Notification/Notifier.php index a1607caad..e42dcb29f 100644 --- a/lib/Notification/Notifier.php +++ b/lib/Notification/Notifier.php @@ -409,7 +409,7 @@ class Notifier implements INotifier { 'id' => $message->getComment()->getId(), 'name' => $shortenMessage, ]; - if ($room->getType() === Room::ONE_TO_ONE_CALL) { + if ($room->getType() === Room::TYPE_ONE_TO_ONE) { $subject = "{user}\n{message}"; } elseif ($richSubjectUser) { $subject = $l->t('{user} in {call}') . "\n{message}"; @@ -424,7 +424,7 @@ class Notifier implements INotifier { } } } elseif ($notification->getSubject() === 'chat') { - if ($room->getType() === Room::ONE_TO_ONE_CALL) { + if ($room->getType() === Room::TYPE_ONE_TO_ONE) { $subject = $l->t('{user} sent you a private message'); } elseif ($richSubjectUser) { $subject = $l->t('{user} sent a message in conversation {call}'); @@ -439,7 +439,7 @@ class Notifier implements INotifier { } } } elseif ($notification->getSubject() === 'reply') { - if ($room->getType() === Room::ONE_TO_ONE_CALL) { + if ($room->getType() === Room::TYPE_ONE_TO_ONE) { $subject = $l->t('{user} replied to your private message'); } elseif ($richSubjectUser) { $subject = $l->t('{user} replied to your message in conversation {call}'); @@ -453,7 +453,7 @@ class Notifier implements INotifier { $subject = $l->t('A guest replied to your message in conversation {call}'); } } - } elseif ($room->getType() === Room::ONE_TO_ONE_CALL) { + } elseif ($room->getType() === Room::TYPE_ONE_TO_ONE) { $subject = $l->t('{user} mentioned you in a private conversation'); } elseif ($richSubjectUser) { $subject = $l->t('{user} mentioned you in conversation {call}'); @@ -512,11 +512,11 @@ class Notifier implements INotifier { */ protected function getRoomType(Room $room): string { switch ($room->getType()) { - case Room::ONE_TO_ONE_CALL: + case Room::TYPE_ONE_TO_ONE: return 'one2one'; - case Room::GROUP_CALL: + case Room::TYPE_GROUP: return 'group'; - case Room::PUBLIC_CALL: + case Room::TYPE_PUBLIC: return 'public'; default: throw new \InvalidArgumentException('Unknown room type'); @@ -545,7 +545,7 @@ class Notifier implements INotifier { } $roomName = $room->getDisplayName($notification->getUser()); - if ($room->getType() === Room::ONE_TO_ONE_CALL) { + if ($room->getType() === Room::TYPE_ONE_TO_ONE) { $subject = $l->t('{user} invited you to a private conversation'); if ($this->participantService->hasActiveSessionsInCall($room)) { $notification = $this->addActionButton($notification, $l->t('Join call')); @@ -570,7 +570,7 @@ class Notifier implements INotifier { ], ] ); - } elseif (\in_array($room->getType(), [Room::GROUP_CALL, Room::PUBLIC_CALL], true)) { + } elseif (\in_array($room->getType(), [Room::TYPE_GROUP, Room::TYPE_PUBLIC], true)) { $subject = $l->t('{user} invited you to a group conversation: {call}'); if ($this->participantService->hasActiveSessionsInCall($room)) { $notification = $this->addActionButton($notification, $l->t('Join call')); @@ -616,7 +616,7 @@ class Notifier implements INotifier { } $roomName = $room->getDisplayName($notification->getUser()); - if ($room->getType() === Room::ONE_TO_ONE_CALL) { + if ($room->getType() === Room::TYPE_ONE_TO_ONE) { $parameters = $notification->getSubjectParameters(); $calleeId = $parameters['callee']; $user = $this->userManager->get($calleeId); @@ -649,7 +649,7 @@ class Notifier implements INotifier { } else { throw new AlreadyProcessedException(); } - } elseif (\in_array($room->getType(), [Room::GROUP_CALL, Room::PUBLIC_CALL], true)) { + } elseif (\in_array($room->getType(), [Room::TYPE_GROUP, Room::TYPE_PUBLIC], true)) { if ($this->notificationManager->isPreparingPushNotification() || $this->participantService->hasActiveSessionsInCall($room)) { $notification = $this->addActionButton($notification, $l->t('Join call')); $subject = $l->t('A group call has started in {call}'); diff --git a/lib/Room.php b/lib/Room.php index 8328aa06b..7129391ca 100644 --- a/lib/Room.php +++ b/lib/Room.php @@ -313,7 +313,7 @@ class Room { } public function getName(): string { - if ($this->type === self::ONE_TO_ONE_CALL) { + if ($this->type === self::TYPE_ONE_TO_ONE) { if ($this->name === '') { // TODO use DI $participantService = \OC::$server->get(ParticipantService::class); @@ -670,7 +670,7 @@ class Room { } /** - * @param string $newName Currently it is only allowed to rename: self::GROUP_CALL, self::PUBLIC_CALL + * @param string $newName Currently it is only allowed to rename: self::TYPE_GROUP, self::TYPE_PUBLIC * @param string|null $oldName * @return bool True when the change was valid, false otherwise */ @@ -728,11 +728,11 @@ class Room { } /** - * @param string $password Currently it is only allowed to have a password for Room::PUBLIC_CALL + * @param string $password Currently it is only allowed to have a password for Room::TYPE_PUBLIC * @return bool True when the change was valid, false otherwise */ public function setPassword(string $password): bool { - if ($this->getType() !== self::PUBLIC_CALL) { + if ($this->getType() !== self::TYPE_PUBLIC) { return false; } @@ -776,7 +776,7 @@ class Room { * @return bool */ public function setActiveSince(\DateTime $since, int $callFlag, bool $isGuest): bool { - if ($isGuest && $this->getType() === self::PUBLIC_CALL) { + if ($isGuest && $this->getType() === self::TYPE_PUBLIC) { $query = $this->db->getQueryBuilder(); $query->update('talk_rooms') ->set('active_guests', $query->createFunction($query->getColumnName('active_guests') . ' + 1')) @@ -856,7 +856,7 @@ class Room { } /** - * @param int $newType Currently it is only allowed to change between `self::GROUP_CALL` and `self::PUBLIC_CALL` + * @param int $newType Currently it is only allowed to change between `self::TYPE_GROUP` and `self::TYPE_PUBLIC` * @return bool True when the change was valid, false otherwise */ public function setType(int $newType, bool $allowSwitchingOneToOne = false): bool { @@ -864,11 +864,11 @@ class Room { return true; } - if (!$allowSwitchingOneToOne && $this->getType() === self::ONE_TO_ONE_CALL) { + if (!$allowSwitchingOneToOne && $this->getType() === self::TYPE_ONE_TO_ONE) { return false; } - if (!in_array($newType, [self::GROUP_CALL, self::PUBLIC_CALL], true)) { + if (!in_array($newType, [self::TYPE_GROUP, self::TYPE_PUBLIC], true)) { return false; } @@ -885,7 +885,7 @@ class Room { $this->type = $newType; - if ($oldType === self::PUBLIC_CALL) { + if ($oldType === self::TYPE_PUBLIC) { // Kick all guests and users that were not invited $query = $this->db->getQueryBuilder(); $query->delete('talk_attendees') @@ -903,7 +903,7 @@ class Room { * @param int $newState Currently it is only allowed to change between * `self::READ_ONLY` and `self::READ_WRITE` * Also it's only allowed on rooms of type - * `self::GROUP_CALL` and `self::PUBLIC_CALL` + * `self::TYPE_GROUP` and `self::TYPE_PUBLIC` * @return bool True when the change was valid, false otherwise */ public function setReadOnly(int $newState): bool { @@ -912,7 +912,7 @@ class Room { return true; } - if (!in_array($this->getType(), [self::GROUP_CALL, self::PUBLIC_CALL, self::CHANGELOG_CONVERSATION], true)) { + if (!in_array($this->getType(), [self::TYPE_GROUP, self::TYPE_PUBLIC, self::TYPE_CHANGELOG], true)) { return false; } @@ -939,7 +939,7 @@ class Room { /** * @param int $newState New listable scope from self::LISTABLE_* * Also it's only allowed on rooms of type - * `self::GROUP_CALL` and `self::PUBLIC_CALL` + * `self::TYPE_GROUP` and `self::TYPE_PUBLIC` * @return bool True when the change was valid, false otherwise */ public function setListable(int $newState): bool { @@ -948,7 +948,7 @@ class Room { return true; } - if (!in_array($this->getType(), [self::GROUP_CALL, self::PUBLIC_CALL], true)) { + if (!in_array($this->getType(), [self::TYPE_GROUP, self::TYPE_PUBLIC], true)) { return false; } @@ -988,7 +988,7 @@ class Room { public function setLobby(int $newState, ?\DateTime $dateTime, bool $timerReached = false): bool { $oldState = $this->lobbyState; - if (!in_array($this->getType(), [self::GROUP_CALL, self::PUBLIC_CALL], true)) { + if (!in_array($this->getType(), [self::TYPE_GROUP, self::TYPE_PUBLIC], true)) { return false; } @@ -1024,7 +1024,7 @@ class Room { return false; } - if (!in_array($this->getType(), [self::GROUP_CALL, self::PUBLIC_CALL], true)) { + if (!in_array($this->getType(), [self::TYPE_GROUP, self::TYPE_PUBLIC], true)) { return false; } diff --git a/lib/Search/ConversationSearch.php b/lib/Search/ConversationSearch.php index 6687adbfe..bde25c053 100644 --- a/lib/Search/ConversationSearch.php +++ b/lib/Search/ConversationSearch.php @@ -87,7 +87,7 @@ class ConversationSearch implements IProvider { $result = []; foreach ($rooms as $room) { - if ($room->getType() === Room::CHANGELOG_CONVERSATION) { + if ($room->getType() === Room::TYPE_CHANGELOG) { continue; } @@ -100,7 +100,7 @@ class ConversationSearch implements IProvider { continue; } - if ($room->getType() === Room::ONE_TO_ONE_CALL) { + if ($room->getType() === Room::TYPE_ONE_TO_ONE) { $otherUserId = str_replace( json_encode($user->getUID()), '', @@ -119,7 +119,7 @@ class ConversationSearch implements IProvider { $icon = ''; $iconClass = ''; - if ($room->getType() === Room::ONE_TO_ONE_CALL) { + if ($room->getType() === Room::TYPE_ONE_TO_ONE) { $users = json_decode($room->getName(), true); foreach ($users as $participantId) { if ($participantId !== $user->getUID()) { @@ -135,7 +135,7 @@ class ConversationSearch implements IProvider { $iconClass = 'conversation-icon icon-password'; } elseif ($room->getObjectType() === 'emails') { $iconClass = 'conversation-icon icon-mail'; - } elseif ($room->getType() === Room::PUBLIC_CALL) { + } elseif ($room->getType() === Room::TYPE_PUBLIC) { $iconClass = 'conversation-icon icon-public'; } else { $iconClass = 'conversation-icon icon-contacts'; diff --git a/lib/Search/MessageSearch.php b/lib/Search/MessageSearch.php index 384b83874..04fc4b8d2 100644 --- a/lib/Search/MessageSearch.php +++ b/lib/Search/MessageSearch.php @@ -117,7 +117,7 @@ class MessageSearch implements IProvider { $roomMap = []; foreach ($rooms as $room) { - if ($room->getType() === Room::CHANGELOG_CONVERSATION) { + if ($room->getType() === Room::TYPE_CHANGELOG) { continue; } @@ -202,7 +202,7 @@ class MessageSearch implements IProvider { } $subline = $this->getSublineTemplate(); - if ($room->getType() === Room::ONE_TO_ONE_CALL) { + if ($room->getType() === Room::TYPE_ONE_TO_ONE) { $subline = '{user}'; } diff --git a/lib/Service/ParticipantService.php b/lib/Service/ParticipantService.php index 8eb594270..1b007c21e 100644 --- a/lib/Service/ParticipantService.php +++ b/lib/Service/ParticipantService.php @@ -249,7 +249,7 @@ class ParticipantService { $manager = \OC::$server->get(\OCA\Talk\Manager::class); // User joining a group or public call through listing - if (($room->getType() === Room::GROUP_CALL || $room->getType() === Room::PUBLIC_CALL) && + if (($room->getType() === Room::TYPE_GROUP || $room->getType() === Room::TYPE_PUBLIC) && $manager->isRoomListableByUser($room, $user->getUID()) ) { $this->addUsers($room, [[ @@ -259,7 +259,7 @@ class ParticipantService { // need to use "USER" here, because "USER_SELF_JOINED" only works for public calls 'participantType' => Participant::USER, ]], $user); - } elseif ($room->getType() === Room::PUBLIC_CALL) { + } elseif ($room->getType() === Room::TYPE_PUBLIC) { // User joining a public room, without being invited $this->addUsers($room, [[ 'actorType' => Attendee::ACTOR_USERS, @@ -638,7 +638,7 @@ class ParticipantService { } public function ensureOneToOneRoomIsFilled(Room $room): void { - if ($room->getType() !== Room::ONE_TO_ONE_CALL) { + if ($room->getType() !== Room::TYPE_ONE_TO_ONE) { return; } diff --git a/lib/Service/RoomService.php b/lib/Service/RoomService.php index 9164f48b2..f54544b18 100644 --- a/lib/Service/RoomService.php +++ b/lib/Service/RoomService.php @@ -68,7 +68,7 @@ class RoomService { } catch (RoomNotFoundException $e) { $users = [$actor->getUID(), $targetUser->getUID()]; sort($users); - $room = $this->manager->createRoom(Room::ONE_TO_ONE_CALL, json_encode($users)); + $room = $this->manager->createRoom(Room::TYPE_ONE_TO_ONE, json_encode($users)); $this->participantService->addUsers($room, [ [ @@ -107,9 +107,9 @@ class RoomService { } if (!\in_array($type, [ - Room::GROUP_CALL, - Room::PUBLIC_CALL, - Room::CHANGELOG_CONVERSATION, + Room::TYPE_GROUP, + Room::TYPE_PUBLIC, + Room::TYPE_CHANGELOG, ], true)) { throw new InvalidArgumentException('type'); } diff --git a/lib/Share/Helper/ShareAPIController.php b/lib/Share/Helper/ShareAPIController.php index aefccb229..29faae6db 100644 --- a/lib/Share/Helper/ShareAPIController.php +++ b/lib/Share/Helper/ShareAPIController.php @@ -93,7 +93,7 @@ class ShareAPIController { // so the avatars for conversations are distinguishable $result['share_with'] = 'private_conversation_' . substr(sha1($room->getName() . $room->getId()), 0, 6); } - if ($room->getType() === Room::PUBLIC_CALL) { + if ($room->getType() === Room::TYPE_PUBLIC) { $result['token'] = $share->getToken(); } $result['share_with_link'] = $this->urlGenerator->linkToRouteAbsolute('spreed.Page.showCall', ['token' => $room->getToken()]); diff --git a/lib/Share/RoomShareProvider.php b/lib/Share/RoomShareProvider.php index 0f0ec6f9d..66d1c3d80 100644 --- a/lib/Share/RoomShareProvider.php +++ b/lib/Share/RoomShareProvider.php @@ -894,7 +894,7 @@ class RoomShareProvider implements IShareProvider { throw new ShareNotFound(); } - if ($room->getType() !== Room::PUBLIC_CALL) { + if ($room->getType() !== Room::TYPE_PUBLIC) { throw new ShareNotFound(); } diff --git a/tests/php/Activity/Provider/BaseTest.php b/tests/php/Activity/Provider/BaseTest.php index f958c2045..7a598279a 100644 --- a/tests/php/Activity/Provider/BaseTest.php +++ b/tests/php/Activity/Provider/BaseTest.php @@ -204,12 +204,12 @@ class BaseTest extends TestCase { public function dataGetRoom() { return [ - [Room::ONE_TO_ONE_CALL, 23, 'private-call', 'private-call', 'one2one'], - [Room::GROUP_CALL, 42, 'group-call', 'group-call', 'group'], - [Room::PUBLIC_CALL, 128, 'public-call', 'public-call', 'public'], - [Room::ONE_TO_ONE_CALL, 23, '', 'a conversation', 'one2one'], - [Room::GROUP_CALL, 42, '', 'a conversation', 'group'], - [Room::PUBLIC_CALL, 128, '', 'a conversation', 'public'], + [Room::TYPE_ONE_TO_ONE, 23, 'private-call', 'private-call', 'one2one'], + [Room::TYPE_GROUP, 42, 'group-call', 'group-call', 'group'], + [Room::TYPE_PUBLIC, 128, 'public-call', 'public-call', 'public'], + [Room::TYPE_ONE_TO_ONE, 23, '', 'a conversation', 'one2one'], + [Room::TYPE_GROUP, 42, '', 'a conversation', 'group'], + [Room::TYPE_PUBLIC, 128, '', 'a conversation', 'public'], ]; } diff --git a/tests/php/Chat/Parser/UserMentionTest.php b/tests/php/Chat/Parser/UserMentionTest.php index c59934901..497d933bb 100644 --- a/tests/php/Chat/Parser/UserMentionTest.php +++ b/tests/php/Chat/Parser/UserMentionTest.php @@ -402,7 +402,7 @@ class UserMentionTest extends \Test\TestCase { $room = $this->createMock(Room::class); $room->expects($this->once()) ->method('getType') - ->willReturn(Room::GROUP_CALL); + ->willReturn(Room::TYPE_GROUP); $room->expects($this->once()) ->method('getToken') ->willReturn('token'); diff --git a/tests/php/Chat/SystemMessage/ListenerTest.php b/tests/php/Chat/SystemMessage/ListenerTest.php index 60b8d946a..8a11d896a 100644 --- a/tests/php/Chat/SystemMessage/ListenerTest.php +++ b/tests/php/Chat/SystemMessage/ListenerTest.php @@ -134,7 +134,7 @@ class ListenerTest extends TestCase { $room = $this->createMock(Room::class); $room->expects($this->any()) ->method('getType') - ->willReturn(Room::ONE_TO_ONE_CALL); + ->willReturn(Room::TYPE_ONE_TO_ONE); $participants = [[ 'actorType' => 'users', @@ -194,11 +194,11 @@ class ListenerTest extends TestCase { ]; return [ - [Room::GROUP_CALL, '', $allParticipants, $expectedMessages], - [Room::PUBLIC_CALL, '', $allParticipants, $expectedMessages], - [Room::ONE_TO_ONE_CALL, '', $allParticipants, []], - [Room::GROUP_CALL, 'file', $allParticipants, $expectedMessages], - [Room::PUBLIC_CALL, 'file', $allParticipants, $expectedMessages], + [Room::TYPE_GROUP, '', $allParticipants, $expectedMessages], + [Room::TYPE_PUBLIC, '', $allParticipants, $expectedMessages], + [Room::TYPE_ONE_TO_ONE, '', $allParticipants, []], + [Room::TYPE_GROUP, 'file', $allParticipants, $expectedMessages], + [Room::TYPE_PUBLIC, 'file', $allParticipants, $expectedMessages], ]; } @@ -290,7 +290,7 @@ class ListenerTest extends TestCase { $this->mockLoggedInUser('alice_actor'); $room = $this->createMock(Room::class); - $room->method('getType')->willReturn(Room::GROUP_CALL); + $room->method('getType')->willReturn(Room::TYPE_GROUP); $attendee = new Attendee(); $attendee->setActorId('bob_participant'); diff --git a/tests/php/Collaboration/Collaborators/RoomPluginTest.php b/tests/php/Collaboration/Collaborators/RoomPluginTest.php index 31f785332..cc5a868e0 100644 --- a/tests/php/Collaboration/Collaborators/RoomPluginTest.php +++ b/tests/php/Collaboration/Collaborators/RoomPluginTest.php @@ -105,34 +105,34 @@ class RoomPluginTest extends \Test\TestCase { // Empty search term with rooms ['', 2, 0, [ - $this->newRoom(Room::GROUP_CALL, 'roomToken', 'Room name') + $this->newRoom(Room::TYPE_GROUP, 'roomToken', 'Room name') ], [], [], false], // Search term with no matches ['Unmatched search term', 2, 0, [ - $this->newRoom(Room::GROUP_CALL, 'roomToken', 'Unmatched name') + $this->newRoom(Room::TYPE_GROUP, 'roomToken', 'Unmatched name') ], [], [], false], // Search term with single wide match ['room', 2, 0, [ - $this->newRoom(Room::GROUP_CALL, 'roomToken', 'Room name'), - $this->newRoom(Room::GROUP_CALL, 'roomToken2', 'Unmatched name') + $this->newRoom(Room::TYPE_GROUP, 'roomToken', 'Room name'), + $this->newRoom(Room::TYPE_GROUP, 'roomToken2', 'Unmatched name') ], [], [ $this->newResult('Room name', 'roomToken') ], false], // Search term with single exact match ['room name', 2, 0, [ - $this->newRoom(Room::GROUP_CALL, 'roomToken', 'Unmatched name'), - $this->newRoom(Room::GROUP_CALL, 'roomToken2', 'Room name') + $this->newRoom(Room::TYPE_GROUP, 'roomToken', 'Unmatched name'), + $this->newRoom(Room::TYPE_GROUP, 'roomToken2', 'Room name') ], [ $this->newResult('Room name', 'roomToken2') ], [], false], // Search term with single exact match and single wide match ['room name', 2, 0, [ - $this->newRoom(Room::GROUP_CALL, 'roomToken', 'Room name that also matches'), - $this->newRoom(Room::GROUP_CALL, 'roomToken2', 'Room name') + $this->newRoom(Room::TYPE_GROUP, 'roomToken', 'Room name that also matches'), + $this->newRoom(Room::TYPE_GROUP, 'roomToken2', 'Room name') ], [ $this->newResult('Room name', 'roomToken2') ], [ @@ -143,8 +143,8 @@ class RoomPluginTest extends \Test\TestCase { // as one-to-one rooms do not have a name, but it would be if they // had, so it is included here for completeness). ['room name', 2, 0, [ - $this->newRoom(Room::ONE_TO_ONE_CALL, 'roomToken', 'Room name that also matches'), - $this->newRoom(Room::ONE_TO_ONE_CALL, 'roomToken2', 'Room name') + $this->newRoom(Room::TYPE_ONE_TO_ONE, 'roomToken', 'Room name that also matches'), + $this->newRoom(Room::TYPE_ONE_TO_ONE, 'roomToken2', 'Room name') ], [ $this->newResult('Room name', 'roomToken2') ], [ @@ -153,8 +153,8 @@ class RoomPluginTest extends \Test\TestCase { // Search term matching public rooms ['room name', 2, 0, [ - $this->newRoom(Room::PUBLIC_CALL, 'roomToken', 'Room name that also matches'), - $this->newRoom(Room::PUBLIC_CALL, 'roomToken2', 'Room name') + $this->newRoom(Room::TYPE_PUBLIC, 'roomToken', 'Room name that also matches'), + $this->newRoom(Room::TYPE_PUBLIC, 'roomToken2', 'Room name') ], [ $this->newResult('Room name', 'roomToken2') ], [ @@ -163,10 +163,10 @@ class RoomPluginTest extends \Test\TestCase { // Search term with several wide matches ['room', 2, 0, [ - $this->newRoom(Room::GROUP_CALL, 'roomToken', 'Room name'), - $this->newRoom(Room::GROUP_CALL, 'roomToken2', 'Another room name'), - $this->newRoom(Room::GROUP_CALL, 'roomToken3', 'Room name'), - $this->newRoom(Room::GROUP_CALL, 'roomToken4', 'Another room name') + $this->newRoom(Room::TYPE_GROUP, 'roomToken', 'Room name'), + $this->newRoom(Room::TYPE_GROUP, 'roomToken2', 'Another room name'), + $this->newRoom(Room::TYPE_GROUP, 'roomToken3', 'Room name'), + $this->newRoom(Room::TYPE_GROUP, 'roomToken4', 'Another room name') ], [], [ $this->newResult('Room name', 'roomToken'), $this->newResult('Another room name', 'roomToken2'), @@ -176,10 +176,10 @@ class RoomPluginTest extends \Test\TestCase { // Search term with several exact matches ['room name', 2, 0, [ - $this->newRoom(Room::GROUP_CALL, 'roomToken', 'Room name'), - $this->newRoom(Room::GROUP_CALL, 'roomToken2', 'Room name'), - $this->newRoom(Room::GROUP_CALL, 'roomToken3', 'Room name'), - $this->newRoom(Room::GROUP_CALL, 'roomToken4', 'Room name') + $this->newRoom(Room::TYPE_GROUP, 'roomToken', 'Room name'), + $this->newRoom(Room::TYPE_GROUP, 'roomToken2', 'Room name'), + $this->newRoom(Room::TYPE_GROUP, 'roomToken3', 'Room name'), + $this->newRoom(Room::TYPE_GROUP, 'roomToken4', 'Room name') ], [ $this->newResult('Room name', 'roomToken'), $this->newResult('Room name', 'roomToken2'), @@ -189,17 +189,17 @@ class RoomPluginTest extends \Test\TestCase { // Search term with several matches ['room name', 2, 0, [ - $this->newRoom(Room::GROUP_CALL, 'roomToken', 'Room name'), - $this->newRoom(Room::GROUP_CALL, 'roomToken2', 'Unmatched name'), - $this->newRoom(Room::GROUP_CALL, 'roomToken3', 'Another room name'), - $this->newRoom(Room::GROUP_CALL, 'roomToken4', 'Room name'), - $this->newRoom(Room::ONE_TO_ONE_CALL, 'roomToken5', 'Room name'), - $this->newRoom(Room::PUBLIC_CALL, 'roomToken6', 'Room name'), - $this->newRoom(Room::GROUP_CALL, 'roomToken7', 'Another unmatched name'), - $this->newRoom(Room::ONE_TO_ONE_CALL, 'roomToken8', 'Another unmatched name'), - $this->newRoom(Room::PUBLIC_CALL, 'roomToken9', 'Another unmatched name'), - $this->newRoom(Room::ONE_TO_ONE_CALL, 'roomToken10', 'Another room name'), - $this->newRoom(Room::PUBLIC_CALL, 'roomToken11', 'Another room name') + $this->newRoom(Room::TYPE_GROUP, 'roomToken', 'Room name'), + $this->newRoom(Room::TYPE_GROUP, 'roomToken2', 'Unmatched name'), + $this->newRoom(Room::TYPE_GROUP, 'roomToken3', 'Another room name'), + $this->newRoom(Room::TYPE_GROUP, 'roomToken4', 'Room name'), + $this->newRoom(Room::TYPE_ONE_TO_ONE, 'roomToken5', 'Room name'), + $this->newRoom(Room::TYPE_PUBLIC, 'roomToken6', 'Room name'), + $this->newRoom(Room::TYPE_GROUP, 'roomToken7', 'Another unmatched name'), + $this->newRoom(Room::TYPE_ONE_TO_ONE, 'roomToken8', 'Another unmatched name'), + $this->newRoom(Room::TYPE_PUBLIC, 'roomToken9', 'Another unmatched name'), + $this->newRoom(Room::TYPE_ONE_TO_ONE, 'roomToken10', 'Another room name'), + $this->newRoom(Room::TYPE_PUBLIC, 'roomToken11', 'Another room name') ], [ $this->newResult('Room name', 'roomToken'), $this->newResult('Room name', 'roomToken4'), diff --git a/tests/php/Controller/SignalingControllerTest.php b/tests/php/Controller/SignalingControllerTest.php index 7e79d7c0a..12276cbf3 100644 --- a/tests/php/Controller/SignalingControllerTest.php +++ b/tests/php/Controller/SignalingControllerTest.php @@ -412,7 +412,7 @@ class SignalingControllerTest extends \Test\TestCase { ->with($this->userId) ->willReturn([ 'name' => $roomName, - 'type' => Room::ONE_TO_ONE_CALL, + 'type' => Room::TYPE_ONE_TO_ONE, ]); $result = $this->performBackendRequest([ @@ -430,7 +430,7 @@ class SignalingControllerTest extends \Test\TestCase { 'roomid' => $roomToken, 'properties' => [ 'name' => $roomName, - 'type' => Room::ONE_TO_ONE_CALL, + 'type' => Room::TYPE_ONE_TO_ONE, ], 'permissions' => [ 'publish-audio', @@ -472,7 +472,7 @@ class SignalingControllerTest extends \Test\TestCase { ->with($this->userId) ->willReturn([ 'name' => $roomName, - 'type' => Room::PUBLIC_CALL, + 'type' => Room::TYPE_PUBLIC, ]); $result = $this->performBackendRequest([ @@ -490,7 +490,7 @@ class SignalingControllerTest extends \Test\TestCase { 'roomid' => $roomToken, 'properties' => [ 'name' => $roomName, - 'type' => Room::PUBLIC_CALL, + 'type' => Room::TYPE_PUBLIC, ], 'permissions' => [ 'publish-audio', @@ -536,7 +536,7 @@ class SignalingControllerTest extends \Test\TestCase { ->with($this->userId) ->willReturn([ 'name' => $roomName, - 'type' => Room::PUBLIC_CALL, + 'type' => Room::TYPE_PUBLIC, ]); $result = $this->performBackendRequest([ @@ -554,7 +554,7 @@ class SignalingControllerTest extends \Test\TestCase { 'roomid' => $roomToken, 'properties' => [ 'name' => $roomName, - 'type' => Room::PUBLIC_CALL, + 'type' => Room::TYPE_PUBLIC, ], 'permissions' => [ 'publish-audio', @@ -598,7 +598,7 @@ class SignalingControllerTest extends \Test\TestCase { ->with('') ->willReturn([ 'name' => $roomName, - 'type' => Room::PUBLIC_CALL, + 'type' => Room::TYPE_PUBLIC, ]); $result = $this->performBackendRequest([ @@ -616,7 +616,7 @@ class SignalingControllerTest extends \Test\TestCase { 'roomid' => $roomToken, 'properties' => [ 'name' => $roomName, - 'type' => Room::PUBLIC_CALL, + 'type' => Room::TYPE_PUBLIC, ], 'permissions' => [ 'publish-audio', @@ -659,7 +659,7 @@ class SignalingControllerTest extends \Test\TestCase { ->with($this->userId) ->willReturn([ 'name' => $roomName, - 'type' => Room::PUBLIC_CALL, + 'type' => Room::TYPE_PUBLIC, ]); $result = $this->performBackendRequest([ @@ -677,7 +677,7 @@ class SignalingControllerTest extends \Test\TestCase { 'roomid' => $roomToken, 'properties' => [ 'name' => $roomName, - 'type' => Room::PUBLIC_CALL, + 'type' => Room::TYPE_PUBLIC, ], 'permissions' => [ 'publish-audio', @@ -738,7 +738,7 @@ class SignalingControllerTest extends \Test\TestCase { ->with($this->userId) ->willReturn([ 'name' => $roomName, - 'type' => Room::PUBLIC_CALL, + 'type' => Room::TYPE_PUBLIC, ]); $result = $this->performBackendRequest([ @@ -756,7 +756,7 @@ class SignalingControllerTest extends \Test\TestCase { 'roomid' => $roomToken, 'properties' => [ 'name' => $roomName, - 'type' => Room::PUBLIC_CALL, + 'type' => Room::TYPE_PUBLIC, ], 'permissions' => $expectedBackendPermissions, ], @@ -832,7 +832,7 @@ class SignalingControllerTest extends \Test\TestCase { ->with($this->userId) ->willReturn([ 'name' => $roomName, - 'type' => Room::ONE_TO_ONE_CALL, + 'type' => Room::TYPE_ONE_TO_ONE, ]); $result = $this->performBackendRequest([ @@ -850,7 +850,7 @@ class SignalingControllerTest extends \Test\TestCase { 'roomid' => $roomToken, 'properties' => [ 'name' => $roomName, - 'type' => Room::ONE_TO_ONE_CALL, + 'type' => Room::TYPE_ONE_TO_ONE, ], 'permissions' => [ 'publish-audio', @@ -1055,7 +1055,7 @@ class SignalingControllerTest extends \Test\TestCase { ->method('getUID') ->willReturn($this->userId); - $room = $this->manager->createRoom(Room::PUBLIC_CALL); + $room = $this->manager->createRoom(Room::TYPE_PUBLIC); // The user joined the room. $oldParticipant = $participantService->joinRoom($room, $testUser, ''); diff --git a/tests/php/Notification/NotifierTest.php b/tests/php/Notification/NotifierTest.php index 678b61518..042a02472 100644 --- a/tests/php/Notification/NotifierTest.php +++ b/tests/php/Notification/NotifierTest.php @@ -139,7 +139,7 @@ class NotifierTest extends \Test\TestCase { $room = $this->createMock(Room::class); $room->expects($this->any()) ->method('getType') - ->willReturn(Room::ONE_TO_ONE_CALL); + ->willReturn(Room::TYPE_ONE_TO_ONE); $room->expects($this->any()) ->method('getId') ->willReturn(1234); @@ -241,7 +241,7 @@ class NotifierTest extends \Test\TestCase { $room = $this->createMock(Room::class); $room->expects($this->any()) ->method('getType') - ->willReturn(Room::ONE_TO_ONE_CALL); + ->willReturn(Room::TYPE_ONE_TO_ONE); $room->expects($this->any()) ->method('getId') ->willReturn(1234); @@ -342,8 +342,8 @@ class NotifierTest extends \Test\TestCase { public function dataPrepareGroup() { return [ - [Room::GROUP_CALL, 'admin', 'Admin', 'Group', 'Admin invited you to a group conversation: Group'], - [Room::PUBLIC_CALL, 'test', 'Test user', 'Public', 'Test user invited you to a group conversation: Public'], + [Room::TYPE_GROUP, 'admin', 'Admin', 'Group', 'Admin invited you to a group conversation: Group'], + [Room::TYPE_PUBLIC, 'test', 'Test user', 'Public', 'Test user invited you to a group conversation: Public'], ]; } @@ -415,7 +415,7 @@ class NotifierTest extends \Test\TestCase { ->method('getId') ->willReturn($roomId); - if ($type === Room::GROUP_CALL) { + if ($type === Room::TYPE_GROUP) { $n->expects($this->once()) ->method('setRichSubject') ->with('{user} invited yo