diff options
-rw-r--r-- | appinfo/routes.php | 2 | ||||
-rw-r--r-- | lib/Controller/ItemController.php | 8 | ||||
-rw-r--r-- | lib/Db/Item.php | 1 | ||||
-rw-r--r-- | lib/Service/ItemServiceV2.php | 1 | ||||
-rw-r--r-- | lib/Service/ShareService.php | 11 | ||||
-rw-r--r-- | tests/Unit/Db/ItemMapperPaginatedTest.php | 1 | ||||
-rw-r--r-- | tests/Unit/Db/ItemMapperTest.php | 6 | ||||
-rw-r--r-- | tests/Unit/Service/ItemServiceTest.php | 3 | ||||
-rw-r--r-- | tests/Unit/Service/ShareServiceTest.php | 4 |
9 files changed, 13 insertions, 24 deletions
diff --git a/appinfo/routes.php b/appinfo/routes.php index 534f37540..b938d4fb5 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -52,7 +52,7 @@ return ['routes' => [ ['name' => 'item#read', 'url' => '/items/{itemId}/read', 'verb' => 'POST'], ['name' => 'item#read_multiple', 'url' => '/items/read/multiple', 'verb' => 'POST'], ['name' => 'item#star', 'url' => '/items/{feedId}/{guidHash}/star', 'verb' => 'POST'], -['name' => 'item#share', 'url' => '/items/{itemId}/share/{shareWithId}', 'verb' => 'POST'], +['name' => 'item#share', 'url' => '/items/{itemId}/share/{shareRecipientId}', 'verb' => 'POST'], // export ['name' => 'export#opml', 'url' => '/export/opml', 'verb' => 'GET'], diff --git a/lib/Controller/ItemController.php b/lib/Controller/ItemController.php index ec56a9e33..a437bf3ff 100644 --- a/lib/Controller/ItemController.php +++ b/lib/Controller/ItemController.php @@ -330,16 +330,16 @@ class ItemController extends Controller /** * @NoAdminRequired * - * @param int $itemId Item to share - * @param string $shareWithId User to share with + * @param int $itemId Item to share + * @param string $shareRecipientId User to share the item with */ - public function share($itemId, $shareWithId) + public function share($itemId, $shareRecipientId) { try { $this->shareService->shareItemWithUser( $this->getUserId(), $itemId, - $shareWithId + $shareRecipientId ); } catch (ServiceNotFoundException $ex) { return $this->error($ex, Http::STATUS_NOT_FOUND); diff --git a/lib/Db/Item.php b/lib/Db/Item.php index 730e387d1..411428e96 100644 --- a/lib/Db/Item.php +++ b/lib/Db/Item.php @@ -70,7 +70,6 @@ class Item extends Entity implements IAPI, \JsonSerializable /** @var string */ protected $sharedBy; - public function __construct() { $this->addType('contentHash', 'string'); diff --git a/lib/Service/ItemServiceV2.php b/lib/Service/ItemServiceV2.php index 3b1a81400..57804a8c3 100644 --- a/lib/Service/ItemServiceV2.php +++ b/lib/Service/ItemServiceV2.php @@ -295,7 +295,6 @@ class ItemServiceV2 extends Service return $this->mapper->findAllInFolderAfter($userId, $folderId, $updatedSince, $hideRead); } - /** * Returns all new items of a type * diff --git a/lib/Service/ShareService.php b/lib/Service/ShareService.php index e88675a21..395cd17d8 100644 --- a/lib/Service/ShareService.php +++ b/lib/Service/ShareService.php @@ -73,25 +73,22 @@ class ShareService * The item is then placed in a dummy feed reserved for items * shared with the user * - * @return Item + * @return Item Shared item * @throws ServiceNotFoundException|ServiceConflictException */ public function shareItemWithUser(string $userId, int $itemId, string $shareRecipientId) { - // find item to share + // Find item to share $item = $this->itemService->find($userId, $itemId); - // duplicate the item + // Duplicate item & initialize fields $sharedItem = clone $item; - - // initialize fields $sharedItem->setId(null); $sharedItem->setUnread(true); $sharedItem->setStarred(false); $sharedItem->setSharedBy($userId); - // get 'shared with me' dummy feed - // TODO: move to feedService->createSharedWithMeFeed() ? + // Get 'shared with me' dummy feed $feedUrl = 'http://nextcloud/sharedwithme'; $feed = $this->feedService->findByUrl($shareRecipientId, $feedUrl); if (is_null($feed)) { diff --git a/tests/Unit/Db/ItemMapperPaginatedTest.php b/tests/Unit/Db/ItemMapperPaginatedTest.php index e0625aa0c..330eaff51 100644 --- a/tests/Unit/Db/ItemMapperPaginatedTest.php +++ b/tests/Unit/Db/ItemMapperPaginatedTest.php @@ -1286,4 +1286,5 @@ class ItemMapperPaginatedTest extends MapperTestUtility $result = $this->class->findAllFolder('jack', 2, 10, 10, false, false, ['key', 'word']); $this->assertEquals([Item::fromRow(['id' => 4])], $result); } + } diff --git a/tests/Unit/Db/ItemMapperTest.php b/tests/Unit/Db/ItemMapperTest.php index ba73d93b8..5cb42c3fa 100644 --- a/tests/Unit/Db/ItemMapperTest.php +++ b/tests/Unit/Db/ItemMapperTest.php @@ -388,11 +388,7 @@ class ItemMapperTest extends MapperTestUtility $this->builder->expects($this->exactly(3)) ->method('andWhere') - ->withConsecutive( - ['feeds.user_id = :user_id'], - ['feeds.id = :feed_id'], - ['items.guid_hash = :guid_hash'] - ) + ->withConsecutive(['feeds.user_id = :user_id'], ['feeds.id = :feed_id'], ['items.guid_hash = :guid_hash']) ->will($this->returnSelf()); $this->builder->expects($this->exactly(3)) diff --git a/tests/Unit/Service/ItemServiceTest.php b/tests/Unit/Service/ItemServiceTest.php index b1cbe6d8d..f91692cda 100644 --- a/tests/Unit/Service/ItemServiceTest.php +++ b/tests/Unit/Service/ItemServiceTest.php @@ -41,7 +41,6 @@ class ItemServiceTest extends TestCase * @var MockObject|ItemMapperV2 */ private $mapper; - /** * @var ItemServiceV2 */ @@ -71,7 +70,6 @@ class ItemServiceTest extends TestCase $this->mapper = $this->getMockBuilder(ItemMapperV2::class) ->disableOriginalConstructor() ->getMock(); - $this->config = $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor() ->getMock(); @@ -631,4 +629,5 @@ class ItemServiceTest extends TestCase $this->class->purgeOverThreshold(5); } + } diff --git a/tests/Unit/Service/ShareServiceTest.php b/tests/Unit/Service/ShareServiceTest.php index 4c74e39a5..06359d572 100644 --- a/tests/Unit/Service/ShareServiceTest.php +++ b/tests/Unit/Service/ShareServiceTest.php @@ -107,8 +107,7 @@ class ShareServiceTest extends TestCase // Shared item $sharedItem = clone $item; - $sharedItem - ->setUnread(1) // A newly shared item is unread, ... + $sharedItem->setUnread(1) // A newly shared item is unread, ... ->setStarred(0) // ... not starred, ... ->setFeedId(100) // ... placed in the 'Shared with me' feed, ... ->setSharedBy($this->uid); // ... and contains the senders user ID @@ -190,7 +189,6 @@ class ShareServiceTest extends TestCase ->with($this->recipient, $feedUrl) ->will($this->returnValue(null)); - // TODO: Test if the feed is properly created $this->feedService->expects($this->once()) ->method('insert') ->will($this->returnValue($feed)); |