diff options
author | Vitor Mattos <vitor@php.rio> | 2022-06-13 12:53:38 -0300 |
---|---|---|
committer | Vitor Mattos <vitor@php.rio> | 2022-06-30 15:01:31 -0300 |
commit | bd9913e1ea72be757e34b5719be0ceace6427544 (patch) | |
tree | 18c1276534feb5912725b6959baf87fd50676663 | |
parent | 1f808ebe56c676d16c81233237bb86332fef98c2 (diff) |
Rename message expire to expire date
Signed-off-by: Vitor Mattos <vitor@php.rio>
-rw-r--r-- | appinfo/routes/routesRoomController.php | 4 | ||||
-rw-r--r-- | docs/capabilities.md | 1 | ||||
-rw-r--r-- | docs/conversation.md | 4 | ||||
-rw-r--r-- | lib/BackgroundJob/ApplyExpireDate.php (renamed from lib/BackgroundJob/ApplyMessageExpire.php) | 6 | ||||
-rw-r--r-- | lib/Chat/ChatManager.php | 8 | ||||
-rw-r--r-- | lib/Controller/RoomController.php | 8 | ||||
-rw-r--r-- | lib/Events/ChangeExpireDateEvent.php (renamed from lib/Events/ChangeMessageExpireEvent.php) | 6 | ||||
-rw-r--r-- | lib/Room.php | 18 | ||||
-rw-r--r-- | lib/Service/RoomService.php | 28 | ||||
-rw-r--r-- | tests/integration/features/bootstrap/FeatureContext.php | 18 | ||||
-rw-r--r-- | tests/integration/features/chat/expire_date.feature (renamed from tests/integration/features/chat/message_expire.feature) | 16 | ||||
-rw-r--r-- | tests/integration/spreedcheats/appinfo/routes.php | 2 | ||||
-rw-r--r-- | tests/integration/spreedcheats/lib/Controller/ApiController.php | 6 |
13 files changed, 67 insertions, 58 deletions
diff --git a/appinfo/routes/routesRoomController.php b/appinfo/routes/routesRoomController.php index 353c232bd..ce36e1cd1 100644 --- a/appinfo/routes/routesRoomController.php +++ b/appinfo/routes/routesRoomController.php @@ -102,7 +102,7 @@ return [ ['name' => 'Room#setLobby', 'url' => '/api/{apiVersion}/room/{token}/webinar/lobby', 'verb' => 'PUT', 'requirements' => $requirementsWithToken], /** @see \OCA\Talk\Controller\RoomController::setSIPEnabled() */ ['name' => 'Room#setSIPEnabled', 'url' => '/api/{apiVersion}/room/{token}/webinar/sip', 'verb' => 'PUT', 'requirements' => $requirementsWithToken], - /** @see \OCA\Talk\Controller\RoomController::setMessageExpire() */ - ['name' => 'Room#setMessageExpire', 'url' => '/api/{apiVersion}/room/{token}/message-expire', 'verb' => 'POST', 'requirements' => $requirements], + /** @see \OCA\Talk\Controller\RoomController::setExpireInterval() */ + ['name' => 'Room#setExpireInterval', 'url' => '/api/{apiVersion}/room/{token}/message-expire-interval', 'verb' => 'POST', 'requirements' => $requirements], ], ]; diff --git a/docs/capabilities.md b/docs/capabilities.md index a21e7f5c7..50f7536c5 100644 --- a/docs/capabilities.md +++ b/docs/capabilities.md @@ -103,4 +103,3 @@ title: Capabilities * `silent-call` - Allow to start calls without sending notification * `config => call => enabled` - Whether calling is enabled on the instance or not * `config => signaling => session-ping-limit` - Number of sessions the HPB is allowed to ping in the same request -* `time-to-live` - Time to live of messages for a conversation diff --git a/docs/conversation.md b/docs/conversation.md index 600fe4525..5afb8df5e 100644 --- a/docs/conversation.md +++ b/docs/conversation.md @@ -51,7 +51,7 @@ `participantFlags` | int | v1 | | "In call" flags of the user's session making the request (only available with `in-call-flags` capability) `readOnly` | int | v1 | | Read-only state for the current user (only available with `read-only-rooms` capability) `listable` | int | v3 | | Listable scope for the room (only available with `listable-rooms` capability) - `messageExpire` | int | v4 | | The message expire time in seconds in this chat. Zero if disabled. (only available with `message-expire` capability) + `expireDate` | int | v4 | | The expire date time in seconds in this chat. Zero if disabled. (only available with `message-expire` capability) `count` | int | v1 | v2 | **Removed:** Count the users on the [Get list of participants in a conversation](participant.md#get-list-of-participants-in-a-conversation) endpoint `numGuests` | int | v1 | v2 | **Removed:** Count the guests on the [Get list of participants in a conversation](participant.md#get-list-of-participants-in-a-conversation) endpoin `lastPing` | int | v1 | | Timestamp of the user's session making the request @@ -337,7 +337,7 @@ + `401 Unauthorized` When the participant is a guest + `404 Not Found` When the conversation could not be found for the participant -## Set message expire for messages in a conversation +## Set expire date for messages in a conversation * Required capability: `message-expire` * Method: `POST` diff --git a/lib/BackgroundJob/ApplyMessageExpire.php b/lib/BackgroundJob/ApplyExpireDate.php index 826512130..c24399965 100644 --- a/lib/BackgroundJob/ApplyMessageExpire.php +++ b/lib/BackgroundJob/ApplyExpireDate.php @@ -2,9 +2,9 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2020 Morris Jobke <hey@morrisjobke.de> + * @copyright Copyright (c) 2020 Vitor Mattos <vitor@php.rio> * - * @author Morris Jobke <hey@morrisjobke.de> + * @author Vitor Mattos <vitor@php.rio> * * @license GNU AGPL version 3 or any later version * @@ -30,7 +30,7 @@ use OCP\AppFramework\Utility\ITimeFactory; use OCP\BackgroundJob\IJob; use OCP\BackgroundJob\TimedJob; -class ApplyMessageExpire extends TimedJob { +class ApplyExpireDate extends TimedJob { private ChatManager $chatManager; public function __construct(ITimeFactory $timeFactory, diff --git a/lib/Chat/ChatManager.php b/lib/Chat/ChatManager.php index c69ef4ae8..826f0e7fa 100644 --- a/lib/Chat/ChatManager.php +++ b/lib/Chat/ChatManager.php @@ -263,7 +263,7 @@ class ChatManager { if ($referenceId !== '') { $comment->setReferenceId($referenceId); } - $this->setMessageExpire($chat, $comment); + $this->setExpireDate($chat, $comment); $event = new ChatParticipantEvent($chat, $comment, $participant, $silent); $this->dispatcher->dispatch(self::EVENT_BEFORE_MESSAGE_SEND, $event); @@ -309,15 +309,15 @@ class ChatManager { return $comment; } - private function setMessageExpire(Room $room, IComment $comment): void { - $expireInterval = $room->getMessageExpire(); + private function setExpireDate(Room $room, IComment $comment): void { + $expireInterval = $room->getExpireInterval(); if (!$expireInterval) { return; } $dateTime = $this->timeFactory->getDateTime(); $dateTime->add(DateInterval::createFromDateString($expireInterval . ' seconds')); - $comment->setMessageExpire($dateTime); + $comment->setExpireDate($dateTime); } /** diff --git a/lib/Controller/RoomController.php b/lib/Controller/RoomController.php index 5e23de42a..ad7cbfe30 100644 --- a/lib/Controller/RoomController.php +++ b/lib/Controller/RoomController.php @@ -400,7 +400,7 @@ class RoomController extends AEnvironmentAwareController { 'lastCommonReadMessage' => 0, 'listable' => Room::LISTABLE_NONE, 'callFlag' => Participant::FLAG_DISCONNECTED, - 'messageExpire' => 0, + 'expireDate' => 0, ]; $lastActivity = $room->getLastActivity(); @@ -467,7 +467,7 @@ class RoomController extends AEnvironmentAwareController { 'defaultPermissions' => $room->getDefaultPermissions(), 'description' => $room->getDescription(), 'listable' => $room->getListable(), - 'messageExpire' => $this->roomService->getMessageExpire($room), + 'expireInterval' => $this->roomService->getExpireInterval($room), ]); if ($currentParticipant->getAttendee()->getReadPrivacy() === Participant::PRIVACY_PUBLIC) { @@ -1713,11 +1713,11 @@ class RoomController extends AEnvironmentAwareController { * @PublicPage * @RequireModeratorParticipant */ - public function setMessageExpire(int $seconds): DataResponse { + public function setExpireInterval(int $seconds): DataResponse { if ($seconds < 0) { return new DataResponse([], Http::STATUS_BAD_REQUEST); } - $this->roomService->setMessageExpire($this->room, $this->getParticipant(), $seconds); + $this->roomService->setExpireInterval($this->room, $this->getParticipant(), $seconds); return new DataResponse(); } } diff --git a/lib/Events/ChangeMessageExpireEvent.php b/lib/Events/ChangeExpireDateEvent.php index 2085337f8..918c7bb60 100644 --- a/lib/Events/ChangeMessageExpireEvent.php +++ b/lib/Events/ChangeExpireDateEvent.php @@ -4,6 +4,8 @@ declare(strict_types=1); /** * @copyright Copyright (c) 2022 Vitor Mattos <vitor@php.rio> * + * @author 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 @@ -25,7 +27,7 @@ namespace OCA\Talk\Events; use OCA\Talk\Room; -class ChangeMessageExpireEvent extends RoomEvent { +class ChangeExpireDateEvent extends RoomEvent { private int $seconds; public function __construct(Room $room, int $seconds @@ -34,7 +36,7 @@ class ChangeMessageExpireEvent extends RoomEvent { $this->seconds = $seconds; } - public function getMessageExpireSeconds(): int { + public function getExpireDateSeconds(): int { return $this->seconds; } } diff --git a/lib/Room.php b/lib/Room.php index ec68b7ad1..14b71edc4 100644 --- a/lib/Room.php +++ b/lib/Room.php @@ -147,8 +147,8 @@ class Room { public const EVENT_BEFORE_SESSION_LEAVE_CALL = self::class . '::preSessionLeaveCall'; public const EVENT_AFTER_SESSION_LEAVE_CALL = self::class . '::postSessionLeaveCall'; public const EVENT_BEFORE_SIGNALING_PROPERTIES = self::class . '::beforeSignalingProperties'; - public const EVENT_BEFORE_SET_MESSAGE_EXPIRE = self::class . '::beforeSetMessageExpire'; - public const EVENT_AFTER_SET_MESSAGE_EXPIRE = self::class . '::afterSetMessageExpire'; + public const EVENT_BEFORE_SET_EXPIRE_DATE = self::class . '::beforeSetExpireInterval'; + public const EVENT_AFTER_SET_EXPIRE_DATE = self::class . '::afterSetExpireInterval'; public const DESCRIPTION_MAXIMUM_LENGTH = 500; @@ -162,7 +162,7 @@ class Room { private int $type; private int $readOnly; private int $listable; - private int $messageExpire; + private int $expireInterval; private int $lobbyState; private int $sipEnabled; private ?int $assignedSignalingServer; @@ -196,7 +196,7 @@ class Room { int $type, int $readOnly, int $listable, - int $messageExpire, + int $expireInterval, int $lobbyState, int $sipEnabled, ?int $assignedSignalingServer, @@ -226,7 +226,7 @@ class Room { $this->type = $type; $this->readOnly = $readOnly; $this->listable = $listable; - $this->messageExpire = $messageExpire; + $this->expireInterval = $expireInterval; $this->lobbyState = $lobbyState; $this->sipEnabled = $sipEnabled; $this->assignedSignalingServer = $assignedSignalingServer; @@ -288,6 +288,14 @@ class Room { $this->listable = $newState; } + public function getExpireInterval(): int { + return $this->expireInterval; + } + + public function setExpireInterval(int $expireInterval): void { + $this->expireInterval = $expireInterval; + } + public function getLobbyState(): int { $this->validateTimer(); return $this->lobbyState; diff --git a/lib/Service/RoomService.php b/lib/Service/RoomService.php index de08931c9..4606ce15a 100644 --- a/lib/Service/RoomService.php +++ b/lib/Service/RoomService.php @@ -24,10 +24,10 @@ declare(strict_types=1); namespace OCA\Talk\Service; use InvalidArgumentException; -use OCA\Talk\BackgroundJob\ApplyMessageExpire; +use OCA\Talk\BackgroundJob\ApplyExpireDate; use OCA\Talk\Chat\ChatManager; use OCA\Talk\Chat\CommentsManager; -use OCA\Talk\Events\ChangeMessageExpireEvent; +use OCA\Talk\Events\ChangeExpireDateEvent; use OCA\Talk\Events\ModifyLobbyEvent; use OCA\Talk\Events\ModifyRoomEvent; use OCA\Talk\Events\VerifyRoomPasswordEvent; @@ -543,28 +543,28 @@ class RoomService { ]; } - public function setMessageExpire(Room $room, Participant $participant, int $seconds): void { - $event = new ChangeMessageExpireEvent($room, $seconds); - $this->dispatcher->dispatch(Room::EVENT_BEFORE_SET_MESSAGE_EXPIRE, $event); + public function setExpireInterval(Room $room, Participant $participant, int $seconds): void { + $event = new ChangeExpireDateEvent($room, $seconds); + $this->dispatcher->dispatch(Room::EVENT_BEFORE_SET_EXPIRE_DATE, $event); $update = $this->db->getQueryBuilder(); $update->update('talk_rooms') ->set('message_expire', $update->createNamedParameter($seconds, IQueryBuilder::PARAM_INT)) ->where($update->expr()->eq('id', $update->createNamedParameter($room->getId(), IQueryBuilder::PARAM_INT))); $update->executeStatement(); - $room->setMessageExpire($seconds); + $room->setExpireInterval($seconds); if ($seconds > 0) { - $this->jobList->add(ApplyMessageExpire::class, ['room_id' => $room->getId()]); - $this->messageExpireSystemMessage($room, $participant, $seconds, 'message_expire_enabled'); + $this->jobList->add(ApplyExpireDate::class, ['room_id' => $room->getId()]); + $this->expireDateSystemMessage($room, $participant, $seconds, 'message_expire_enabled'); } else { - $this->jobList->remove(ApplyMessageExpire::class, ['room_id' => $room->getId()]); - $this->messageExpireSystemMessage($room, $participant, $seconds, 'message_expire_disabled'); + $this->jobList->remove(ApplyExpireDate::class, ['room_id' => $room->getId()]); + $this->expireDateSystemMessage($room, $participant, $seconds, 'message_expire_disabled'); } - $this->dispatcher->dispatch(Room::EVENT_AFTER_SET_MESSAGE_EXPIRE, $event); + $this->dispatcher->dispatch(Room::EVENT_AFTER_SET_EXPIRE_DATE, $event); } - private function messageExpireSystemMessage(Room $room, Participant $participant, int $seconds, string $message): void { + private function expireDateSystemMessage(Room $room, Participant $participant, int $seconds, string $message): void { $this->chatManager->addSystemMessage( $room, $participant->getAttendee()->getActorType(), @@ -578,7 +578,7 @@ class RoomService { ); } - public function getMessageExpire(Room $room): int { - return $room->getMessageExpire(); + public function getExpireInterval(Room $room): int { + return $room->getExpireInterval(); } } diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php index 397a371f8..4c8f5ed3d 100644 --- a/tests/integration/features/bootstrap/FeatureContext.php +++ b/tests/integration/features/bootstrap/FeatureContext.php @@ -2568,25 +2568,25 @@ class FeatureContext implements Context, SnippetAcceptingContext { } /** - * @Given user :user set the message expire to :messageExpire of room :identifier with :statusCode (:apiVersion) + * @Given user :user set the expire interval to :expireInterval of room :identifier with :statusCode (:apiVersion) */ - public function userSetTheMessageExpireToWith(string $user, int $messageExpire, string $identifier, int $statusCode, string $apiVersion = 'v4'): void { + public function userSetTheExpireIntervalToWith(string $user, int $expireInterval, string $identifier, int $statusCode, string $apiVersion = 'v4'): void { $this->setCurrentUser($user); - $this->sendRequest('POST', '/apps/spreed/api/' . $apiVersion . '/room/' . self::$identifierToToken[$identifier] . '/message-expire', [ - 'seconds' => $messageExpire + $this->sendRequest('POST', '/apps/spreed/api/' . $apiVersion . '/room/' . self::$identifierToToken[$identifier] . '/message-expire-interval', [ + 'seconds' => $expireInterval ]); $this->assertStatusCode($this->response, $statusCode); } /** - * @Given user :user check if message expire of room :identifier is :messageExpire (:apiVersion) + * @Given user :user check if expire interval of room :identifier is :expireInterval (:apiVersion) */ - public function userCheckIfMessageExpireOfRoomIsX(string $user, string $identifier, int $messageExpire, string $apiVersion = 'v4') { + public function userCheckIfExpireIntervalOfRoomIsX(string $user, string $identifier, int $expireInterval, string $apiVersion = 'v4') { $this->setCurrentUser($user); $this->sendRequest('GET', '/apps/spreed/api/' . $apiVersion . '/room/' . self::$identifierToToken[$identifier]); $room = $this->getDataFromResponse($this->response); - Assert::assertEquals($messageExpire, $room['messageExpire']); + Assert::assertEquals($expireInterval, $room['expireInterval']); } /** @@ -2597,9 +2597,9 @@ class FeatureContext implements Context, SnippetAcceptingContext { } /** - * @When apply message expire job to room :identifier + * @When apply expire date job to room :identifier */ - public function applyMessageExpireJobToRoom($identifier): void { + public function applyExpireDateJobToRoom($identifier): void { $currentUser = $this->currentUser; $this->setCurrentUser('admin'); $this->sendRequest('GET', '/apps/spreedcheats/get_message_expire_job/' . self::$identifierToToken[$identifier]); diff --git a/tests/integration/features/chat/message_expire.feature b/tests/integration/features/chat/expire_date.feature index 4f94ee635..339ef448f 100644 --- a/tests/integration/features/chat/message_expire.feature +++ b/tests/integration/features/chat/expire_date.feature @@ -1,23 +1,23 @@ -Feature: room/message_expire +Feature: room/expire_date Background: Given user "participant1" exists Given user "participant2" exists Given user "participant3" exists - Scenario: Enable message expire and check after expire + Scenario: Enable expire date and check after expire Given user "participant1" creates room "room" (v4) | roomType | 3 | | roomName | room | And user "participant1" adds user "participant2" to room "room" with 200 (v4) And user "participant1" sends message "Message 1" to room "room" with 201 - And user "participant1" set the message expire to -1 of room "room" with 400 (v4) - And user "participant2" set the message expire to 3 of room "room" with 403 (v4) - And user "participant3" set the message expire to 3 of room "room" with 404 (v4) - And user "participant1" set the message expir |