-
Notifications
You must be signed in to change notification settings - Fork 577
feat(sidebar): Add conversation sections and sort options #17368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Rikdekker
wants to merge
14
commits into
nextcloud:main
from
Rikdekker:feat/conversation-sections-and-sort
Closed
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
e81d3db
feat(sidebar): Add conversation sections and sort options
Rikdekker dd4c6a6
chore(openapi): Regenerate OpenAPI specs and TypeScript types
Rikdekker b45ec0a
fix: Resolve TypeScript errors in ConversationsListVirtual
Rikdekker 21491d3
fix: Resolve ESLint errors and mock fetchSections in tests
Rikdekker 9f37951
fix: Restore app version and add section_id to test data
Rikdekker 224cbd8
fix: Set correct Nextcloud version compatibility for main branch
Rikdekker d16f08f
fix: Add userId parameter to prevent IDOR in section mapper
Rikdekker 436ea71
fix: Use Snowflake ID for conversation section primary key
Rikdekker 520241b
fix: Remove standalone docs, revert CHANGELOG, move capabilities to v24
Rikdekker c6fee92
feat(sidebar): Address PR review feedback for conversation categories
Rikdekker 81842fe
fix: Address CI failures (php-cs, psalm, CapabilitiesTest)
Rikdekker b37ee63
fix: Address remaining CI failures (psalm type hint, AttendeeMapper w…
Rikdekker 05ba925
fix: Address PR review feedback from Antreesy
Rikdekker c540c91
fix: Address CI failures (openapi, psalm, test, types)
Rikdekker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,154 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /** | ||
| * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| namespace OCA\Talk\Controller; | ||
|
|
||
| use OCA\Talk\Model\ConversationCategory; | ||
| use OCA\Talk\ResponseDefinitions; | ||
| use OCA\Talk\Service\ConversationCategoryService; | ||
| use OCP\AppFramework\Db\DoesNotExistException; | ||
| use OCP\AppFramework\Http; | ||
| use OCP\AppFramework\Http\Attribute\ApiRoute; | ||
| use OCP\AppFramework\Http\Attribute\NoAdminRequired; | ||
| use OCP\AppFramework\Http\DataResponse; | ||
| use OCP\AppFramework\OCSController; | ||
| use OCP\IRequest; | ||
|
|
||
| /** | ||
| * @psalm-import-type TalkConversationCategory from ResponseDefinitions | ||
| */ | ||
| class ConversationCategoryController extends OCSController { | ||
| public function __construct( | ||
| string $appName, | ||
| IRequest $request, | ||
| protected ConversationCategoryService $categoryService, | ||
| protected ?string $userId, | ||
| ) { | ||
| parent::__construct($appName, $request); | ||
| } | ||
|
|
||
| /** | ||
| * Get all conversation categories for the current user | ||
| * | ||
| * Required capability: `conversation-categories` | ||
| * | ||
| * @return DataResponse<Http::STATUS_OK, list<TalkConversationCategory>, array{}> | ||
| * | ||
| * 200: Categories returned | ||
| */ | ||
| #[NoAdminRequired] | ||
| #[ApiRoute(verb: 'GET', url: '/api/{apiVersion}/categories', requirements: [ | ||
| 'apiVersion' => '(v4)', | ||
| ])] | ||
| public function getCategories(): DataResponse { | ||
| $categories = $this->categoryService->getCategories($this->userId); | ||
| return new DataResponse(array_values(array_map([$this, 'formatCategory'], $categories))); | ||
| } | ||
|
|
||
| /** | ||
| * Create a new conversation category | ||
| * | ||
| * Required capability: `conversation-categories` | ||
| * | ||
| * @param string $name Name of the category | ||
| * @return DataResponse<Http::STATUS_CREATED, TalkConversationCategory, array{}> | ||
| * | ||
| * 201: Category created | ||
| */ | ||
| #[NoAdminRequired] | ||
| #[ApiRoute(verb: 'POST', url: '/api/{apiVersion}/categories', requirements: [ | ||
| 'apiVersion' => '(v4)', | ||
| ])] | ||
| public function createCategory(string $name): DataResponse { | ||
| $category = $this->categoryService->createCategory($this->userId, $name); | ||
| return new DataResponse($this->formatCategory($category), Http::STATUS_CREATED); | ||
| } | ||
|
|
||
| /** | ||
| * Update a conversation category | ||
| * | ||
| * Required capability: `conversation-categories` | ||
| * | ||
| * @param int $categoryId ID of the category | ||
| * @param string $name New name for the category | ||
| * @return DataResponse<Http::STATUS_OK, TalkConversationCategory, array{}>|DataResponse<Http::STATUS_NOT_FOUND, null, array{}> | ||
| * | ||
| * 200: Category updated | ||
| * 404: Category not found | ||
| */ | ||
| #[NoAdminRequired] | ||
| #[ApiRoute(verb: 'PUT', url: '/api/{apiVersion}/categories/{categoryId}', requirements: [ | ||
| 'apiVersion' => '(v4)', | ||
| 'categoryId' => '\d+', | ||
| ])] | ||
| public function updateCategory(int $categoryId, string $name): DataResponse { | ||
| try { | ||
| $category = $this->categoryService->updateCategory($categoryId, $this->userId, $name); | ||
| return new DataResponse($this->formatCategory($category)); | ||
| } catch (DoesNotExistException) { | ||
| return new DataResponse(null, Http::STATUS_NOT_FOUND); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Delete a conversation category | ||
| * | ||
| * Required capability: `conversation-categories` | ||
| * | ||
| * @param int $categoryId ID of the category | ||
| * @return DataResponse<Http::STATUS_OK, null, array{}>|DataResponse<Http::STATUS_NOT_FOUND, null, array{}> | ||
| * | ||
| * 200: Category deleted | ||
| * 404: Category not found | ||
| */ | ||
| #[NoAdminRequired] | ||
| #[ApiRoute(verb: 'DELETE', url: '/api/{apiVersion}/categories/{categoryId}', requirements: [ | ||
| 'apiVersion' => '(v4)', | ||
| 'categoryId' => '\d+', | ||
| ])] | ||
| public function deleteCategory(int $categoryId): DataResponse { | ||
| try { | ||
| $this->categoryService->deleteCategory($categoryId, $this->userId); | ||
| return new DataResponse(null); | ||
| } catch (DoesNotExistException) { | ||
| return new DataResponse(null, Http::STATUS_NOT_FOUND); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Reorder conversation categories | ||
| * | ||
| * Required capability: `conversation-categories` | ||
| * | ||
| * @param list<int> $orderedIds Ordered list of category IDs | ||
| * @return DataResponse<Http::STATUS_OK, list<TalkConversationCategory>, array{}> | ||
| * | ||
| * 200: Categories reordered | ||
| */ | ||
| #[NoAdminRequired] | ||
| #[ApiRoute(verb: 'PUT', url: '/api/{apiVersion}/categories/reorder', requirements: [ | ||
| 'apiVersion' => '(v4)', | ||
| ])] | ||
| public function reorderCategories(array $orderedIds): DataResponse { | ||
| $this->categoryService->reorderCategories($this->userId, $orderedIds); | ||
| $categories = $this->categoryService->getCategories($this->userId); | ||
| return new DataResponse(array_values(array_map([$this, 'formatCategory'], $categories))); | ||
| } | ||
|
|
||
| /** | ||
| * @return TalkConversationCategory | ||
| */ | ||
| protected function formatCategory(ConversationCategory $category): array { | ||
| return [ | ||
| 'id' => (string)$category->getId(), | ||
| 'name' => $category->getName(), | ||
| 'sortOrder' => $category->getSortOrder(), | ||
| ]; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /** | ||
| * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| namespace OCA\Talk\Migration; | ||
|
|
||
| use Closure; | ||
| use OCP\DB\ISchemaWrapper; | ||
| use OCP\DB\Types; | ||
| use OCP\Migration\IOutput; | ||
| use OCP\Migration\SimpleMigrationStep; | ||
| use Override; | ||
|
|
||
| class Version24000Date20260313120000 extends SimpleMigrationStep { | ||
| /** | ||
| * @param IOutput $output | ||
| * @param Closure(): ISchemaWrapper $schemaClosure | ||
| * @param array $options | ||
| * @return null|ISchemaWrapper | ||
| */ | ||
| #[Override] | ||
| public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { | ||
| /** @var ISchemaWrapper $schema */ | ||
| $schema = $schemaClosure(); | ||
|
|
||
| if (!$schema->hasTable('talk_conversation_categories')) { | ||
| $table = $schema->createTable('talk_conversation_categories'); | ||
| $table->addColumn('id', Types::BIGINT, [ | ||
| 'notnull' => true, | ||
| 'unsigned' => true, | ||
| 'length' => 20, | ||
| ]); | ||
| $table->addColumn('user_id', Types::STRING, [ | ||
| 'notnull' => true, | ||
| 'length' => 64, | ||
| ]); | ||
| $table->addColumn('name', Types::STRING, [ | ||
| 'notnull' => true, | ||
| 'length' => 255, | ||
| ]); | ||
| $table->addColumn('sort_order', Types::INTEGER, [ | ||
| 'notnull' => true, | ||
| 'default' => 0, | ||
| ]); | ||
| $table->addColumn('collapsed', Types::BOOLEAN, [ | ||
| 'notnull' => false, | ||
| 'default' => 0, | ||
| ]); | ||
| $table->setPrimaryKey(['id']); | ||
| $table->addIndex(['user_id'], 'tcs_user_id'); | ||
| } | ||
|
|
||
| $attendeesTable = $schema->getTable('talk_attendees'); | ||
| if (!$attendeesTable->hasColumn('category_ids')) { | ||
| $attendeesTable->addColumn('category_ids', Types::TEXT, [ | ||
| 'notnull' => false, | ||
| 'default' => null, | ||
| ]); | ||
| } | ||
|
|
||
| return $schema; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.