Add an endpoint for a media tab

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2022-03-18 09:23:24 +01:00
Родитель 9822c9fb1c
Коммит 2397bd4fae
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 7076EA9751AACDDA
2 изменённых файлов: 33 добавлений и 0 удалений

Просмотреть файл

@ -52,5 +52,7 @@ return [
['name' => 'Chat#mentions', 'url' => '/api/{apiVersion}/chat/{token}/mentions', 'verb' => 'GET', 'requirements' => $requirements],
/** @see \OCA\Talk\Controller\ChatController::shareObjectToChat() */
['name' => 'Chat#shareObjectToChat', 'url' => '/api/{apiVersion}/chat/{token}/share', 'verb' => 'POST', 'requirements' => $requirements],
/** @see \OCA\Talk\Controller\ChatController::getObjectsSharedInRoom() */
['name' => 'Chat#getObjectsSharedInRoom', 'url' => '/api/{apiVersion}/chat/{token}/share', 'verb' => 'GET', 'requirements' => $requirements],
],
];

Просмотреть файл

@ -700,6 +700,37 @@ class ChatController extends AEnvironmentAwareController {
return $this->setReadMarker($unreadId);
}
/**
* @PublicPage
* @RequireParticipant
* @RequireReadWriteConversation
* @RequireModeratorOrNoLobby
*
* @param int $offset
* @param int $limit
* @return DataResponse
*/
public function getObjectsSharedInRoom(int $offset = 0, int $limit = 50): DataResponse {
$offset = max(0, $offset);
$limit = min(200, $limit);
$comments = $this->chatManager->searchForObjects('', [$this->room->getId()], 'object_shared', $offset, $limit);
$messages = [];
foreach ($comments as $comment) {
$message = $this->messageParser->createMessage($this->room, $this->participant, $comment, $this->l);
$this->messageParser->parseMessage($message);
if (!$message->getVisibility()) {
continue;
}
$messages[] = $message->toArray();
}
return new DataResponse($messages);
}
/**
* @PublicPage
* @RequireParticipant