Skip to content

Commit

Permalink
Update dependencies, remove laravel-cors package
Browse files Browse the repository at this point in the history
  • Loading branch information
Kovah committed Mar 16, 2023
1 parent ac0b471 commit f8f194a
Show file tree
Hide file tree
Showing 6 changed files with 1,357 additions and 1,254 deletions.
29 changes: 12 additions & 17 deletions app/Actions/ImportHtmlBookmarks.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ class ImportHtmlBookmarks
*/
public function run(string $data, string $userId, bool $generateMeta = true): bool
{
$parser = new NetscapeBookmarkParser(
defaultPub: usersettings('links_private_default'),
logDir: storage_path('logs')
);
$parser = new NetscapeBookmarkParser(logger: Log::getLogger());

try {
$links = $parser->parseString($data);
Expand All @@ -44,38 +41,36 @@ public function run(string $data, string $userId, bool $generateMeta = true): bo
}

foreach ($links as $link) {
if (Link::whereUrl($link['uri'])->first()) {
if (Link::whereUrl($link['url'])->first()) {
$this->skipped++;
continue;
}

if ($generateMeta) {
$linkMeta = (new HtmlMeta)->getFromUrl($link['uri']);
$title = $link['title'] ?: $linkMeta['title'];
$description = $link['note'] ?: $linkMeta['description'];
$linkMeta = (new HtmlMeta)->getFromUrl($link['url']);
$title = $link['name'] ?: $linkMeta['title'];
$description = $link['description'] ?: $linkMeta['description'];
} else {
$title = $link['title'];
$description = $link['note'];
$title = $link['name'];
$description = $link['description'];
}

$newLink = new Link([
'user_id' => $userId,
'url' => $link['uri'],
'url' => $link['url'],
'title' => $title,
'description' => $description,
'icon' => LinkIconMapper::mapLink($link['uri']),
'is_private' => $link['pub']
'icon' => LinkIconMapper::mapLink($link['url']),
'is_private' => usersettings('tags_private_default') === '1' ? true : $link['public'],
]);
$newLink->created_at = Carbon::createFromTimestamp($link['time']);
$newLink->created_at = Carbon::createFromTimestamp($link['dateCreated']);
$newLink->updated_at = Carbon::now();
$newLink->timestamps = false;
$newLink->save();

if (!empty($link['tags'])) {
$tags = explode(' ', $link['tags']);

$newTags = [];
foreach ($tags as $tag) {
foreach ($link['tags'] as $tag) {
$newTag = Tag::firstOrCreate([
'user_id' => $userId,
'name' => $tag,
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Kernel extends HttpKernel
*/
protected $middleware = [
\App\Http\Middleware\TrustProxies::class,
\Fruitcake\Cors\HandleCors::class,
\Illuminate\Http\Middleware\HandleCors::class,
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
Expand Down
15 changes: 7 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
"type": "project",
"require": {
"php": "^8.0.2 | ^8.1 | ^8.2",
"composer/semver": "^1.5",
"doctrine/dbal": "^2.10.2",
"composer/semver": "^3.3.2",
"doctrine/dbal": "^3.6.1",
"fideloper/proxy": "^4.4",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
"kovah/laravel-html-meta": "^2.0",
"laracasts/flash": "^3.1",
Expand All @@ -18,10 +17,10 @@
"league/flysystem-aws-s3-v3": "^3.0",
"league/flysystem-ftp": "^3.0",
"league/flysystem-sftp-v3": "^3.0",
"predis/predis": "^1.1",
"predis/predis": "^v2.1",
"rap2hpoutre/laravel-log-viewer": "^v2.2.0",
"sentry/sentry-laravel": "^2.3",
"shaarli/netscape-bookmark-parser": "^2.1",
"sentry/sentry-laravel": "^3.3.0",
"shaarli/netscape-bookmark-parser": "^v4.0",
"spatie/laravel-backup": "^8.1.5",
"symfony/http-client": "^6.0",
"symfony/mailgun-mailer": "^6.0",
Expand All @@ -33,8 +32,8 @@
"barryvdh/laravel-ide-helper": "^2.6",
"spatie/laravel-ignition": "^1.6",
"fakerphp/faker": "^1.12",
"laravel/tinker": "^2.2.0",
"mockery/mockery": "1.3.*",
"laravel/tinker": "^2.2",
"mockery/mockery": "^1.5",
"nunomaduro/collision": "^6.1",
"phpunit/phpunit": "^9.0",
"roave/security-advisories": "dev-latest",
Expand Down
Loading

0 comments on commit f8f194a

Please sign in to comment.