-
Notifications
You must be signed in to change notification settings - Fork 28
feat: Add system tags to AI generated files #406
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| <?php | ||
|
|
||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /** | ||
| * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| namespace OCA\Assistant\Service; | ||
|
|
||
| use OCP\SystemTag\ISystemTagManager; | ||
| use OCP\SystemTag\ISystemTagObjectMapper; | ||
| use OCP\SystemTag\TagNotFoundException; | ||
|
|
||
| class SystemTagService { | ||
|
|
||
| public const AI_TAG_NAME = 'Generated using AI'; | ||
|
|
||
| public function __construct( | ||
| private ISystemTagManager $systemTagManager, | ||
| private ISystemTagObjectMapper $systemTagObjectMapper, | ||
| ) { | ||
| } | ||
|
|
||
| public function getAiTag() { | ||
| try { | ||
| return $this->systemTagManager->getTag(self::AI_TAG_NAME, true, true); | ||
| } catch (TagNotFoundException $e) { | ||
| return $this->systemTagManager->createTag(self::AI_TAG_NAME, true, true); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * @param string $fileId | ||
| * @return void | ||
| * @throws TagNotFoundException | ||
| */ | ||
| public function assignAiTagToFile(string $fileId) { | ||
| $this->systemTagObjectMapper->assignTags($fileId, 'files', $this->getAiTag()->getId()); | ||
|
Comment on lines
+27
to
+41
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. perhaps the tag can be created in a migration so we're sure it exists and then store the tag's ID in a config. It might be a little better to not create
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
can they be deleted by users? If yes, then ignore this review.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes :) |
||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.