mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-25 18:45:27 -06:00
Merge pull request #1415 from acelaya-forks/feature/yourls-domain
Feature/yourls domain
This commit is contained in:
commit
efb604a381
@ -6,7 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
### Added
|
### Added
|
||||||
* *Nothing*
|
* [#1294](https://github.com/shlinkio/shlink/issues/1294) Allowed to specify a specific domain when importing URLs from YOURLS.
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
* [#1359](https://github.com/shlinkio/shlink/issues/1359) Hidden database commands.
|
* [#1359](https://github.com/shlinkio/shlink/issues/1359) Hidden database commands.
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
"shlinkio/shlink-common": "^4.4",
|
"shlinkio/shlink-common": "^4.4",
|
||||||
"shlinkio/shlink-config": "^1.6",
|
"shlinkio/shlink-config": "^1.6",
|
||||||
"shlinkio/shlink-event-dispatcher": "^2.3",
|
"shlinkio/shlink-event-dispatcher": "^2.3",
|
||||||
"shlinkio/shlink-importer": "^2.5",
|
"shlinkio/shlink-importer": "dev-main#75d50f9 as 3.0",
|
||||||
"shlinkio/shlink-installer": "dev-develop#d02f256 as 7.1",
|
"shlinkio/shlink-installer": "dev-develop#d02f256 as 7.1",
|
||||||
"shlinkio/shlink-ip-geolocation": "^2.2",
|
"shlinkio/shlink-ip-geolocation": "^2.2",
|
||||||
"symfony/console": "^6.0",
|
"symfony/console": "^6.0",
|
||||||
|
@ -13,6 +13,7 @@ use Shlinkio\Shlink\Core\ShortUrl\Resolver\ShortUrlRelationResolverInterface;
|
|||||||
use Shlinkio\Shlink\Core\Util\DoctrineBatchHelperInterface;
|
use Shlinkio\Shlink\Core\Util\DoctrineBatchHelperInterface;
|
||||||
use Shlinkio\Shlink\Importer\ImportedLinksProcessorInterface;
|
use Shlinkio\Shlink\Importer\ImportedLinksProcessorInterface;
|
||||||
use Shlinkio\Shlink\Importer\Model\ImportedShlinkUrl;
|
use Shlinkio\Shlink\Importer\Model\ImportedShlinkUrl;
|
||||||
|
use Shlinkio\Shlink\Importer\Params\ImportParams;
|
||||||
use Shlinkio\Shlink\Importer\Sources\ImportSources;
|
use Shlinkio\Shlink\Importer\Sources\ImportSources;
|
||||||
use Symfony\Component\Console\Style\StyleInterface;
|
use Symfony\Component\Console\Style\StyleInterface;
|
||||||
|
|
||||||
@ -34,10 +35,10 @@ class ImportedLinksProcessor implements ImportedLinksProcessorInterface
|
|||||||
/**
|
/**
|
||||||
* @param iterable|ImportedShlinkUrl[] $shlinkUrls
|
* @param iterable|ImportedShlinkUrl[] $shlinkUrls
|
||||||
*/
|
*/
|
||||||
public function process(StyleInterface $io, iterable $shlinkUrls, array $params): void
|
public function process(StyleInterface $io, iterable $shlinkUrls, ImportParams $params): void
|
||||||
{
|
{
|
||||||
$importShortCodes = $params['import_short_codes'];
|
$importShortCodes = $params->importShortCodes();
|
||||||
$source = $params['source'];
|
$source = $params->source();
|
||||||
$iterable = $this->batchHelper->wrapIterable($shlinkUrls, $source === ImportSources::SHLINK ? 10 : 100);
|
$iterable = $this->batchHelper->wrapIterable($shlinkUrls, $source === ImportSources::SHLINK ? 10 : 100);
|
||||||
|
|
||||||
/** @var ImportedShlinkUrl $importedUrl */
|
/** @var ImportedShlinkUrl $importedUrl */
|
||||||
|
@ -20,6 +20,7 @@ use Shlinkio\Shlink\Core\ShortUrl\Resolver\SimpleShortUrlRelationResolver;
|
|||||||
use Shlinkio\Shlink\Core\Util\DoctrineBatchHelperInterface;
|
use Shlinkio\Shlink\Core\Util\DoctrineBatchHelperInterface;
|
||||||
use Shlinkio\Shlink\Importer\Model\ImportedShlinkUrl;
|
use Shlinkio\Shlink\Importer\Model\ImportedShlinkUrl;
|
||||||
use Shlinkio\Shlink\Importer\Model\ImportedShlinkVisit;
|
use Shlinkio\Shlink\Importer\Model\ImportedShlinkVisit;
|
||||||
|
use Shlinkio\Shlink\Importer\Params\ImportParams;
|
||||||
use Shlinkio\Shlink\Importer\Sources\ImportSources;
|
use Shlinkio\Shlink\Importer\Sources\ImportSources;
|
||||||
use Symfony\Component\Console\Style\StyleInterface;
|
use Symfony\Component\Console\Style\StyleInterface;
|
||||||
|
|
||||||
@ -32,8 +33,6 @@ class ImportedLinksProcessorTest extends TestCase
|
|||||||
{
|
{
|
||||||
use ProphecyTrait;
|
use ProphecyTrait;
|
||||||
|
|
||||||
private const PARAMS = ['import_short_codes' => true, 'source' => ImportSources::BITLY];
|
|
||||||
|
|
||||||
private ImportedLinksProcessor $processor;
|
private ImportedLinksProcessor $processor;
|
||||||
private ObjectProphecy $em;
|
private ObjectProphecy $em;
|
||||||
private ObjectProphecy $shortCodeHelper;
|
private ObjectProphecy $shortCodeHelper;
|
||||||
@ -74,7 +73,7 @@ class ImportedLinksProcessorTest extends TestCase
|
|||||||
$ensureUniqueness = $this->shortCodeHelper->ensureShortCodeUniqueness(Argument::cetera())->willReturn(true);
|
$ensureUniqueness = $this->shortCodeHelper->ensureShortCodeUniqueness(Argument::cetera())->willReturn(true);
|
||||||
$persist = $this->em->persist(Argument::type(ShortUrl::class));
|
$persist = $this->em->persist(Argument::type(ShortUrl::class));
|
||||||
|
|
||||||
$this->processor->process($this->io->reveal(), $urls, self::PARAMS);
|
$this->processor->process($this->io->reveal(), $urls, $this->buildParams());
|
||||||
|
|
||||||
$importedUrlExists->shouldHaveBeenCalledTimes($expectedCalls);
|
$importedUrlExists->shouldHaveBeenCalledTimes($expectedCalls);
|
||||||
$ensureUniqueness->shouldHaveBeenCalledTimes($expectedCalls);
|
$ensureUniqueness->shouldHaveBeenCalledTimes($expectedCalls);
|
||||||
@ -104,7 +103,7 @@ class ImportedLinksProcessorTest extends TestCase
|
|||||||
$ensureUniqueness = $this->shortCodeHelper->ensureShortCodeUniqueness(Argument::cetera())->willReturn(true);
|
$ensureUniqueness = $this->shortCodeHelper->ensureShortCodeUniqueness(Argument::cetera())->willReturn(true);
|
||||||
$persist = $this->em->persist(Argument::type(ShortUrl::class));
|
$persist = $this->em->persist(Argument::type(ShortUrl::class));
|
||||||
|
|
||||||
$this->processor->process($this->io->reveal(), $urls, self::PARAMS);
|
$this->processor->process($this->io->reveal(), $urls, $this->buildParams());
|
||||||
|
|
||||||
$importedUrlExists->shouldHaveBeenCalledTimes(count($urls));
|
$importedUrlExists->shouldHaveBeenCalledTimes(count($urls));
|
||||||
$ensureUniqueness->shouldHaveBeenCalledTimes(2);
|
$ensureUniqueness->shouldHaveBeenCalledTimes(2);
|
||||||
@ -141,7 +140,7 @@ class ImportedLinksProcessorTest extends TestCase
|
|||||||
});
|
});
|
||||||
$persist = $this->em->persist(Argument::type(ShortUrl::class));
|
$persist = $this->em->persist(Argument::type(ShortUrl::class));
|
||||||
|
|
||||||
$this->processor->process($this->io->reveal(), $urls, self::PARAMS);
|
$this->processor->process($this->io->reveal(), $urls, $this->buildParams());
|
||||||
|
|
||||||
$importedUrlExists->shouldHaveBeenCalledTimes(count($urls));
|
$importedUrlExists->shouldHaveBeenCalledTimes(count($urls));
|
||||||
$failingEnsureUniqueness->shouldHaveBeenCalledTimes(5);
|
$failingEnsureUniqueness->shouldHaveBeenCalledTimes(5);
|
||||||
@ -167,7 +166,7 @@ class ImportedLinksProcessorTest extends TestCase
|
|||||||
$persistUrl = $this->em->persist(Argument::type(ShortUrl::class));
|
$persistUrl = $this->em->persist(Argument::type(ShortUrl::class));
|
||||||
$persistVisits = $this->em->persist(Argument::type(Visit::class));
|
$persistVisits = $this->em->persist(Argument::type(Visit::class));
|
||||||
|
|
||||||
$this->processor->process($this->io->reveal(), [$importedUrl], self::PARAMS);
|
$this->processor->process($this->io->reveal(), [$importedUrl], $this->buildParams());
|
||||||
|
|
||||||
$findExisting->shouldHaveBeenCalledOnce();
|
$findExisting->shouldHaveBeenCalledOnce();
|
||||||
$ensureUniqueness->shouldHaveBeenCalledTimes($foundShortUrl === null ? 1 : 0);
|
$ensureUniqueness->shouldHaveBeenCalledTimes($foundShortUrl === null ? 1 : 0);
|
||||||
@ -214,4 +213,12 @@ class ImportedLinksProcessorTest extends TestCase
|
|||||||
])),
|
])),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function buildParams(): ImportParams
|
||||||
|
{
|
||||||
|
return ImportParams::fromSourceAndCallableMap(
|
||||||
|
ImportSources::BITLY,
|
||||||
|
['import_short_codes' => static fn () => true],
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user