diff options
author | Joas Schilling <coding@schilljs.com> | 2022-03-18 11:23:24 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2022-03-18 11:23:24 +0300 |
commit | 8780b1dac49fa62a259cfdcaa32444af09248122 (patch) | |
tree | f07872ccf9eb3dc78e3256c2f4273346e10711dd | |
parent | 2a2895cec1de113d23ebc4682e4780f24733f641 (diff) |
Add an endpoint for a media tabapi/1577/media-tab-endpoint
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r-- | appinfo/routes/routesChatController.php | 2 | ||||
-rw-r--r-- | lib/Controller/ChatController.php | 31 |
2 files changed, 33 insertions, 0 deletions
diff --git a/appinfo/routes/routesChatController.php b/appinfo/routes/routesChatController.php index 9b70c25b0..55f31b981 100644 --- a/appinfo/routes/routesChatController.php +++ b/appinfo/routes/routesChatController.php @@ -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], ], ]; diff --git a/lib/Controller/ChatController.php b/lib/Controller/ChatController.php index 312965dc3..686a75359 100644 --- a/lib/Controller/ChatController.php +++ b/lib/Controller/ChatController.php @@ -706,6 +706,37 @@ class ChatController extends AEnvironmentAwareController { * @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 + * @RequireReadWriteConversation + * @RequireModeratorOrNoLobby + * * @param string $search * @param int $limit * @param bool $includeStatus |