Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/private/SystemTag/SystemTagManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,15 @@ public function getTag(string $tagName, bool $userVisible, bool $userAssignable)
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)) {
Expand Down
6 changes: 6 additions & 0 deletions lib/private/SystemTag/SystemTagObjectMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@ public function assignTags(string $objId, string $objectType, $tagIds): void {
$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)) {
Expand Down
5 changes: 5 additions & 0 deletions lib/public/SystemTag/ISystemTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
8 changes: 8 additions & 0 deletions lib/public/SystemTag/ISystemTagManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ public function getTagsByIds($tagIds, ?IUser $user = null): array;
*/
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.
*
Expand Down
9 changes: 9 additions & 0 deletions lib/public/SystemTag/ISystemTagObjectMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ public function getObjectIdsForTags($tagIds, string $objectType, int $limit = 0,
*/
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.
*
Expand Down
Loading