mirror of
https://github.com/chenasraf/nextcloud-forum.git
synced 2026-05-18 01:28:58 +00:00
feat: current user endpoint, routing fixes
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user