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
parent
commit
48af93ee39
No known key found for this signature in database GPG Key ID: B7AB4B76A7CA7318
  1. 5
      lib/Controller/ChatController.php
  2. 14
      tests/integration/features/bootstrap/FeatureContext.php
  3. 4
      tests/integration/features/chat/message-expiration.feature

5
lib/Controller/ChatController.php

@ -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;

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

@ -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
*/

4
tests/integration/features/chat/message-expiration.feature

@ -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

Loading…
Cancel
Save