Signed-off-by: Marco Nassabain <marco.nassabain@hotmail.com>
This commit is contained in:
Marco Nassabain 2021-03-05 22:14:56 +01:00 ΠΊΠΎΠΌΠΌΠΈΡ‚ ΠΏΡ€ΠΎΠΈΠ·Π²Ρ‘Π» Sean Molenaar
Π ΠΎΠ΄ΠΈΡ‚Π΅Π»ΡŒ 4612ed9bf0
ΠšΠΎΠΌΠΌΠΈΡ‚ 2cba1e4146
9 ΠΈΠ·ΠΌΠ΅Π½Ρ‘Π½Π½Ρ‹Ρ… Ρ„Π°ΠΉΠ»ΠΎΠ²: 13 Π΄ΠΎΠ±Π°Π²Π»Π΅Π½ΠΈΠΉ ΠΈ 24 ΡƒΠ΄Π°Π»Π΅Π½ΠΈΠΉ

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -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'],

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -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);

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -70,7 +70,6 @@ class Item extends Entity implements IAPI, \JsonSerializable
/** @var string */
protected $sharedBy;
public function __construct()
{
$this->addType('contentHash', 'string');

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -295,7 +295,6 @@ class ItemServiceV2 extends Service
return $this->mapper->findAllInFolderAfter($userId, $folderId, $updatedSince, $hideRead);
}
/**
* Returns all new items of a type
*

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -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)) {

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -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);
}
}

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -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))

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -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);
}
}

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -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));