Π·Π΅ΡΠΊΠ°Π»ΠΎ ΠΈΠ· https://github.com/nextcloud/news.git
π§Ή Cleanup code, remove spaces, rename variables
Signed-off-by: Marco Nassabain <marco.nassabain@hotmail.com>
This commit is contained in:
Π ΠΎΠ΄ΠΈΡΠ΅Π»Ρ
4612ed9bf0
ΠΠΎΠΌΠΌΠΈΡ
2cba1e4146
|
@ -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));
|
||||
|
|
ΠΠ°Π³ΡΡΠ·ΠΊΠ°β¦
Π‘ΡΡΠ»ΠΊΠ° Π² Π½ΠΎΠ²ΠΎΠΉ Π·Π°Π΄Π°ΡΠ΅