<NME> ApiController.php
<BEF> <?php

declare(strict_types=1);
/**
 * @author Joas Schilling <coding@schilljs.com>
 *
 * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com>
 *
 * @license GNU AGPL version 3 or any later version
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

namespace OCA\SpreedCheats\Controller;

use OCA\Talk\BackgroundJob\ExpireChatMessages;
use OCP\AppFramework\Http;
use OCP\AppFramework\OCSController;
use OCP\AppFramework\Http\DataResponse;
use OCP\IDBConnection;
use OCP\IRequest;
use OCP\Share\IShare;

class ApiController extends OCSController {
	/** @var IDBConnection */
	private $db;

	public function __construct(string $appName,
								IRequest $request,
								IDBConnection $db
	) {
		parent::__construct($appName, $request);
		$this->db = $db;
	}

	/**
	 * @NoCSRFRequired
	 *
	 * @return DataResponse
	 */
	public function resetSpreed(): DataResponse {
		$delete = $this->db->getQueryBuilder();
		$delete->delete('talk_attachments')->executeStatement();

		$delete = $this->db->getQueryBuilder();
		$delete->delete('talk_attendees')->executeStatement();

		$delete = $this->db->getQueryBuilder();
		$delete->delete('talk_bridges')->executeStatement();

		$delete = $this->db->getQueryBuilder();
		$delete->delete('talk_commands')
			->where($delete->expr()->neq('app', $delete->createNamedParameter('')))
			->andWhere($delete->expr()->neq('command', $delete->createNamedParameter('help')))
			->executeStatement();

		$delete = $this->db->getQueryBuilder();
		$delete->delete('talk_internalsignaling')->executeStatement();

		$delete = $this->db->getQueryBuilder();
		$delete->delete('talk_invitations')->executeStatement();

		$delete = $this->db->getQueryBuilder();
		$delete->delete('talk_rooms')->executeStatement();

		$delete = $this->db->getQueryBuilder();
		$delete->delete('talk_polls')->executeStatement();

		$delete = $this->db->getQueryBuilder();
		$delete->delete('talk_poll_votes')->executeStatement();

		$delete = $this->db->getQueryBuilder();
		$delete->delete('talk_sessions')->executeStatement();

		$delete = $this->db->getQueryBuilder();
		$delete->delete('share')
			->where($delete->expr()->orX(
				$delete->expr()->eq('share_type', $delete->createNamedParameter(IShare::TYPE_ROOM)),
				$delete->expr()->eq('share_type', $delete->createNamedParameter(11 /*RoomShareProvider::SHARE_TYPE_USERROOM*/))
			))
			->executeStatement();

		try {
			$delete = $this->db->getQueryBuilder();
			$delete->delete('notifications')
				->where($delete->expr()->eq('app', $delete->createNamedParameter('spreed')))
				->executeStatement();
		} catch (\Throwable $e) {
			// Ignore
		}

		return new DataResponse();
	}

	/**
	 * @NoCSRFRequired
	 *
	 * @return JSONResponse
	 */
	public function getTtlJob($token): JSONResponse {
		$class = 'OCA\Talk\BackgroundJob\ApplyTtl';
		$roomId = $this->getRoomIdByToken($token);
		if (!$roomId) {
			return new JSONResponse();
				$query->expr()->eq('class', $query->createNamedParameter(ExpireChatMessages::class))
			);
		$result = $query->executeQuery();
		$job = $result->fetchOne();
		if ($job) {
			return new DataResponse(['id' => (int) $job]);
		}
		return new DataResponse([], Http::STATUS_NOT_FOUND);
	}
}

<MSG> Rename ttl to message expire

Signed-off-by: Vitor Mattos <ddd80347cc894536655615ccf7805ebc23683866@php.rio>

<DFF> @@ -109,8 +109,8 @@ class ApiController extends OCSController {
 	 *
 	 * @return JSONResponse
 	 */
-	public function getTtlJob($token): JSONResponse {
-		$class = 'OCA\Talk\BackgroundJob\ApplyTtl';
+	public function getMessageExpireJob($token): JSONResponse {
+		$class = 'OCA\Talk\BackgroundJob\ApplyMessageExpire';
 		$roomId = $this->getRoomIdByToken($token);
 		if (!$roomId) {
 			return new JSONResponse();

{'commit': 'diff --git a/.drone.jsonnet b/.drone.jsonnet\nindex d0104fe1b..16bfdbe30 100644\n--- a/.drone.jsonnet\n+++ b/.drone.jsonnet\n@@ -123,7 +123,7 @@ local PipelinePostgreSQL(test_set) = Pipeline(\n \tPipelineSQLite("conversation-2"),\n \tPipelineSQLite("federation"),\n \tPipelineSQLite("reaction"),\n-\tPipelineSQLite("ttl"),\n+\tPipelineSQLite("message_expire"),\n \tPipelineSQLite("sharing"),\n \tPipelineSQLite("sharing-2"),\n \n@@ -134,7 +134,7 @@ local PipelinePostgreSQL(test_set) = Pipeline(\n \tPipelineMySQL("conversation-2"),\n \tPipelineMySQL("federation"),\n \tPipelineMySQL("reaction"),\n-\tPipelineMySQL("ttl"),\n+\tPipelineMySQL("message_expire"),\n \tPipelineMySQL("sharing"),\n \tPipelineMySQL("sharing-2"),\n \n@@ -145,7 +145,7 @@ local PipelinePostgreSQL(test_set) = Pipeline(\n \tPipelinePostgreSQL("conversation-2"),\n \tPipelinePostgreSQL("federation"),\n \tPipelinePostgreSQL("reaction"),\n-\tPipelinePostgreSQL("ttl"),\n+\tPipelinePostgreSQL("message_expire"),\n \tPipelinePostgreSQL("sharing"),\n \tPipelinePostgreSQL("sharing-2"),\n ]\ndiff --git a/.drone.yml b/.drone.yml\nindex 3634dfbcf..874cf6411 100644\n--- a/.drone.yml\n+++ b/.drone.yml\n@@ -233,7 +233,7 @@ trigger:\n   - push\n ---\n kind: pipeline\n-name: int-sqlite-ttl\n+name: int-sqlite-message_expire\n services:\n - image: ghcr.io/nextcloud/continuous-integration-redis:latest\n   name: cache\n@@ -249,7 +249,7 @@ steps:\n   - ./occ app:enable notifications\n   - cd apps/$APP_NAME\n   - cd tests/integration/\n-  - bash run.sh features/ttl\n+  - bash run.sh features/message_expire\n   environment:\n     APP_NAME: spreed\n     CORE_BRANCH: master\n@@ -257,7 +257,7 @@ steps:\n     GUESTS_BRANCH: master\n     NOTIFICATIONS_BRANCH: master\n   image: ghcr.io/nextcloud/continuous-integration-php8.0:latest\n-  name: integration-ttl\n+  name: integration-message_expire\n trigger:\n   branch:\n   - master\n@@ -670,7 +670,7 @@ trigger:\n   - push\n ---\n kind: pipeline\n-name: int-mysql-ttl\n+name: int-mysql-message_expire\n services:\n - image: ghcr.io/nextcloud/continuous-integration-redis:latest\n   name: cache\n@@ -700,7 +700,7 @@ steps:\n   - ./occ app:enable notifications\n   - cd apps/$APP_NAME\n   - cd tests/integration/\n-  - bash run.sh features/ttl\n+  - bash run.sh features/message_expire\n   environment:\n     APP_NAME: spreed\n     CORE_BRANCH: master\n@@ -708,7 +708,7 @@ steps:\n     GUESTS_BRANCH: master\n     NOTIFICATIONS_BRANCH: master\n   image: ghcr.io/nextcloud/continuous-integration-php8.0:latest\n-  name: integration-ttl\n+  name: integration-message_expire\n trigger:\n   branch:\n   - master\n@@ -1110,7 +1110,7 @@ trigger:\n   - push\n ---\n kind: pipeline\n-name: int-pgsql-ttl\n+name: int-pgsql-message_expire\n services:\n - image: ghcr.io/nextcloud/continuous-integration-redis:latest\n   name: cache\n@@ -1135,7 +1135,7 @@ steps:\n   - ./occ app:enable notifications\n   - cd apps/$APP_NAME\n   - cd tests/integration/\n-  - bash run.sh features/ttl\n+  - bash run.sh features/message_expire\n   environment:\n     APP_NAME: spreed\n     CORE_BRANCH: master\n@@ -1143,7 +1143,7 @@ steps:\n     GUESTS_BRANCH: master\n     NOTIFICATIONS_BRANCH: master\n   image: ghcr.io/nextcloud/continuous-integration-php8.0:latest\n-  name: integration-ttl\n+  name: integration-message_expire\n trigger:\n   branch:\n   - master\ndiff --git a/appinfo/routes/routesRoomController.php b/appinfo/routes/routesRoomController.php\nindex b68b7824b..353c232bd 100644\n--- a/appinfo/routes/routesRoomController.php\n+++ b/appinfo/routes/routesRoomController.php\n@@ -102,7 +102,7 @@ return [\n \t\t[\'name\' => \'Room#setLobby\', \'url\' => \'/api/{apiVersion}/room/{token}/webinar/lobby\', \'verb\' => \'PUT\', \'requirements\' => $requirementsWithToken],\n \t\t/** @see \\OCA\\Talk\\Controller\\RoomController::setSIPEnabled() */\n \t\t[\'name\' => \'Room#setSIPEnabled\', \'url\' => \'/api/{apiVersion}/room/{token}/webinar/sip\', \'verb\' => \'PUT\', \'requirements\' => $requirementsWithToken],\n-\t\t/** @see \\OCA\\Talk\\Controller\\RoomController::setTimeToLive() */\n-\t\t[\'name\' => \'Room#setTimeToLive\', \'url\' => \'/api/{apiVersion}/room/{token}/ttl\', \'verb\' => \'POST\', \'requirements\' => $requirements],\n+\t\t/** @see \\OCA\\Talk\\Controller\\RoomController::setMessageExpire() */\n+\t\t[\'name\' => \'Room#setMessageExpire\', \'url\' => \'/api/{apiVersion}/room/{token}/message-expire\', \'verb\' => \'POST\', \'requirements\' => $requirements],\n \t],\n ];\ndiff --git a/docs/conversation.md b/docs/conversation.md\nindex 893cb395d..a0875f985 100644\n--- a/docs/conversation.md\n+++ b/docs/conversation.md\n@@ -337,7 +337,7 @@\n         + `401 Unauthorized` When the participant is a guest\n         + `404 Not Found` When the conversation could not be found for the participant\n \n-## Set time to live for messages in a conversation\n+## Set message expire for messages in a conversation\n \n * Required capability: `time-to-live`\n * Method: `POST`\ndiff --git a/lib/BackgroundJob/ApplyTtl.php b/lib/BackgroundJob/ApplyMessageExpire.php\nsimilarity index 91%\nrename from lib/BackgroundJob/ApplyTtl.php\nrename to lib/BackgroundJob/ApplyMessageExpire.php\nindex 4dbd53a5b..98260c559 100644\n--- a/lib/BackgroundJob/ApplyTtl.php\n+++ b/lib/BackgroundJob/ApplyMessageExpire.php\n@@ -30,7 +30,7 @@ use OCP\\AppFramework\\Utility\\ITimeFactory;\n use OCP\\BackgroundJob\\IJob;\n use OCP\\BackgroundJob\\TimedJob;\n \n-class ApplyTtl extends TimedJob {\n+class ApplyMessageExpire extends TimedJob {\n \tprivate RoomService $roomService;\n \n \tpublic function __construct(ITimeFactory $timeFactory,\n@@ -47,6 +47,6 @@ class ApplyTtl extends TimedJob {\n \t * @param array $argument\n \t */\n \tprotected function run($argument): void {\n-\t\t$this->roomService->deleteExpiredTtl($argument[\'room_id\'], $this->getId());\n+\t\t$this->roomService->deleteExpiredMessages($argument[\'room_id\'], $this->getId());\n \t}\n }\ndiff --git a/lib/Controller/RoomController.php b/lib/Controller/RoomController.php\nindex 0803af4a5..fbf6a206c 100644\n--- a/lib/Controller/RoomController.php\n+++ b/lib/Controller/RoomController.php\n@@ -1713,11 +1713,11 @@ class RoomController extends AEnvironmentAwareController {\n \t * @PublicPage\n \t * @RequireModeratorParticipant\n \t */\n-\tpublic function setTimeToLive(int $ttl): DataResponse {\n-\t\tif ($ttl < 0) {\n+\tpublic function setMessageExpire(int $seconds): DataResponse {\n+\t\tif ($seconds < 0) {\n \t\t\treturn new DataResponse([], Http::STATUS_BAD_REQUEST);\n \t\t}\n-\t\t$this->roomService->setTimeToLive($this->room, $this->getParticipant(), $ttl);\n+\t\t$this->roomService->setMessageExpire($this->room, $this->getParticipant(), $seconds);\n \t\treturn new DataResponse();\n \t}\n }\ndiff --git a/lib/Events/ChangeTtlEvent.php b/lib/Events/ChangeMessageExpireEvent.php\nsimilarity index 82%\nrename from lib/Events/ChangeTtlEvent.php\nrename to lib/Events/ChangeMessageExpireEvent.php\nindex 005df61b1..2085337f8 100644\n--- a/lib/Events/ChangeTtlEvent.php\n+++ b/lib/Events/ChangeMessageExpireEvent.php\n@@ -25,16 +25,16 @@ namespace OCA\\Talk\\Events;\n \n use OCA\\Talk\\Room;\n \n-class ChangeTtlEvent extends RoomEvent {\n-\tprivate int $ttl;\n+class ChangeMessageExpireEvent extends RoomEvent {\n+\tprivate int $seconds;\n \tpublic function __construct(Room $room,\n-\t\t\t\t\t\t\t\tint $ttl\n+\t\t\t\t\t\t\t\tint $seconds\n \t) {\n \t\tparent::__construct($room);\n-\t\t$this->ttl = $ttl;\n+\t\t$this->seconds = $seconds;\n \t}\n \n-\tpublic function getTtl(): int {\n-\t\treturn $this->ttl;\n+\tpublic function getMessageExpireSeconds(): int {\n+\t\treturn $this->seconds;\n \t}\n }\ndiff --git a/lib/Manager.php b/lib/Manager.php\nindex 353558dcf..023c7e702 100644\n--- a/lib/Manager.php\n+++ b/lib/Manager.php\n@@ -165,7 +165,7 @@ class Manager {\n \t\t\t(int) $row[\'type\'],\n \t\t\t(int) $row[\'read_only\'],\n \t\t\t(int) $row[\'listable\'],\n-\t\t\t(int) $row[\'time_to_live\'],\n+\t\t\t(int) $row[\'message_expire\'],\n \t\t\t(int) $row[\'lobby_state\'],\n \t\t\t(int) $row[\'sip_enabled\'],\n \t\t\t$assignedSignalingServer,\ndiff --git a/lib/Migration/Version15000Date20220506005058.php b/lib/Migration/Version15000Date20220506005058.php\nindex cb71afaa7..0397a50d0 100644\n--- a/lib/Migration/Version15000Date20220506005058.php\n+++ b/lib/Migration/Version15000Date20220506005058.php\n@@ -45,8 +45,8 @@ class Version15000Date20220506005058 extends SimpleMigrationStep {\n \t\t$schema = $schemaClosure();\n \n \t\t$table = $schema->getTable(\'talk_rooms\');\n-\t\tif (!$table->hasColumn(\'time_to_live\')) {\n-\t\t\t$table->addColumn(\'time_to_live\', Types::INTEGER, [\n+\t\tif (!$table->hasColumn(\'message_expire\')) {\n+\t\t\t$table->addColumn(\'message_expire\', Types::INTEGER, [\n \t\t\t\t\'default\' => 0,\n \t\t\t]);\n \t\t\treturn $schema;\ndiff --git a/lib/Model/SelectHelper.php b/lib/Model/SelectHelper.php\nindex 3e946c94e..28a426e24 100644\n--- a/lib/Model/SelectHelper.php\n+++ b/lib/Model/SelectHelper.php\n@@ -51,7 +51,7 @@ class SelectHelper {\n \t\t\t->addSelect($alias . \'object_type\')\n \t\t\t->addSelect($alias . \'object_id\')\n \t\t\t->addSelect($alias . \'listable\')\n-\t\t\t->addSelect($alias . \'time_to_live\')\n+\t\t\t->addSelect($alias . \'message_expire\')\n \t\t\t->addSelect($alias . \'remote_server\')\n \t\t\t->addSelect($alias . \'remote_token\')\n \t\t\t->selectAlias($alias . \'id\', \'r_id\');\ndiff --git a/lib/Room.php b/lib/Room.php\nindex 85adc90d8..3d669a9b1 100644\n--- a/lib/Room.php\n+++ b/lib/Room.php\n@@ -147,8 +147,8 @@ class Room {\n \tpublic const EVENT_BEFORE_SESSION_LEAVE_CALL = self::class . \'::preSessionLeaveCall\';\n \tpublic const EVENT_AFTER_SESSION_LEAVE_CALL = self::class . \'::postSessionLeaveCall\';\n \tpublic const EVENT_BEFORE_SIGNALING_PROPERTIES = self::class . \'::beforeSignalingProperties\';\n-\tpublic const EVENT_BEFORE_SET_TIME_TO_LIVE = self::class . \'::beforeSetTimeToLive\';\n-\tpublic const EVENT_AFTER_SET_TIME_TO_LIVE = self::class . \'::afterSetTimeToLive\';\n+\tpublic const EVENT_BEFORE_SET_MESSAGE_EXPIRE = self::class . \'::beforeSetMessageExpire\';\n+\tpublic const EVENT_AFTER_SET_MESSAGE_EXPIRE = self::class . \'::afterSetMessageExpire\';\n \n \tpublic const DESCRIPTION_MAXIMUM_LENGTH = 500;\n \ndiff --git a/lib/Service/RoomService.php b/lib/Service/RoomService.php\nindex 01f033e86..d73f6631d 100644\n--- a/lib/Service/RoomService.php\n+++ b/lib/Service/RoomService.php\n@@ -25,10 +25,10 @@ namespace OCA\\Talk\\Service;\n \n use DateInterval;\n use InvalidArgumentException;\n-use OCA\\Talk\\BackgroundJob\\ApplyTtl;\n+use OCA\\Talk\\BackgroundJob\\ApplyMessageExpire;\n use OCA\\Talk\\Chat\\ChatManager;\n use OCA\\Talk\\Chat\\CommentsManager;\n-use OCA\\Talk\\Events\\ChangeTtlEvent;\n+use OCA\\Talk\\Events\\ChangeMessageExpireEvent;\n use OCA\\Talk\\Events\\ModifyLobbyEvent;\n use OCA\\Talk\\Events\\ModifyRoomEvent;\n use OCA\\Talk\\Events\\VerifyRoomPasswordEvent;\n@@ -542,35 +542,35 @@ class RoomService {\n \t\t];\n \t}\n \n-\tpublic function setTimeToLive(Room $room, Participant $participant, int $ttl): void {\n-\t\t$event = new ChangeTtlEvent($room, $ttl);\n-\t\t$this->dispatcher->dispatch(Room::EVENT_BEFORE_SET_TIME_TO_LIVE, $event);\n+\tpublic function setMessageExpire(Room $room, Participant $participant, int $seconds): void {\n+\t\t$event = new ChangeMessageExpireEvent($room, $seconds);\n+\t\t$this->dispatcher->dispatch(Room::EVENT_BEFORE_SET_MESSAGE_EXPIRE, $event);\n \n \t\t$update = $this->db->getQueryBuilder();\n \t\t$update->update(\'talk_rooms\')\n-\t\t\t->set(\'time_to_live\', $update->createNamedParameter($ttl, IQueryBuilder::PARAM_INT))\n+\t\t\t->set(\'message_expire\', $update->createNamedParameter($seconds, IQueryBuilder::PARAM_INT))\n \t\t\t->where($update->expr()->eq(\'id\', $update->createNamedParameter($room->getId(), IQueryBuilder::PARAM_INT)));\n \t\t$update->executeStatement();\n \t\t$jobList = Server::get(IJobList::class);\n-\t\tif ($ttl > 0) {\n-\t\t\t$this->ttlSystemMessage($room, $participant, $ttl, \'ttl_enabled\');\n-\t\t\t$jobList->add(ApplyTtl::class, [\'room_id\' => $room->getId()]);\n+\t\tif ($seconds > 0) {\n+\t\t\t$this->messageExpireSystemMessage($room, $participant, $seconds, \'message_expire_enabled\');\n+\t\t\t$jobList->add(ApplyMessageExpire::class, [\'room_id\' => $room->getId()]);\n \t\t} else {\n-\t\t\t$this->ttlSystemMessage($room, $participant, $ttl, \'ttl_disabled\');\n-\t\t\t$jobList->remove(ApplyTtl::class, [\'room_id\' => $room->getId()]);\n+\t\t\t$this->messageExpireSystemMessage($room, $participant, $seconds, \'message_expire_disabled\');\n+\t\t\t$jobList->remove(ApplyMessageExpire::class, [\'room_id\' => $room->getId()]);\n \t\t}\n \n-\t\t$this->dispatcher->dispatch(Room::EVENT_AFTER_SET_TIME_TO_LIVE, $event);\n+\t\t$this->dispatcher->dispatch(Room::EVENT_AFTER_SET_MESSAGE_EXPIRE, $event);\n \t}\n \n-\tprivate function ttlSystemMessage(Room $room, Participant $participant, int $ttl, string $message): void {\n+\tprivate function messageExpireSystemMessage(Room $room, Participant $participant, int $seconds, string $message): void {\n \t\t$this->chatManager->addSystemMessage(\n \t\t\t$room,\n \t\t\t$participant->getAttendee()->getActorType(),\n \t\t\t$participant->getAttendee()->getActorId(),\n \t\t\tjson_encode([\n \t\t\t\t\'message\' => $message,\n-\t\t\t\t\'parameters\' => [\'ttl\' => $ttl]\n+\t\t\t\t\'parameters\' => [\'seconds\' => $seconds]\n \t\t\t]),\n \t\t\t$this->timeFactory->getDateTime(),\n \t\t\tfalse\n@@ -578,11 +578,11 @@ class RoomService {\n \t}\n \n \n-\tpublic function deleteExpiredTtl(int $roomId, int $jobId): array {\n+\tpublic function deleteExpiredMessages(int $roomId, int $jobId): array {\n \t\t$room = $this->manager->getRoomById($roomId);\n \n-\t\t$max = $this->getMaxDateTtl($room->getTimeToLive());\n-\t\t$min = $this->getMinDateTtl($jobId);\n+\t\t$max = $this->getMaxMessageExpireSeconds($room->getTimeToLive());\n+\t\t$min = $this->getMinMessageExpireSeconds($jobId);\n \n \t\t$ids = $this->commentsManager->getMessageIdsByRoomIdInDateInterval($roomId, $min, $max);\n \t\tif (count($ids)) {\n@@ -592,12 +592,12 @@ class RoomService {\n \t\treturn $ids;\n \t}\n \n-\tprivate function getMaxDateTtl(int $ttl): \\DateTime {\n+\tprivate function getMaxMessageExpireSeconds(int $seconds): \\DateTime {\n \t\t$max = $this->timeFactory->getDateTime();\n-\t\treturn $max->sub(new DateInterval(\'PT\' . $ttl . \'S\'));\n+\t\treturn $max->sub(new DateInterval(\'PT\' . $seconds . \'S\'));\n \t}\n \n-\tprivate function getMinDateTtl(int $jobId): \\DateTime {\n+\tprivate function getMinMessageExpireSeconds(int $jobId): \\DateTime {\n \t\t$query = $this->db->getQueryBuilder();\n \t\t$query->select(\'last_checked\')\n \t\t\t->from(\'jobs\')\n@@ -627,8 +627,8 @@ class RoomService {\n \t\tforeach ($ids as $id) {\n \t\t\t$this->chatManager->addSystemMessage(\n \t\t\t\t$chat,\n-\t\t\t\t\'ttl_expired\',\n-\t\t\t\t\'ttl_expired\',\n+\t\t\t\t\'message_expire_expired\',\n+\t\t\t\t\'message_expire_expired\',\n \t\t\t\tjson_encode([\'message\' => \'message_deleted\', \'parameters\' => [\'message\' => $id]]),\n \t\t\t\t$this->timeFactory->getDateTime(),\n \t\t\t\tfalse,\ndiff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php\nindex a5dfc8ce0..b214ac704 100644\n--- a/tests/integration/features/bootstrap/FeatureContext.php\n+++ b/tests/integration/features/bootstrap/FeatureContext.php\n@@ -2568,25 +2568,25 @@ class FeatureContext implements Context, SnippetAcceptingContext {\n \t}\n \n \t/**\n-\t * @Given user :user set the ttl to :ttl of room :identifier with :statusCode (:apiVersion)\n+\t * @Given user :user set the message expire to :messageExpire of room :identifier with :statusCode (:apiVersion)\n \t */\n-\tpublic function userSetTheTtlToWith(string $user, int $ttl, string $identifier, int $statusCode, string $apiVersion = \'v4\'): void {\n+\tpublic function userSetTheMessageExpireToWith(string $user, int $messageExpire, string $identifier, int $statusCode, string $apiVersion = \'v4\'): void {\n \t\t$this->setCurrentUser($user);\n-\t\t$this->sendRequest(\'POST\', \'/apps/spreed/api/\' .  $apiVersion . \'/room/\' . self::$identifierToToken[$identifier] . \'/ttl\', [\n-\t\t\t\'ttl\' => $ttl\n+\t\t$this->sendRequest(\'POST\', \'/apps/spreed/api/\' .  $apiVersion . \'/room/\' . self::$identifierToToken[$identifier] . \'/message-expire\', [\n+\t\t\t\'seconds\' => $messageExpire\n \t\t]);\n \t\t$this->assertStatusCode($this->response, $statusCode);\n \t}\n \n \t/**\n-\t * @Given user :user check if ttl of room :identifier is :ttl (:apiVersion)\n+\t * @Given user :user check if message expire of room :identifier is :messageExpire (:apiVersion)\n \t */\n-\tpublic function userCheckIfTtlOfRoomIsX(string $user, string $identifier, int $ttl, string $apiVersion = \'v4\') {\n+\tpublic function userCheckIfMessageExpireOfRoomIsX(string $user, string $identifier, int $messageExpire, string $apiVersion = \'v4\') {\n \t\t$this->setCurrentUser($user);\n \t\t$this->sendRequest(\'GET\', \'/apps/spreed/api/\' . $apiVersion . \'/room/\' . self::$identifierToToken[$identifier]);\n \t\t$room = $this->getDataFromResponse($this->response);\n \n-\t\tAssert::assertEquals($ttl, $room[\'timeToLive\']);\n+\t\tAssert::assertEquals($messageExpire, $room[\'timeToLive\']);\n \t}\n \n \t/**\n@@ -2597,12 +2597,12 @@ class FeatureContext implements Context, SnippetAcceptingContext {\n \t}\n \n \t/**\n-\t * @When apply ttl job to room :identifier\n+\t * @When apply message expire job to room :identifier\n \t */\n-\tpublic function applyTtlJobToRoom($identifier): void {\n+\tpublic function applyMessageExpireJobToRoom($identifier): void {\n \t\t$currentUser = $this->currentUser;\n \t\t$this->setCurrentUser(\'admin\');\n-\t\t$this->sendRequest(\'GET\', \'/apps/spreedcheats/get_ttl_job/\' . self::$identifierToToken[$identifier]);\n+\t\t$this->sendRequest(\'GET\', \'/apps/spreedcheats/get_message_expire_job/\' . self::$identifierToToken[$identifier]);\n \t\t$response = $this->response->getBody()->getContents();\n \t\t$response = json_decode($response, true);\n \t\tAssert::assertIsArray($response, \'Room \' . $identifier . \'not found\');\ndiff --git a/tests/integration/features/ttl/ttl.feature b/tests/integration/features/message_expiration/message_expiration.feature\nsimilarity index 55%\nrename from tests/integration/features/ttl/ttl.feature\nrename to tests/integration/features/message_expiration/message_expiration.feature\nindex 85d7972b7..4f94ee635 100644\n--- a/tests/integration/features/ttl/ttl.feature\n+++ b/tests/integration/features/message_expiration/message_expiration.feature\n@@ -1,23 +1,23 @@\n-Feature: room/ttp\n+Feature: room/message_expire\n   Background:\n     Given user "participant1" exists\n     Given user "participant2" exists\n     Given user "participant3" exists\n \n-  Scenario: Enable TTL and check after expire\n+  Scenario: Enable message expire and check after expire\n     Given user "participant1" creates room "room" (v4)\n       | roomType | 3 |\n       | roomName | room |\n     And user "participant1" adds user "participant2" to room "room" with 200 (v4)\n     And user "participant1" sends message "Message 1" to room "room" with 201\n-    And user "participant1" set the ttl to -1 of room "room" with 400 (v4)\n-    And user "participant2" set the ttl to 3 of room "room" with 403 (v4)\n-    And user "participant3" set the ttl to 3 of room "room" with 404 (v4)\n-    And user "participant1" set the ttl to 3 of room "room" with 200 (v4)\n+    And user "participant1" set the message expire to -1 of room "room" with 400 (v4)\n+    And user "participant2" set the message expire to 3 of room "room" with 403 (v4)\n+    And user "participant3" set the message expire to 3 of room "room" with 404 (v4)\n+    And user "participant1" set the message expire to 3 of room "room" with 200 (v4)\n     And user "participant1" sends message "Message 2" to room "room" with 201\n-    And user "participant1" check if ttl of room "room" is 3 (v4)\n+    And user "participant1" check if message expire of room "room" is 3 (v4)\n     And wait for 3 seconds\n-    And apply ttl job to room "room"\n+    And apply message expire job to room "room"\n     Then user "participant1" sees the following messages in room "room" with 200\n       | room | actorType | actorId      | actorDisplayName         | message     | messageParameters | parentMessage |\n-      | room | users     | participant1 | participant1-displayname | Message 1   | []                |               |\n\\ No newline at end of file\n+      | room | users     | participant1 | participant1-displayname | Message 1   | []                |               |\ndiff --git a/tests/integration/spreedcheats/appinfo/routes.php b/tests/integration/spreedcheats/appinfo/routes.php\nindex 618bbf9a1..21a933c20 100644\n--- a/tests/integration/spreedcheats/appinfo/routes.php\n+++ b/tests/integration/spreedcheats/appinfo/routes.php\n@@ -26,6 +26,6 @@ declare(strict_types=1);\n return [\n \t\'ocs\' => [\n \t\t[\'name\' => \'Api#resetSpreed\', \'url\' => \'/\', \'verb\' => \'DELETE\'],\n-\t\t[\'name\' => \'Api#getTtlJob\', \'url\' => \'/get_ttl_job/{token}\', \'verb\' => \'GET\'],\n+\t\t[\'name\' => \'Api#getMessageExpireJob\', \'url\' => \'/get_message_expire_job/{token}\', \'verb\' => \'GET\'],\n \t],\n ];\ndiff --git a/tests/integration/spreedcheats/lib/Controller/ApiController.php b/tests/integration/spreedcheats/lib/Controller/ApiController.php\nindex 30184cca8..46c836078 100644\n--- a/tests/integration/spreedcheats/lib/Controller/ApiController.php\n+++ b/tests/integration/spreedcheats/lib/Controller/ApiController.php\n@@ -109,8 +109,8 @@ class ApiController extends OCSController {\n \t *\n \t * @return JSONResponse\n \t */\n-\tpublic function getTtlJob($token): JSONResponse {\n-\t\t$class = \'OCA\\Talk\\BackgroundJob\\ApplyTtl\';\n+\tpublic function getMessageExpireJob($token): JSONResponse {\n+\t\t$class = \'OCA\\Talk\\BackgroundJob\\ApplyMessageExpire\';\n \t\t$roomId = $this->getRoomIdByToken($token);\n \t\tif (!$roomId) {\n \t\t\treturn new JSONResponse();\n', 'commit_subject': 'Rename ttl to message expire', 'repo_name': 'nextcloud/spreed', 'committer': {'name': 'Vitor Mattos', 'email': 'ddd80347cc894536655615ccf7805ebc23683866@php.rio', 'time_sec': '1656612086', 'tz_offset': '-180', 'date': {'seconds': '1656612086'}}, 'commit_tree': 'b30e014314b17a30e85eaf3033e1052ca59f0042', 'commit_message': 'Rename ttl to message expire\n\nSigned-off-by: Vitor Mattos <ddd80347cc894536655615ccf7805ebc23683866@php.rio>\n', 'language_name': 'Shell', 'license': 'agpl-3.0', 'hunks': "@@ -109,8 +109,8 @@ class ApiController extends OCSController {\n \t *\n \t * @return JSONResponse\n \t */\n-\tpublic function getTtlJob($token): JSONResponse {\n-\t\t$class = 'OCA\\Talk\\BackgroundJob\\ApplyTtl';\n+\tpublic function getMessageExpireJob($token): JSONResponse {\n+\t\t$class = 'OCA\\Talk\\BackgroundJob\\ApplyMessageExpire';\n \t\t$roomId = $this->getRoomIdByToken($token);\n \t\tif (!$roomId) {\n \t\t\treturn new JSONResponse();\n", 'addition_count': 2, 'deletion_count': 2, 'src_file': 'a/tests/integration/spreedcheats/lib/Controller/ApiController.php', 'tgt_file': 'b/tests/integration/spreedcheats/lib/Controller/ApiController.php', 'file_extension': '.php', 'before_file': "<?php\n\ndeclare(strict_types=1);\n/**\n * @author Joas Schilling <coding@schilljs.com>\n *\n * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com>\n *\n * @license GNU AGPL version 3 or any later version\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program.  If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nnamespace OCA\\SpreedCheats\\Controller;\n\nuse OCA\\Talk\\BackgroundJob\\ExpireChatMessages;\nuse OCP\\AppFramework\\Http;\nuse OCP\\AppFramework\\OCSController;\nuse OCP\\AppFramework\\Http\\DataResponse;\nuse OCP\\IDBConnection;\nuse OCP\\IRequest;\nuse OCP\\Share\\IShare;\n\nclass ApiController extends OCSController {\n\t/** @var IDBConnection */\n\tprivate $db;\n\n\tpublic function __construct(string $appName,\n\t\t\t\t\t\t\t\tIRequest $request,\n\t\t\t\t\t\t\t\tIDBConnection $db\n\t) {\n\t\tparent::__construct($appName, $request);\n\t\t$this->db = $db;\n\t}\n\n\t/**\n\t * @NoCSRFRequired\n\t *\n\t * @return DataResponse\n\t */\n\tpublic function resetSpreed(): DataResponse {\n\t\t$delete = $this->db->getQueryBuilder();\n\t\t$delete->delete('talk_attachments')->executeStatement();\n\n\t\t$delete = $this->db->getQueryBuilder();\n\t\t$delete->delete('talk_attendees')->executeStatement();\n\n\t\t$delete = $this->db->getQueryBuilder();\n\t\t$delete->delete('talk_bridges')->executeStatement();\n\n\t\t$delete = $this->db->getQueryBuilder();\n\t\t$delete->delete('talk_commands')\n\t\t\t->where($delete->expr()->neq('app', $delete->createNamedParameter('')))\n\t\t\t->andWhere($delete->expr()->neq('command', $delete->createNamedParameter('help')))\n\t\t\t->executeStatement();\n\n\t\t$delete = $this->db->getQueryBuilder();\n\t\t$delete->delete('talk_internalsignaling')->executeStatement();\n\n\t\t$delete = $this->db->getQueryBuilder();\n\t\t$delete->delete('talk_invitations')->executeStatement();\n\n\t\t$delete = $this->db->getQueryBuilder();\n\t\t$delete->delete('talk_rooms')->executeStatement();\n\n\t\t$delete = $this->db->getQueryBuilder();\n\t\t$delete->delete('talk_polls')->executeStatement();\n\n\t\t$delete = $this->db->getQueryBuilder();\n\t\t$delete->delete('talk_poll_votes')->executeStatement();\n\n\t\t$delete = $this->db->getQueryBuilder();\n\t\t$delete->delete('talk_sessions')->executeStatement();\n\n\t\t$delete = $this->db->getQueryBuilder();\n\t\t$delete->delete('share')\n\t\t\t->where($delete->expr()->orX(\n\t\t\t\t$delete->expr()->eq('share_type', $delete->createNamedParameter(IShare::TYPE_ROOM)),\n\t\t\t\t$delete->expr()->eq('share_type', $delete->createNamedParameter(11 /*RoomShareProvider::SHARE_TYPE_USERROOM*/))\n\t\t\t))\n\t\t\t->executeStatement();\n\n\t\ttry {\n\t\t\t$delete = $this->db->getQueryBuilder();\n\t\t\t$delete->delete('notifications')\n\t\t\t\t->where($delete->expr()->eq('app', $delete->createNamedParameter('spreed')))\n\t\t\t\t->executeStatement();\n\t\t} catch (\\Throwable $e) {\n\t\t\t// Ignore\n\t\t}\n\n\t\treturn new DataResponse();\n\t}\n\n\t/**\n\t * @NoCSRFRequired\n\t *\n\t * @return JSONResponse\n\t */\n\tpublic function getTtlJob($token): JSONResponse {\n\t\t$class = 'OCA\\Talk\\BackgroundJob\\ApplyTtl';\n\t\t$roomId = $this->getRoomIdByToken($token);\n\t\tif (!$roomId) {\n\t\t\treturn new JSONResponse();\n\t\t\t\t$query->expr()->eq('class', $query->createNamedParameter(ExpireChatMessages::class))\n\t\t\t);\n\t\t$result = $query->executeQuery();\n\t\t$job = $result->fetchOne();\n\t\tif ($job) {\n\t\t\treturn new DataResponse(['id' => (int) $job]);\n\t\t}\n\t\treturn new DataResponse([], Http::STATUS_NOT_FOUND);\n\t}\n}\n", 'message': 'Rename ttl to message expire\n\nSigned-off-by: Vitor Mattos <ddd80347cc894536655615ccf7805ebc23683866@php.rio>\n', 'author_name': 'Vitor Mattos', 'lang': 'php'}