From e98af2ea1633bc948995c9f9ced8abfa3ce5bfd1 Mon Sep 17 00:00:00 2001 From: Ian Morland Date: Thu, 18 Mar 2021 22:33:54 +0000 Subject: [PATCH] Beta 16 --- composer.json | 6 +++--- extend.php | 3 ++- js/package-lock.json | 12 +++++++++--- js/package.json | 5 +++-- .../2019_09_15_000000_migrate_extension_settings.php | 2 +- src/Listeners/ReportSpammer.php | 5 +++-- src/Middleware/RegisterMiddleware.php | 6 +++--- 7 files changed, 24 insertions(+), 15 deletions(-) diff --git a/composer.json b/composer.json index fb021cb..f8caff2 100644 --- a/composer.json +++ b/composer.json @@ -20,8 +20,8 @@ } ], "require": { - "flarum/core": ">=0.1.0-beta.15", - "guzzlehttp/guzzle": "6.* || 7.*" + "flarum/core": "^0.1.0-beta.16", + "guzzlehttp/guzzle": "^7.2" }, "replace": { "reflar/stopforumspam": "*" @@ -46,7 +46,7 @@ "extra": { "flarum-extension": { "title": "FoF Stop Forum Spam", - "category": "moderation", + "category": "feature", "icon": { "name": "fas fa-stop", "backgroundColor": "#e74c3c", diff --git a/extend.php b/extend.php index 9201c93..962e593 100644 --- a/extend.php +++ b/extend.php @@ -24,5 +24,6 @@ (new Extend\Event()) ->listen(MarkedUserAsSpammer::class, Listeners\ReportSpammer::class), - (new Extend\Middleware('forum'))->add(RegisterMiddleware::class), + (new Extend\Middleware('forum')) + ->add(RegisterMiddleware::class), ]; diff --git a/js/package-lock.json b/js/package-lock.json index 6a3561b..e632d3b 100644 --- a/js/package-lock.json +++ b/js/package-lock.json @@ -2396,6 +2396,12 @@ "resolve-dir": "^1.0.1" } }, + "flarum": { + "version": "0.1.0-beta.16", + "resolved": "https://registry.npmjs.org/flarum/-/flarum-0.1.0-beta.16.tgz", + "integrity": "sha512-uovm+6J8TO35dfbTSRtHRH6tz71W4dnEDfB63NOKHIhOz8oRh65qyWpXtlBOjv9f1cFMkMcjGHbWetb5lAIEnQ==", + "dev": true + }, "flarum-webpack-config": { "version": "0.1.0-beta.10", "resolved": "https://registry.npmjs.org/flarum-webpack-config/-/flarum-webpack-config-0.1.0-beta.10.tgz", @@ -3389,9 +3395,9 @@ "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=" }, "prettier": { - "version": "1.19.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz", - "integrity": "sha1-99f1/4qc2HKnvkyhQglZVqYHl8s=", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.2.1.tgz", + "integrity": "sha512-PqyhM2yCjg/oKkFPtTGUojv7gnZAoG80ttl45O6x2Ug/rMJw4wcc9k6aaf2hibP7BGVCCM33gZoGjyvt9mm16Q==", "dev": true }, "process": { diff --git a/js/package.json b/js/package.json index bd020c1..4a11007 100644 --- a/js/package.json +++ b/js/package.json @@ -9,9 +9,10 @@ "scripts": { "build": "webpack --mode production", "dev": "webpack --mode development --watch", - "lint": "prettier --single-quote --trailing-comma es5 --print-width 150 --tab-width 4 --write src/**/* src/**/**/*" + "lint": "prettier --single-quote --trailing-comma es5 --print-width 150 --tab-width 4 --write src" }, "devDependencies": { - "prettier": "^1.19.1" + "flarum": "0.1.0-beta.16", + "prettier": "^2.2.1" } } diff --git a/migrations/2019_09_15_000000_migrate_extension_settings.php b/migrations/2019_09_15_000000_migrate_extension_settings.php index 2275e63..224c1d7 100644 --- a/migrations/2019_09_15_000000_migrate_extension_settings.php +++ b/migrations/2019_09_15_000000_migrate_extension_settings.php @@ -17,7 +17,7 @@ /** * @var SettingsRepositoryInterface */ - $settings = app('flarum.settings'); + $settings = resolve('flarum.settings'); $keys = ['username', 'email', 'ip', 'frequency', 'api_key']; foreach ($keys as $key) { diff --git a/src/Listeners/ReportSpammer.php b/src/Listeners/ReportSpammer.php index 3514f4e..e49e14d 100644 --- a/src/Listeners/ReportSpammer.php +++ b/src/Listeners/ReportSpammer.php @@ -15,6 +15,7 @@ use FoF\Spamblock\Event\MarkedUserAsSpammer; use FoF\StopForumSpam\StopForumSpam; use GuzzleHttp\Exception\RequestException; +use GuzzleHttp\Psr7\Message; class ReportSpammer { @@ -51,11 +52,11 @@ public function handle(MarkedUserAsSpammer $event) ]); } catch (RequestException $e) { throw new ValidationException([ - 'sfs' => strip_tags(RequestException::getResponseBodySummary($e->getResponse())), + 'sfs' => strip_tags(Message::bodySummary($e->getResponse())), ]); } catch (\Throwable $e) { throw new ValidationException([ - 'sfs' => app('translator')->trans('fof-stopforumspam.api.error.unknown'), + 'sfs' => resolve('translator')->trans('fof-stopforumspam.api.error.unknown'), ]); } } diff --git a/src/Middleware/RegisterMiddleware.php b/src/Middleware/RegisterMiddleware.php index 2f954e3..551a11c 100644 --- a/src/Middleware/RegisterMiddleware.php +++ b/src/Middleware/RegisterMiddleware.php @@ -70,7 +70,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface ]); } catch (\Throwable $e) { return (new JsonApiFormatter())->format( - app(Registry::class)->handle($e), + resolve(Registry::class)->handle($e), $request ); } @@ -88,9 +88,9 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface if ($frequency !== 0 && $frequency >= (int) $this->settings->get('fof-stopforumspam.frequency')) { return (new JsonApiFormatter()) ->format( - app(Registry::class) + resolve(Registry::class) ->handle(new ValidationException([ - 'username' => app('translator')->trans('fof-stopforumspam.forum.message.spam'), + 'username' => resolve('translator')->trans('fof-stopforumspam.forum.message.spam'), ])), $request );