feat: current user endpoint, routing fixes

This commit is contained in:
2025-11-07 19:12:31 +02:00
parent d3c0590dca
commit 30edbc8330
13 changed files with 480 additions and 64 deletions

View File

@@ -42,7 +42,7 @@ class ThreadController extends OCSController {
public function index(): DataResponse {
try {
$threads = $this->threadMapper->findAll();
return new DataResponse(array_map(fn ($t) => Thread::enrichThreadAuthor($t), $threads));
return new DataResponse(array_map(fn ($t) => Thread::enrichThread($t), $threads));
} catch (\Exception $e) {
$this->logger->error('Error fetching threads: ' . $e->getMessage());
return new DataResponse(['error' => 'Failed to fetch threads'], Http::STATUS_INTERNAL_SERVER_ERROR);
@@ -64,7 +64,7 @@ class ThreadController extends OCSController {
public function byCategory(int $categoryId, int $limit = 50, int $offset = 0): DataResponse {
try {
$threads = $this->threadMapper->findByCategoryId($categoryId, $limit, $offset);
return new DataResponse(array_map(fn ($t) => Thread::enrichThreadAuthor($t), $threads));
return new DataResponse(array_map(fn ($t) => Thread::enrichThread($t), $threads));
} catch (\Exception $e) {
$this->logger->error('Error fetching threads by category: ' . $e->getMessage());
return new DataResponse(['error' => 'Failed to fetch threads'], Http::STATUS_INTERNAL_SERVER_ERROR);
@@ -90,7 +90,7 @@ class ThreadController extends OCSController {
/** @var \OCA\Forum\Db\Thread */
$thread = $this->threadMapper->update($thread);
return new DataResponse(Thread::enrichThreadAuthor($thread));
return new DataResponse(Thread::enrichThread($thread));
} catch (DoesNotExistException $e) {
return new DataResponse(['error' => 'Thread not found'], Http::STATUS_NOT_FOUND);
} catch (\Exception $e) {
@@ -118,7 +118,7 @@ class ThreadController extends OCSController {
/** @var \OCA\Forum\Db\Thread */
$thread = $this->threadMapper->update($thread);
return new DataResponse(Thread::enrichThreadAuthor($thread));
return new DataResponse(Thread::enrichThread($thread));
} catch (DoesNotExistException $e) {
return new DataResponse(['error' => 'Thread not found'], Http::STATUS_NOT_FOUND);
} catch (\Exception $e) {