diff options
author | Vitor Mattos <vitor@php.rio> | 2022-05-23 13:12:02 -0300 |
---|---|---|
committer | Vitor Mattos <vitor@php.rio> | 2022-06-30 15:01:26 -0300 |
commit | 751d18f2b110f4e1de4152fa213cdc6e77d5134f (patch) | |
tree | b30e014314b17a30e85eaf3033e1052ca59f0042 | |
parent | 26808039bd1f967cf6ce81b9be3c822dfd345d9b (diff) |
Rename ttl to message expire
Signed-off-by: Vitor Mattos <vitor@php.rio>
-rw-r--r-- | .drone.jsonnet | 6 | ||||
-rw-r--r-- | .drone.yml | 18 | ||||
-rw-r--r-- | appinfo/routes/routesRoomController.php | 4 | ||||
-rw-r--r-- | docs/conversation.md | 2 | ||||
-rw-r--r-- | lib/BackgroundJob/ApplyMessageExpire.php (renamed from lib/BackgroundJob/ApplyTtl.php) | 4 | ||||
-rw-r--r-- | lib/Controller/RoomController.php | 6 | ||||
-rw-r--r-- | lib/Events/ChangeMessageExpireEvent.php (renamed from lib/Events/ChangeTtlEvent.php) | 12 | ||||
-rw-r--r-- | lib/Manager.php | 2 | ||||
-rw-r--r-- | lib/Migration/Version15000Date20220506005058.php | 4 | ||||
-rw-r--r-- | lib/Model/SelectHelper.php | 2 | ||||
-rw-r--r-- | lib/Room.php | 4 | ||||
-rw-r--r-- | lib/Service/RoomService.php | 44 | ||||
-rw-r--r-- | tests/integration/features/bootstrap/FeatureContext.php | 20 | ||||
-rw-r--r-- | tests/integration/features/message_expiration/message_expiration.feature (renamed from tests/integration/features/ttl/ttl.feature) | 18 | ||||
-rw-r--r-- | tests/integration/spreedcheats/appinfo/routes.php | 2 | ||||
-rw-r--r-- | tests/integration/spreedcheats/lib/Controller/ApiController.php | 4 |
16 files changed, 76 insertions, 76 deletions
diff --git a/.drone.jsonnet b/.drone.jsonnet index d0104fe1b..16bfdbe30 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -123,7 +123,7 @@ local PipelinePostgreSQL(test_set) = Pipeline( PipelineSQLite("conversation-2"), PipelineSQLite("federation"), PipelineSQLite("reaction"), - PipelineSQLite("ttl"), + PipelineSQLite("message_expire"), PipelineSQLite("sharing"), PipelineSQLite("sharing-2"), @@ -134,7 +134,7 @@ local PipelinePostgreSQL(test_set) = Pipeline( PipelineMySQL("conversation-2"), PipelineMySQL("federation"), PipelineMySQL("reaction"), - PipelineMySQL("ttl"), + PipelineMySQL("message_expire"), PipelineMySQL("sharing"), PipelineMySQL("sharing-2"), @@ -145,7 +145,7 @@ local PipelinePostgreSQL(test_set) = Pipeline( PipelinePostgreSQL("conversation-2"), PipelinePostgreSQL("federation"), PipelinePostgreSQL("reaction"), - PipelinePostgreSQL("ttl"), + PipelinePostgreSQL("message_expire"), PipelinePostgreSQL("sharing"), PipelinePostgreSQL("sharing-2"), ] diff --git a/.drone.yml b/.drone.yml index 3634dfbcf..874cf6411 100644 --- a/.drone.yml +++ b/.drone.yml @@ -233,7 +233,7 @@ trigger: - push --- kind: pipeline -name: int-sqlite-ttl +name: int-sqlite-message_expire services: - image: ghcr.io/nextcloud/continuous-integration-redis:latest name: cache @@ -249,7 +249,7 @@ steps: - ./occ app:enable notifications - cd apps/$APP_NAME - cd tests/integration/ - - bash run.sh features/ttl + - bash run.sh features/message_expire environment: APP_NAME: spreed CORE_BRANCH: master @@ -257,7 +257,7 @@ steps: GUESTS_BRANCH: master NOTIFICATIONS_BRANCH: master image: ghcr.io/nextcloud/continuous-integration-php8.0:latest - name: integration-ttl + name: integration-message_expire trigger: branch: - master @@ -670,7 +670,7 @@ trigger: - push --- kind: pipeline -name: int-mysql-ttl +name: int-mysql-message_expire services: - image: ghcr.io/nextcloud/continuous-integration-redis:latest name: cache @@ -700,7 +700,7 @@ steps: - ./occ app:enable notifications - cd apps/$APP_NAME - cd tests/integration/ - - bash run.sh features/ttl + - bash run.sh features/message_expire environment: APP_NAME: spreed CORE_BRANCH: master @@ -708,7 +708,7 @@ steps: GUESTS_BRANCH: master NOTIFICATIONS_BRANCH: master image: ghcr.io/nextcloud/continuous-integration-php8.0:latest - name: integration-ttl + name: integration-message_expire trigger: branch: - master @@ -1110,7 +1110,7 @@ trigger: - push --- kind: pipeline -name: int-pgsql-ttl +name: int-pgsql-message_expire services: - image: ghcr.io/nextcloud/continuous-integration-redis:latest name: cache @@ -1135,7 +1135,7 @@ steps: - ./occ app:enable notifications - cd apps/$APP_NAME - cd tests/integration/ - - bash run.sh features/ttl + - bash run.sh features/message_expire environment: APP_NAME: spreed CORE_BRANCH: master @@ -1143,7 +1143,7 @@ steps: GUESTS_BRANCH: master NOTIFICATIONS_BRANCH: master image: ghcr.io/nextcloud/continuous-integration-php8.0:latest - name: integration-ttl + name: integration-message_expire trigger: branch: - master diff --git a/appinfo/routes/routesRoomController.php b/appinfo/routes/routesRoomController.php index b68b7824b..353c232bd 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::setTimeToLive() */ - ['name' => 'Room#setTimeToLive', 'url' => '/api/{apiVersion}/room/{token}/ttl', 'verb' => 'POST', 'requirements' => $requirements], + /** @see \OCA\Talk\Controller\RoomController::setMessageExpire() */ + ['name' => 'Room#setMessageExpire', 'url' => '/api/{apiVersion}/room/{token}/message-expire', 'verb' => 'POST', 'requirements' => $requirements], ], ]; diff --git a/docs/conversation.md b/docs/conversation.md index 893cb395d..a0875f985 100644 --- a/docs/conversation.md +++ b/docs/conversation.md @@ -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 time to live for messages in a conversation +## Set message expire for messages in a conversation * Required capability: `time-to-live` * Method: `POST` diff --git a/lib/BackgroundJob/ApplyTtl.php b/lib/BackgroundJob/ApplyMessageExpire.php index 4dbd53a5b..98260c559 100644 --- a/lib/BackgroundJob/ApplyTtl.php +++ b/lib/BackgroundJob/ApplyMessageExpire.php @@ -30,7 +30,7 @@ use OCP\AppFramework\Utility\ITimeFactory; use OCP\BackgroundJob\IJob; use OCP\BackgroundJob\TimedJob; -class ApplyTtl extends TimedJob { +class ApplyMessageExpire extends TimedJob { private RoomService $roomService; public function __construct(ITimeFactory $timeFactory, @@ -47,6 +47,6 @@ class ApplyTtl extends TimedJob { * @param array $argument */ protected function run($argument): void { - $this->roomService->deleteExpiredTtl($argument['room_id'], $this->getId()); + $this->roomService->deleteExpiredMessages($argument['room_id'], $this->getId()); } } diff --git a/lib/Controller/RoomController.php b/lib/Controller/RoomController.php index 0803af4a5..fbf6a206c 100644 --- a/lib/Controller/RoomController.php +++ b/lib/Controller/RoomController.php @@ -1713,11 +1713,11 @@ class RoomController extends AEnvironmentAwareController { * @PublicPage * @RequireModeratorParticipant */ - public function setTimeToLive(int $ttl): DataResponse { - if ($ttl < 0) { + public function setMessageExpire(int $seconds): DataResponse { + if ($seconds < 0) { return new DataResponse([], Http::STATUS_BAD_REQUEST); } - $this->roomService->setTimeToLive($this->room, $this->getParticipant(), $ttl); + $this->roomService->setMessageExpire($this->room, $this->getParticipant(), $seconds); return new DataResponse(); } } diff --git a/lib/Events/ChangeTtlEvent.php b/lib/Events/ChangeMessageExpireEvent.php index 005df61b1..2085337f8 100644 --- a/lib/Events/ChangeTtlEvent.php +++ b/lib/Events/ChangeMessageExpireEvent.php @@ -25,16 +25,16 @@ namespace OCA\Talk\Events; use OCA\Talk\Room; -class ChangeTtlEvent extends RoomEvent { - private int $ttl; +class ChangeMessageExpireEvent extends RoomEvent { + private int $seconds; public function __construct(Room $room, - int $ttl + int $seconds ) { parent::__construct($room); - $this->ttl = $ttl; + $this->seconds = $seconds; } - public function getTtl(): int { - return $this->ttl; + public function getMessageExpireSeconds(): int { + return $this->seconds; } } diff --git a/lib/Manager.php b/lib/Manager.php index 353558dcf..023c7e702 100644 --- a/lib/Manager.php +++ b/lib/Manager.php @@ -165,7 +165,7 @@ class Manager { (int) $row['type'], (int) $row['read_only'], (int) $row['listable'], - (int) $row['time_to_live'], + (int) $row['message_expire'], (int) $row['lobby_state'], (int) $row['sip_enabled'], $assignedSignalingServer, diff --git a/lib/Migration/Version15000Date20220506005058.php b/lib/Migration/Version15000Date20220506005058.php index cb71afaa7..0397a50d0 100644 --- a/lib/Migration/Version15000Date20220506005058.php +++ b/lib/Migration/Version15000Date20220506005058.php @@ -45,8 +45,8 @@ class Version15000Date20220506005058 extends SimpleMigrationStep { $schema = $schemaClosure(); $table = $schema->getTable('talk_rooms'); - if (!$table->hasColumn('time_to_live')) { - $table->addColumn('time_to_live', Types::INTEGER, [ + if (!$table->hasColumn('message_expire')) { + $table->addColumn('message_expire', Types::INTEGER, [ 'default' => 0, ]); return $schema; diff --git a/lib/Model/SelectHelper.php b/lib/Model/SelectHelper.php index 3e946c94e..28a426e24 100644 --- a/lib/Model/SelectHelper.php +++ b/lib/Model/SelectHelper.php @@ -51,7 +51,7 @@ class SelectHelper { ->addSelect($alias . 'object_type') ->addSelect($alias . 'object_id') ->addSelect($alias . 'listable') - ->addSelect($alias . 'time_to_live') + ->addSelect($alias . 'message_expire') ->addSelect($alias . 'remote_server') ->addSelect($alias . 'remote_token') ->selectAlias($alias . 'id', 'r_id'); diff --git a/lib/Room.php b/lib/Room.php index 85adc90d8..3d669a9b1 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_TIME_TO_LIVE = self::class . '::beforeSetTimeToLive'; - public const EVENT_AFTER_SET_TIME_TO_LIVE = self::class . '::afterSetTimeToLive'; + public const EVENT_BEFORE_SET_MESSAGE_EXPIRE = self::class . '::beforeSetMessageExpire'; + public const EVENT_AFTER_SET_MESSAGE_EXPIRE = self::class . '::afterSetMessageExpire'; public const DESCRIPTION_MAXIMUM_LENGTH = 500; diff --git a/lib/Service/RoomService.php b/lib/Service/RoomService.php index 01f033e86..d73f6631d 100644 --- a/lib/Service/RoomService.php +++ b/lib/Service/RoomService.php @@ -25,10 +25,10 @@ namespace OCA\Talk\Service; use DateInterval; use InvalidArgumentException; -use OCA\Talk\BackgroundJob\ApplyTtl; +use OCA\Talk\BackgroundJob\ApplyMessageExpire; use OCA\Talk\Chat\ChatManager; use OCA\Talk\Chat\CommentsManager; -use OCA\Talk\Events\ChangeTtlEvent; +use OCA\Talk\Events\ChangeMessageExpireEvent; use OCA\Talk\Events\ModifyLobbyEvent; use OCA\Talk\Events\ModifyRoomEvent; use OCA\Talk\Events\VerifyRoomPasswordEvent; @@ -542,35 +542,35 @@ class RoomService { ]; } - public function setTimeToLive(Room $room, Participant $participant, int $ttl): void { - $event = new ChangeTtlEvent($room, $ttl); - $this->dispatcher->dispatch(Room::EVENT_BEFORE_SET_TIME_TO_LIVE, $event); + 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); $update = $this->db->getQueryBuilder(); $update->update('talk_rooms') - ->set('time_to_live', $update->createNamedParameter($ttl, IQueryBuilder::PARAM_INT)) + ->set('message_expire', $update->createNamedParameter($seconds, IQueryBuilder::PARAM_INT)) ->where($update->expr()->eq('id', $update->createNamedParameter($room->getId(), IQueryBuilder::PARAM_INT))); $update->executeStatement(); $jobList = Server::get(IJobList::class); - if ($ttl > 0) { - $this->ttlSystemMessage($room, $participant, $ttl, 'ttl_enabled'); - $jobList->add(ApplyTtl::class, ['room_id' => $room->getId()]); + if ($seconds > 0) { + $this->messageExpireSystemMessage($room, $participant, $seconds, 'message_expire_enabled'); + $jobList->add(ApplyMessageExpire::class, ['room_id' => $room->getId()]); } else { - $this->ttlSystemMessage($room, $participant, $ttl, 'ttl_disabled'); - $jobList->remove(ApplyTtl::class, ['room_id' => $room->getId()]); + $this->messageExpireSystemMessage($room, $participant, $seconds, 'message_expire_disabled'); + $jobList->remove(ApplyMessageExpire::class, ['room_id' => $room->getId()]); } - $this->dispatcher->dispatch(Room::EVENT_AFTER_SET_TIME_TO_LIVE, $event); + $this->dispatcher->dispatch(Room::EVENT_AFTER_SET_MESSAGE_EXPIRE, $event); } - private function ttlSystemMessage(Room $room, Participant $participant, int $ttl, string $message): void { + private function messageExpireSystemMessage(Room $room, Participant $participant, int $seconds, string $message): void { $this->chatManager->addSystemMessage( $room, $participant->getAttendee()->getActorType(), $participant->getAttendee()->getActorId(), json_encode([ 'message' => $message, - 'parameters' => ['ttl' => $ttl] + 'parameters' => ['seconds' => $seconds] ]), $this->timeFactory->getDateTime(), false @@ -578,11 +578,11 @@ class RoomService { } - public function deleteExpiredTtl(int $roomId, int $jobId): array { + public function deleteExpiredMessages(int $roomId, int $jobId): array { $room = $this->manager->getRoomById($roomId); - $max = $this->getMaxDateTtl($room->getTimeToLive()); - $min = $this->getMinDateTtl($jobId); + $max = $this->getMaxMessageExpireSeconds($room->getTimeToLive()); + $min = $this->getMinMessageExpireSeconds($jobId); $ids = $this->commentsManager->getMessageIdsByRoomIdInDateInterval($roomId, $min, $max); if (count($ids)) { @@ -592,12 +592,12 @@ class RoomService { return $ids; } - private function getMaxDateTtl(int $ttl): \DateTime { + private function getMaxMessageExpireSeconds(int $seconds): \DateTime { $max = $this->timeFactory->getDateTime(); - return $max->sub(new DateInterval('PT' . $ttl . 'S')); + return $max->sub(new DateInterval('PT' . $seconds . 'S')); } - private function getMinDateTtl(int $jobId): \DateTime { + private function getMinMessageExpireSeconds(int $jobId): \DateTime { $query = $this->db->getQueryBuilder(); $query->select('last_checked') ->from('jobs') @@ -627,8 +627,8 @@ class RoomService { foreach ($ids as $id) { $this->chatManager->addSystemMessage( $chat, - 'ttl_expired', - 'ttl_expired', + 'message_expire_expired', + 'message_expire_expired', json_encode(['message' => 'message_deleted', 'parameters' => ['message' => $id]]), $this->timeFactory->getDateTime(), false, diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php index a5dfc8ce0..b214ac704 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 ttl to :ttl of room :identifier with :statusCode (:apiVersion) + * @Given user :user set the message expire to :messageExpire of room :identifier with :statusCode (:apiVersio |