зеркало из https://github.com/nextcloud/spreed.git
Instead of the offset based use lastKnownMessageId as for message
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Родитель
5035644bb9
Коммит
acdbdb7838
|
@ -163,7 +163,7 @@ See [OCP\RichObjectStrings\Definitions](https://github.com/nextcloud/server/blob
|
|||
|
||||
field | type | Description
|
||||
---|---|---
|
||||
`offset` | int | Offset parameter to get another chunk of chat messages
|
||||
`lastKnownMessageId` | int | Serves as an offset for the query. The lastKnownMessageId for the next page is available in the `X-Chat-Last-Given` header.
|
||||
`limit` | int | Number of chat messages with shares you want to get
|
||||
|
||||
* Response:
|
||||
|
@ -173,6 +173,12 @@ See [OCP\RichObjectStrings\Definitions](https://github.com/nextcloud/server/blob
|
|||
+ `404 Not Found` When the conversation could not be found for the participant
|
||||
+ `412 Precondition Failed` When the lobby is active and the user is not a moderator
|
||||
|
||||
- Header:
|
||||
|
||||
field | type | Description
|
||||
---|---|---
|
||||
`X-Chat-Last-Given` | int | Offset (lastKnownMessageId) for the next page.
|
||||
|
||||
- Data:
|
||||
Array of messages as defined in [Receive chat messages of a conversation](#receive-chat-messages-of-a-conversation)
|
||||
|
||||
|
|
|
@ -564,6 +564,25 @@ class ChatManager {
|
|||
$this->notifier->removePendingNotificationsForRoom($chat);
|
||||
}
|
||||
|
||||
/**
|
||||
* Search for comments with a given content
|
||||
*
|
||||
* @param Room $chat
|
||||
* @param int $offset
|
||||
* @param int $limit
|
||||
* @return IComment[]
|
||||
*/
|
||||
public function getSharedObjectMessages(Room $chat, int $offset, int $limit): array {
|
||||
return $this->commentsManager->getCommentsWithVerbForObjectSinceComment(
|
||||
'chat',
|
||||
(string) $chat->getId(),
|
||||
['object_shared'],
|
||||
$offset,
|
||||
'desc',
|
||||
$limit
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Search for comments with a given content
|
||||
*
|
||||
|
|
|
@ -706,15 +706,15 @@ class ChatController extends AEnvironmentAwareController {
|
|||
* @RequireReadWriteConversation
|
||||
* @RequireModeratorOrNoLobby
|
||||
*
|
||||
* @param int $offset
|
||||
* @param int $lastKnownMessageId
|
||||
* @param int $limit
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function getObjectsSharedInRoom(int $offset = 0, int $limit = 50): DataResponse {
|
||||
$offset = max(0, $offset);
|
||||
public function getObjectsSharedInRoom(int $lastKnownMessageId = 0, int $limit = 100): DataResponse {
|
||||
$offset = max(0, $lastKnownMessageId);
|
||||
$limit = min(200, $limit);
|
||||
|
||||
$comments = $this->chatManager->searchForObjects('', [$this->room->getId()], 'object_shared', $offset, $limit);
|
||||
$comments = $this->chatManager->getSharedObjectMessages($this->room, $offset, $limit);
|
||||
|
||||
$messages = [];
|
||||
foreach ($comments as $comment) {
|
||||
|
@ -728,7 +728,14 @@ class ChatController extends AEnvironmentAwareController {
|
|||
$messages[] = $message->toArray();
|
||||
}
|
||||
|
||||
return new DataResponse($messages);
|
||||
$response = new DataResponse($messages, Http::STATUS_OK);
|
||||
|
||||
$newLastKnown = end($comments);
|
||||
if ($newLastKnown instanceof IComment) {
|
||||
$response->addHeader('X-Chat-Last-Given', $newLastKnown->getId());
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1561,7 +1561,7 @@ class FeatureContext implements Context, SnippetAcceptingContext {
|
|||
* @param string $statusCode
|
||||
* @param string $apiVersion
|
||||
*/
|
||||
public function userSeesTheFollowingSharedMediaInRoom($user, $identifier, $statusCode, $apiVersion = 'v1', TableNode $formData = null) {
|
||||
public function userSeesTheFollowingSharedMediaInRoom($user, $identifier, $statusCode, $apiVersion = 'v1', TableNode $formData = null): void {
|
||||
$this->setCurrentUser($user);
|
||||
$this->sendRequest('GET', '/apps/spreed/api/' . $apiVersion . '/chat/' . self::$identifierToToken[$identifier] . '/share');
|
||||
$this->assertStatusCode($this->response, $statusCode);
|
||||
|
|
Загрузка…
Ссылка в новой задаче