mirror of
https://github.com/nextcloud/server.git
synced 2026-04-24 23:59:27 -04:00
Merge pull request #58836 from nextcloud/feat/noid/unify-generated-by-ai-tag-handling
feat(systemtags): Add methods to directly do "Generated by AI" tag
This commit is contained in:
commit
a304a54775
5 changed files with 37 additions and 0 deletions
|
|
@ -150,6 +150,15 @@ class SystemTagManager implements ISystemTagManager {
|
|||
return $this->createSystemTagFromRow($row);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function getGeneratedByAITag(): ISystemTag {
|
||||
try {
|
||||
return $this->getTag(ISystemTag::GENERATED_BY_AI, true, true);
|
||||
} catch (TagNotFoundException) {
|
||||
return $this->createTag(ISystemTag::GENERATED_BY_AI, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
public function createTag(string $tagName, bool $userVisible, bool $userAssignable): ISystemTag {
|
||||
$user = $this->userSession->getUser();
|
||||
if (!$this->canUserCreateTag($user)) {
|
||||
|
|
|
|||
|
|
@ -176,6 +176,12 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper {
|
|||
$this->dispatcher->dispatchTyped(new TagAssignedEvent($objectType, [$objId], $tagsAssigned));
|
||||
}
|
||||
|
||||
#[Override]
|
||||
public function assignGeneratedByAITag(string $objId, string $objectType) {
|
||||
$tag = $this->tagManager->getGeneratedByAITag();
|
||||
$this->assignTags($objId, $objectType, [$tag->getId()]);
|
||||
}
|
||||
|
||||
#[Override]
|
||||
public function unassignTags(string $objId, string $objectType, $tagIds): void {
|
||||
if (!\is_array($tagIds)) {
|
||||
|
|
|
|||
|
|
@ -36,6 +36,11 @@ interface ISystemTag {
|
|||
ISystemTag::ACCESS_LEVEL_INVISIBLE => 'invisible',
|
||||
];
|
||||
|
||||
/**
|
||||
* @since 34.0.0
|
||||
*/
|
||||
public const GENERATED_BY_AI = 'Generated by AI';
|
||||
|
||||
/**
|
||||
* Returns the tag id
|
||||
*
|
||||
|
|
|
|||
|
|
@ -47,6 +47,14 @@ interface ISystemTagManager {
|
|||
*/
|
||||
public function getTag(string $tagName, bool $userVisible, bool $userAssignable): ISystemTag;
|
||||
|
||||
/**
|
||||
* Returns the tag object to mark AI generated content with
|
||||
*
|
||||
* @return ISystemTag system tag
|
||||
* @since 34.0.0
|
||||
*/
|
||||
public function getGeneratedByAITag(): ISystemTag;
|
||||
|
||||
/**
|
||||
* Creates the tag object using the given attributes.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -81,6 +81,15 @@ interface ISystemTagObjectMapper {
|
|||
*/
|
||||
public function assignTags(string $objId, string $objectType, $tagIds);
|
||||
|
||||
/**
|
||||
* Assign the "Generated by AI" tag to the given object.
|
||||
*
|
||||
* @param string $objId object id
|
||||
* @param string $objectType object type
|
||||
* @since 34.0.0
|
||||
*/
|
||||
public function assignGeneratedByAITag(string $objId, string $objectType);
|
||||
|
||||
/**
|
||||
* Unassign the given tags from the given object.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in a new issue