Browse Source
Hide expired messages when do not run expire job
Signed-off-by: Vitor Mattos <vitor@php.rio>
pull/8515/head
Vitor Mattos
3 years ago
No known key found for this signature in database
GPG Key ID: B7AB4B76A7CA7318
3 changed files with
6 additions and
17 deletions
-
lib/Controller/ChatController.php
-
tests/integration/features/bootstrap/FeatureContext.php
-
tests/integration/features/chat/message-expiration.feature
|
|
|
@ -472,6 +472,11 @@ class ChatController extends AEnvironmentAwareController { |
|
|
|
$message = $this->messageParser->createMessage($this->room, $this->participant, $comment, $this->l); |
|
|
|
$this->messageParser->parseMessage($message); |
|
|
|
|
|
|
|
$expireDate = $message->getComment()->getExpireDate(); |
|
|
|
if ($expireDate instanceof \DateTime && $expireDate < $this->timeFactory->getDateTime()) { |
|
|
|
$message->setVisibility(false); |
|
|
|
} |
|
|
|
|
|
|
|
if (!$message->getVisibility()) { |
|
|
|
$commentIdToIndex[$id] = null; |
|
|
|
continue; |
|
|
|
|
|
|
|
@ -2965,20 +2965,6 @@ class FeatureContext implements Context, SnippetAcceptingContext { |
|
|
|
sleep($seconds); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @When apply message expiration job manually |
|
|
|
*/ |
|
|
|
public function applyMessageExpirationJob(): void { |
|
|
|
$currentUser = $this->currentUser; |
|
|
|
$this->setCurrentUser('admin'); |
|
|
|
$this->sendRequest('GET', '/apps/spreedcheats/get_message_expiration_job'); |
|
|
|
$response = $this->getDataFromResponse($this->response); |
|
|
|
Assert::assertIsArray($response, 'Job not found'); |
|
|
|
Assert::assertArrayHasKey('id', $response, 'Job not found'); |
|
|
|
$this->runOcc(['background-job:execute', $response['id'], '--force-execute']); |
|
|
|
$this->setCurrentUser($currentUser); |
|
|
|
} |
|
|
|
|
|
|
|
/* |
|
|
|
* Requests |
|
|
|
*/ |
|
|
|
|
|
|
|
@ -15,11 +15,10 @@ Feature: chat/message-expiration |
|
|
|
And user "participant3" set the message expiration to 3 of room "room" with 404 (v4) |
|
|
|
And user "participant1" set the message expiration to 3 of room "room" with 200 (v4) |
|
|
|
And user "participant1" sends message "Message 2" to room "room" with 201 |
|
|
|
Then user "participant1" is participant of the following rooms (v4) |
|
|
|
And user "participant1" is participant of the following rooms (v4) |
|
|
|
| id | type | messageExpiration | |
|
|
|
| room | 3 | 3 | |
|
|
|
And wait for 3 seconds |
|
|
|
And apply message expiration job manually |
|
|
|
Then user "participant1" sees the following messages in room "room" with 200 |
|
|
|
| room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage | |
|
|
|
| room | users | participant1 | participant1-displayname | Message 1 | [] | | |
|
|
|
@ -34,7 +33,6 @@ Feature: chat/message-expiration |
|
|
|
| room | actorType | actorId | actorDisplayName | message | messageParameters | |
|
|
|
| room2 | users | participant1 | participant1-displayname | {file} | "IGNORE" | |
|
|
|
And wait for 3 seconds |
|
|
|
And apply message expiration job manually |
|
|
|
Then user "participant1" sees the following messages in room "room2" with 200 |
|
|
|
| room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage | |
|
|
|
And user "participant1" gets last share |
|
|
|
|