Browse Source

Rename time to live to message expire

Signed-off-by: Vitor Mattos <vitor@php.rio>
pull/7327/head
Vitor Mattos 4 years ago
parent
commit
3145bac343
No known key found for this signature in database GPG Key ID: B7AB4B76A7CA7318
  1. 2
      docs/conversation.md
  2. 4
      lib/Chat/ChatManager.php
  3. 4
      lib/Controller/RoomController.php
  4. 10
      lib/Room.php
  5. 4
      lib/Service/RoomService.php
  6. 2
      tests/integration/features/bootstrap/FeatureContext.php

2
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)
`timeToLive` | int | v4 | | The time to live of messages in this chat. Zero if disabled. (only available with `time-to-live` capability)
`messageExpire` | int | v4 | | The message expire time in seconds in this chat. Zero if disabled. (only available with `time-to-live` 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

4
lib/Chat/ChatManager.php

@ -36,6 +36,7 @@ use OCA\Talk\Room;
use OCA\Talk\Service\AttachmentService;
use OCA\Talk\Service\ParticipantService;
use OCA\Talk\Service\PollService;
use OCA\Talk\Service\RoomService;
use OCA\Talk\Share\RoomShareProvider;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Comments\IComment;
@ -48,6 +49,7 @@ use OCP\ICacheFactory;
use OCP\IDBConnection;
use OCP\IUser;
use OCP\Notification\IManager as INotificationManager;
use OCP\Server;
use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\IManager;
use OCP\Share\IShare;
@ -703,7 +705,7 @@ class ChatManager {
public function deleteExpiredMessages(int $roomId, int $jobId): array {
$room = $this->manager->getRoomById($roomId);
$max = $this->getMaxMessageExpireSeconds($room->getTimeToLive());
$max = $this->getMaxMessageExpireSeconds(Server::get(RoomService::class)->getMessageExpire($room));
$min = $this->getMinMessageExpireSeconds($jobId);
$ids = $this->commentsManager->getMessageIdsByRoomIdInDateInterval($roomId, $min, $max);

4
lib/Controller/RoomController.php

@ -400,7 +400,7 @@ class RoomController extends AEnvironmentAwareController {
'lastCommonReadMessage' => 0,
'listable' => Room::LISTABLE_NONE,
'callFlag' => Participant::FLAG_DISCONNECTED,
'timeToLive' => 0,
'messageExpire' => 0,
];
$lastActivity = $room->getLastActivity();
@ -467,7 +467,7 @@ class RoomController extends AEnvironmentAwareController {
'defaultPermissions' => $room->getDefaultPermissions(),
'description' => $room->getDescription(),
'listable' => $room->getListable(),
'timeToLive' => $room->getTimeToLive(),
'messageExpire' => $this->roomService->getMessageExpire($room),
]);
if ($currentParticipant->getAttendee()->getReadPrivacy() === Participant::PRIVACY_PUBLIC) {

10
lib/Room.php

@ -162,7 +162,7 @@ class Room {
private int $type;
private int $readOnly;
private int $listable;
private int $timeToLive;
private int $messageExpire;
private int $lobbyState;
private int $sipEnabled;
private ?int $assignedSignalingServer;
@ -196,7 +196,7 @@ class Room {
int $type,
int $readOnly,
int $listable,
int $timeToLive,
int $messageExpire,
int $lobbyState,
int $sipEnabled,
?int $assignedSignalingServer,
@ -226,7 +226,7 @@ class Room {
$this->type = $type;
$this->readOnly = $readOnly;
$this->listable = $listable;
$this->timeToLive = $timeToLive;
$this->messageExpire = $messageExpire;
$this->lobbyState = $lobbyState;
$this->sipEnabled = $sipEnabled;
$this->assignedSignalingServer = $assignedSignalingServer;
@ -288,10 +288,6 @@ class Room {
$this->listable = $newState;
}
public function getTimeToLive(): int {
return $this->timeToLive;
}
public function getLobbyState(): int {
$this->validateTimer();
return $this->lobbyState;

4
lib/Service/RoomService.php

@ -575,4 +575,8 @@ class RoomService {
false
);
}
public function getMessageExpire($room): int {
return $room->messageExpire;
}
}

2
tests/integration/features/bootstrap/FeatureContext.php

@ -2586,7 +2586,7 @@ class FeatureContext implements Context, SnippetAcceptingContext {
$this->sendRequest('GET', '/apps/spreed/api/' . $apiVersion . '/room/' . self::$identifierToToken[$identifier]);
$room = $this->getDataFromResponse($this->response);
Assert::assertEquals($messageExpire, $room['timeToLive']);
Assert::assertEquals($messageExpire, $room['messageExpire']);
}
/**

Loading…
Cancel
Save