diff options
author | Joas Schilling <coding@schilljs.com> | 2020-12-08 16:46:54 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2020-12-10 13:47:04 +0300 |
commit | bc716c7199a1ed315e63d84e3f5f4501800af68b (patch) | |
tree | e4669f0343be5b4e0972717cf5726c4d0e17a63d /lib/Controller/ChatController.php | |
parent | 6eefd9c3fae1d66d3a277f0b1e3d2a8e3a02418c (diff) |
Add the last common read message id as header on chat requests and to the conversation list
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/Controller/ChatController.php')
-rw-r--r-- | lib/Controller/ChatController.php | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/lib/Controller/ChatController.php b/lib/Controller/ChatController.php index 6e97a747b..fd3cd0458 100644 --- a/lib/Controller/ChatController.php +++ b/lib/Controller/ChatController.php @@ -218,7 +218,11 @@ class ChatController extends AEnvironmentAwareController { $this->messageParser->parseMessage($chatMessage); if (!$chatMessage->getVisibility()) { - return new DataResponse([], Http::STATUS_CREATED); + $response = new DataResponse([], Http::STATUS_CREATED); + if ($this->participant->getAttendee()->getReadPrivacy() === Participant::PRIVACY_PUBLIC) { + $response->addHeader('X-Chat-Last-Common-Read', $this->chatManager->getLastCommonReadMessage($this->room)); + } + return $response; } $this->participantService->updateLastReadMessage($this->participant, (int) $comment->getId()); @@ -227,7 +231,12 @@ class ChatController extends AEnvironmentAwareController { if ($parentMessage instanceof Message) { $data['parent'] = $parentMessage->toArray(); } - return new DataResponse($data, Http::STATUS_CREATED); + + $response = new DataResponse($data, Http::STATUS_CREATED); + if ($this->participant->getAttendee()->getReadPrivacy() === Participant::PRIVACY_PUBLIC) { + $response->addHeader('X-Chat-Last-Common-Read', $this->chatManager->getLastCommonReadMessage($this->room)); + } + return $response; } /** @@ -333,7 +342,11 @@ class ChatController extends AEnvironmentAwareController { } if (empty($comments)) { - return new DataResponse([], Http::STATUS_NOT_MODIFIED); + $response = new DataResponse([], Http::STATUS_NOT_MODIFIED); + if ($this->participant->getAttendee()->getReadPrivacy() === Participant::PRIVACY_PUBLIC) { + $response->addHeader('X-Chat-Last-Common-Read', $this->chatManager->getLastCommonReadMessage($this->room)); + } + return $response; } $i = 0; @@ -424,6 +437,9 @@ class ChatController extends AEnvironmentAwareController { * $this->participantService->updateLastReadMessage($this->participant, (int) $newLastKnown->getId()); * } */ + if ($this->participant->getAttendee()->getReadPrivacy() === Participant::PRIVACY_PUBLIC) { + $response->addHeader('X-Chat-Last-Common-Read', $this->chatManager->getLastCommonReadMessage($this->room)); + } } return $response; @@ -438,7 +454,11 @@ class ChatController extends AEnvironmentAwareController { */ public function setReadMarker(int $lastReadMessage): DataResponse { $this->participantService->updateLastReadMessage($this->participant, $lastReadMessage); - return new DataResponse(); + $response = new DataResponse(); + if ($this->participant->getAttendee()->getReadPrivacy() === Participant::PRIVACY_PUBLIC) { + $response->addHeader('X-Chat-Last-Common-Read', $this->chatManager->getLastCommonReadMessage($this->room)); + } + return $response; } /** |