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
5 changes: 2 additions & 3 deletions apps/files/lib/Service/TagService.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

namespace OCA\Files\Service;

use OC\Tags;
use OCA\Files\Activity\FavoriteProvider;
use OCP\Activity\IManager;
use OCP\Files\Folder;
Expand Down Expand Up @@ -92,14 +91,14 @@ public function updateFileTags($path, $tags) {

$newTags = array_diff($tags, $currentTags);
foreach ($newTags as $tag) {
if ($tag === Tags::TAG_FAVORITE) {
if ($tag === ITags::TAG_FAVORITE) {
$this->addActivity(true, $fileId, $path);
}
$this->tagger->tagAs($fileId, $tag);
}
$deletedTags = array_diff($currentTags, $tags);
foreach ($deletedTags as $tag) {
if ($tag === Tags::TAG_FAVORITE) {
if ($tag === ITags::TAG_FAVORITE) {
$this->addActivity(false, $fileId, $path);
}
$this->tagger->unTag($fileId, $tag);
Expand Down
4 changes: 2 additions & 2 deletions apps/files/tests/Service/TagServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@

namespace OCA\Files\Tests\Service;

use OC\Tags;
use OCA\Files\Service\TagService;
use OCP\Activity\IManager;
use OCP\ITags;
use OCP\IUser;
use OCP\IUserSession;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
Expand Down Expand Up @@ -172,7 +172,7 @@ public function testFavoriteActivity() {
);

// set tags
$this->tagService->updateFileTags('subdir/test.txt', [Tags::TAG_FAVORITE]);
$this->tagService->updateFileTags('subdir/test.txt', [ITags::TAG_FAVORITE]);

// remove tag
$this->tagService->updateFileTags('subdir/test.txt', []);
Expand Down
19 changes: 9 additions & 10 deletions lib/private/Tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@
use OC\Tagging\TagMapper;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\ILogger;
use OCP\ITags;

class Tags implements \OCP\ITags {
class Tags implements ITags {

/**
* Tags
Expand Down Expand Up @@ -112,8 +113,6 @@ class Tags implements \OCP\ITags {
const TAG_TABLE = '*PREFIX*vcategory';
const RELATION_TABLE = '*PREFIX*vcategory_to_object';

const TAG_FAVORITE = '_$!<Favorite>!$_';

/**
* Constructor.
*
Expand Down Expand Up @@ -186,7 +185,7 @@ public function getTags() {
$tagMap = array();

foreach($this->tags as $tag) {
if($tag->getName() !== self::TAG_FAVORITE) {
if($tag->getName() !== ITags::TAG_FAVORITE) {
$tagMap[] = $this->tagMap($tag);
}
}
Expand Down Expand Up @@ -624,12 +623,12 @@ public function purgeObjects(array $ids) {
* @return array|false An array of object ids.
*/
public function getFavorites() {
if(!$this->userHasTag(self::TAG_FAVORITE, $this->user)) {
if(!$this->userHasTag(ITags::TAG_FAVORITE, $this->user)) {
return [];
}

try {
return $this->getIdsForTag(self::TAG_FAVORITE);
return $this->getIdsForTag(ITags::TAG_FAVORITE);
} catch(\Exception $e) {
\OC::$server->getLogger()->logException($e, [
'message' => __METHOD__,
Expand All @@ -647,10 +646,10 @@ public function getFavorites() {
* @return boolean
*/
public function addToFavorites($objid) {
if(!$this->userHasTag(self::TAG_FAVORITE, $this->user)) {
$this->add(self::TAG_FAVORITE);
if(!$this->userHasTag(ITags::TAG_FAVORITE, $this->user)) {
$this->add(ITags::TAG_FAVORITE);
}
return $this->tagAs($objid, self::TAG_FAVORITE);
return $this->tagAs($objid, ITags::TAG_FAVORITE);
}

/**
Expand All @@ -660,7 +659,7 @@ public function addToFavorites($objid) {
* @return boolean
*/
public function removeFromFavorites($objid) {
return $this->unTag($objid, self::TAG_FAVORITE);
return $this->unTag($objid, ITags::TAG_FAVORITE);
}

/**
Expand Down
4 changes: 4 additions & 0 deletions lib/public/ITags.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
*/

interface ITags {
/**
* @since 19.0.0
*/
public const TAG_FAVORITE = '_$!<Favorite>!$_';

/**
* Check if any tags are saved for this type and user.
Expand Down