From 5d63d9d848c5b9c2be0c64a66e03cea8edd96df8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20LEUILLIOT?= Date: Sat, 1 Jan 2022 16:16:39 +0100 Subject: [PATCH 01/34] feat: allow settings default to be defined --- src/Exceptions/EveImageException.php | 4 +- src/Exceptions/FilterException.php | 4 +- src/Exceptions/SettingException.php | 4 +- src/Settings/Profile.php | 26 ------- src/Settings/Seat.php | 105 --------------------------- src/Settings/Settings.php | 11 +++ 6 files changed, 20 insertions(+), 134 deletions(-) diff --git a/src/Exceptions/EveImageException.php b/src/Exceptions/EveImageException.php index fa244e95..d8ab39d2 100644 --- a/src/Exceptions/EveImageException.php +++ b/src/Exceptions/EveImageException.php @@ -22,6 +22,8 @@ namespace Seat\Services\Exceptions; -class EveImageException extends \Exception +use Exception; + +class EveImageException extends Exception { } diff --git a/src/Exceptions/FilterException.php b/src/Exceptions/FilterException.php index e849b1f7..d5ea2a5d 100644 --- a/src/Exceptions/FilterException.php +++ b/src/Exceptions/FilterException.php @@ -22,6 +22,8 @@ namespace Seat\Services\Exceptions; -class FilterException extends \Exception +use Exception; + +class FilterException extends Exception { } diff --git a/src/Exceptions/SettingException.php b/src/Exceptions/SettingException.php index 70d7205a..90427d20 100644 --- a/src/Exceptions/SettingException.php +++ b/src/Exceptions/SettingException.php @@ -22,6 +22,8 @@ namespace Seat\Services\Exceptions; -class SettingException extends \Exception +use Exception; + +class SettingException extends Exception { } diff --git a/src/Settings/Profile.php b/src/Settings/Profile.php index 32b460c2..183e4962 100644 --- a/src/Settings/Profile.php +++ b/src/Settings/Profile.php @@ -61,30 +61,4 @@ class Profile extends Settings * @var string */ protected static $scope = 'user'; - - /** - * @var array - */ - protected static $defaults = [ - - // UI - 'sidebar' => 'sidebar-full', - 'skin' => 'skin-black', - 'language' => 'en', - 'mail_threads' => 'yes', - - // A groups main character_id - 'main_character_id' => 0, - - // Numbers - 'thousand_seperator' => ' ', - 'decimal_seperator' => '.', - - // Notifications - 'email_notifications' => 'no', - 'email_address' => '', - - // Multi factor authentication - 'require_mfa' => 'no', - ]; } diff --git a/src/Settings/Seat.php b/src/Settings/Seat.php index c4a5b5b5..eb001377 100644 --- a/src/Settings/Seat.php +++ b/src/Settings/Seat.php @@ -60,109 +60,4 @@ class Seat extends Settings * @var string */ protected static $scope = 'global'; - - /** - * @var array - */ - protected static $defaults = [ - - // User Registration - 'registration' => 'yes', - - // Admin contact - 'admin_contact' => 'seatadmin@localhost.local', - - // Cleanup data in the database for users - // that have been deleted. - 'cleanup_data' => 'no', - - // The number of workers to spawn. - 'queue_workers' => 4, - - // Allow Usage Tracking - 'allow_tracking' => 'yes', - - // Currently Installed SDE Version - 'installed_sde' => null, - - // API Updater Class Constraint. This value should - // be stored as a json string! - 'api_constraint' => '', - - // Require Email Activation - 'require_activation' => 'yes', - - // Default Scopes asked for SSO Authentication - 'sso_scopes' => [ - [ - 'id' => 0, - 'name' => 'default', - 'default' => true, - 'scopes' => [ - 'publicData', - 'esi-alliances.read_contacts.v1', - 'esi-assets.read_assets.v1', - 'esi-assets.read_corporation_assets.v1', - 'esi-bookmarks.read_character_bookmarks.v1', - 'esi-bookmarks.read_corporation_bookmarks.v1', - 'esi-calendar.read_calendar_events.v1', - 'esi-characters.read_agents_research.v1', - 'esi-characters.read_blueprints.v1', - 'esi-characters.read_chat_channels.v1', - 'esi-characters.read_contacts.v1', - 'esi-characters.read_corporation_roles.v1', - 'esi-characters.read_fatigue.v1', - 'esi-characters.read_fw_stats.v1', - 'esi-characters.read_loyalty.v1', - 'esi-characters.read_medals.v1', - 'esi-characters.read_notifications.v1', - 'esi-characters.read_opportunities.v1', - 'esi-characters.read_standings.v1', - 'esi-characters.read_titles.v1', - 'esi-characterstats.read.v1', - 'esi-clones.read_clones.v1', - 'esi-clones.read_implants.v1', - 'esi-contracts.read_character_contracts.v1', - 'esi-contracts.read_corporation_contracts.v1', - 'esi-corporations.read_blueprints.v1', - 'esi-corporations.read_contacts.v1', - 'esi-corporations.read_container_logs.v1', - 'esi-corporations.read_corporation_membership.v1', - 'esi-corporations.read_divisions.v1', - 'esi-corporations.read_facilities.v1', - 'esi-corporations.read_fw_stats.v1', - 'esi-corporations.read_medals.v1', - 'esi-corporations.read_standings.v1', - 'esi-corporations.read_starbases.v1', - 'esi-corporations.read_structures.v1', - 'esi-corporations.read_titles.v1', - 'esi-corporations.track_members.v1', - 'esi-fittings.read_fittings.v1', - 'esi-fleets.read_fleet.v1', - 'esi-industry.read_character_jobs.v1', - 'esi-industry.read_character_mining.v1', - 'esi-industry.read_corporation_jobs.v1', - 'esi-industry.read_corporation_mining.v1', - 'esi-killmails.read_corporation_killmails.v1', - 'esi-killmails.read_killmails.v1', - 'esi-location.read_location.v1', - 'esi-location.read_online.v1', - 'esi-location.read_ship_type.v1', - 'esi-mail.read_mail.v1', - 'esi-markets.read_character_orders.v1', - 'esi-markets.read_corporation_orders.v1', - 'esi-markets.structure_markets.v1', - 'esi-planets.manage_planets.v1', - 'esi-planets.read_customs_offices.v1', - 'esi-search.search_structures.v1', - 'esi-skills.read_skillqueue.v1', - 'esi-skills.read_skills.v1', - 'esi-ui.open_window.v1', - 'esi-universe.read_structures.v1', - 'esi-wallet.read_character_wallet.v1', - 'esi-wallet.read_corporation_wallets.v1', - ], - ], - ], - ]; } diff --git a/src/Settings/Settings.php b/src/Settings/Settings.php index 9a32e8e2..00cf8180 100644 --- a/src/Settings/Settings.php +++ b/src/Settings/Settings.php @@ -61,6 +61,17 @@ abstract class Settings */ protected static $scope = 'global'; + /** + * Register new setting with its default value. + * + * @param string $name + * @param mixed $value + */ + public static function define(string $name, $value) + { + static::$defaults[$name] = $value; + } + /** * Retrieve a setting by name. * From bae05f4545eaa2312edc32ebe6aa5e29bfe418f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20LEUILLIOT?= Date: Sat, 1 Jan 2022 19:00:13 +0100 Subject: [PATCH 02/34] deps: update dependencies to be L8 compliant --- composer.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 64083354..4e589c1b 100644 --- a/composer.json +++ b/composer.json @@ -19,24 +19,24 @@ "minimum-stability": "dev", "prefer-stable": true, "require": { - "php": "^7.3", + "php": "^8.0", "ext-gmp": "*", "ext-json": "*", "ext-mbstring": "*", "ext-openssl": "*", "composer-runtime-api": "^2.0", - "coduo/php-humanizer": "^3.0", - "composer/semver": "^2.0", - "doctrine/dbal": "^2.9", - "guzzlehttp/guzzle": "^6.3", - "laravel/framework": "^6.2", + "coduo/php-humanizer": "^4.0", + "composer/semver": "^3.0", + "doctrine/dbal": "^3.0", + "guzzlehttp/guzzle": "^7.0", + "laravel/framework": "^8.0", "web-token/jwt-easy": "^2.1", "web-token/jwt-signature-algorithm-hmac": "^2.1", "web-token/jwt-signature-algorithm-rsa": "^2.1", "web-token/jwt-signature-algorithm-ecdsa": "^2.1" }, "require-dev": { - "phpunit/phpunit": "^8.5" + "phpunit/phpunit": "^9.0" }, "extra": { "laravel": { From 8634ec844dae444be8e287a139465e1dd3f7f2b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20LEUILLIOT?= Date: Mon, 3 Jan 2022 01:09:57 +0100 Subject: [PATCH 03/34] refactor: upgrade swagger annotations registration --- src/AbstractSeatPlugin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/AbstractSeatPlugin.php b/src/AbstractSeatPlugin.php index d430d10e..2ef198e2 100644 --- a/src/AbstractSeatPlugin.php +++ b/src/AbstractSeatPlugin.php @@ -201,7 +201,7 @@ final public function registerPermissions(string $permissions_path, string $scop final public function registerApiAnnotationsPath($paths) { // ensure current annotation setting is an array of path or transform into it - $current_annotations = config('l5-swagger.paths.annotations', []); + $current_annotations = config('l5-swagger.documentations.default.paths.annotations', []); if (! is_array($current_annotations)) $current_annotations = [$current_annotations]; @@ -211,7 +211,7 @@ final public function registerApiAnnotationsPath($paths) // merge paths together and update config config([ - 'l5-swagger.paths.annotations' => array_unique(array_merge($current_annotations, $paths)), + 'l5-swagger.documentations.default.paths.annotations' => array_unique(array_merge($current_annotations, $paths)), ]); } From 0f65bf5308f38565eeb84c8b0b9d8fc2bafbcdf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20LEUILLIOT?= Date: Wed, 5 Jan 2022 08:53:27 +0100 Subject: [PATCH 04/34] fix: ignore data clean when parameter string is empty with php8, when we attempt to load an empty string with DOMDocument::loadHTML, an exception is trigger. --- src/Helpers/helpers.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Helpers/helpers.php b/src/Helpers/helpers.php index 83af546d..3d1fa066 100644 --- a/src/Helpers/helpers.php +++ b/src/Helpers/helpers.php @@ -125,6 +125,8 @@ function number_metric($number) */ function clean_ccp_html($html, $acceptable_tags = '
') { + if (empty($html)) + return ''; // Handle Unicode cases. $html = mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'); From be0d308e8011643d381385254c3e1c97e2826ae3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20LEUILLIOT?= Date: Wed, 5 Jan 2022 08:53:43 +0100 Subject: [PATCH 05/34] deps: add missing dom extension --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index 4e589c1b..9bc13034 100644 --- a/composer.json +++ b/composer.json @@ -20,6 +20,7 @@ "prefer-stable": true, "require": { "php": "^8.0", + "ext-dom": "*", "ext-gmp": "*", "ext-json": "*", "ext-mbstring": "*", From 9f8bef099370f2612a2fcfdd188e72a6a3cc8d07 Mon Sep 17 00:00:00 2001 From: Crypta-Eve Date: Wed, 7 Dec 2022 07:27:07 +1030 Subject: [PATCH 06/34] feat: provide a generic seeder subscriber --- src/AbstractSeatPlugin.php | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/AbstractSeatPlugin.php b/src/AbstractSeatPlugin.php index 2ef198e2..3b62e9b2 100644 --- a/src/AbstractSeatPlugin.php +++ b/src/AbstractSeatPlugin.php @@ -146,10 +146,8 @@ abstract public function getPackagistVendorName(): string; * Return the plugin installed version. * * @return string - * - * @deprecated This method will be non longer overridable in the future. */ - public function getVersion(): string + final public function getVersion(): string { $name = sprintf('%s/%s', $this->getPackagistVendorName(), $this->getPackagistPackageName()); @@ -231,4 +229,22 @@ final public function registerSdeTables($tables) 'seat.sde.tables' => array_unique(array_merge($current_tables, $tables)), ]); } + + /** + * Register database seeders in the stack. + * + * @param string|array $classes + * @return void + */ + final public function registerDatabaseSeeders(string|array $classes) + { + $current_seeders = config('seat.seeders', []); + + if (! is_array($classes)) + $classes = [$classes]; + + config([ + 'seat.seeders' => array_merge($current_seeders, $classes), + ]); + } } From a8a066c33adcd10549581987efc72b6f956baabc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20LEUILLIOT?= Date: Wed, 9 Feb 2022 21:22:18 +0100 Subject: [PATCH 07/34] deps: update dependencies to be L9 compliant --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 9bc13034..c4f9740b 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "minimum-stability": "dev", "prefer-stable": true, "require": { - "php": "^8.0", + "php": "^8.1", "ext-dom": "*", "ext-gmp": "*", "ext-json": "*", @@ -30,7 +30,7 @@ "composer/semver": "^3.0", "doctrine/dbal": "^3.0", "guzzlehttp/guzzle": "^7.0", - "laravel/framework": "^8.0", + "laravel/framework": "^9.0", "web-token/jwt-easy": "^2.1", "web-token/jwt-signature-algorithm-hmac": "^2.1", "web-token/jwt-signature-algorithm-rsa": "^2.1", From 688e3f0008a4d298b1a1739fc3c3d5f5e2356a2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Leuilliot?= Date: Wed, 14 Sep 2022 10:38:20 +0200 Subject: [PATCH 08/34] refactor: introduce esi contracts to reduce eseye coupling --- composer.json | 2 + src/Contracts/EsiClient.php | 102 +++++++++++++++++++++++++++++ src/Contracts/EsiResponse.php | 84 ++++++++++++++++++++++++ src/Contracts/EsiToken.php | 75 +++++++++++++++++++++ src/Helpers/AnalyticsContainer.php | 10 +-- 5 files changed, 268 insertions(+), 5 deletions(-) create mode 100644 src/Contracts/EsiClient.php create mode 100644 src/Contracts/EsiResponse.php create mode 100644 src/Contracts/EsiToken.php diff --git a/composer.json b/composer.json index c4f9740b..94e0b7f6 100644 --- a/composer.json +++ b/composer.json @@ -31,6 +31,8 @@ "doctrine/dbal": "^3.0", "guzzlehttp/guzzle": "^7.0", "laravel/framework": "^9.0", + "psr/simple-cache": "^1.0|^2.0|^3.0", + "psr/log": "^1.0|^2.0|^3.0", "web-token/jwt-easy": "^2.1", "web-token/jwt-signature-algorithm-hmac": "^2.1", "web-token/jwt-signature-algorithm-rsa": "^2.1", diff --git a/src/Contracts/EsiClient.php b/src/Contracts/EsiClient.php new file mode 100644 index 00000000..9c3004b0 --- /dev/null +++ b/src/Contracts/EsiClient.php @@ -0,0 +1,102 @@ +data); @@ -67,7 +67,7 @@ public function offsetExists($offset) * @param mixed $offset * @return mixed */ - public function offsetGet($offset) + public function offsetGet(mixed $offset): mixed { return $this->data[$offset]; @@ -77,7 +77,7 @@ public function offsetGet($offset) * @param mixed $offset * @param mixed $value */ - public function offsetSet($offset, $value) + public function offsetSet(mixed $offset, mixed $value): void { $this->data[$offset] = $value; @@ -86,7 +86,7 @@ public function offsetSet($offset, $value) /** * @param mixed $offset */ - public function offsetUnset($offset) + public function offsetUnset(mixed $offset): void { unset($this->data[$offset]); @@ -117,7 +117,7 @@ public function __set($key, $val) * @param $val * @return $this */ - public function set($key, $val) + public function set($key, $val): self { $this->__set($key, $val); From 2e4e010deddcf6911f5b5ea0bfbd5323f3988cf5 Mon Sep 17 00:00:00 2001 From: Crypta Electrica Date: Sun, 29 Jan 2023 20:13:22 +1030 Subject: [PATCH 09/34] fix: adjust client_id config path --- src/Socialite/EveOnline/Provider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Socialite/EveOnline/Provider.php b/src/Socialite/EveOnline/Provider.php index dba08693..ca8465a6 100644 --- a/src/Socialite/EveOnline/Provider.php +++ b/src/Socialite/EveOnline/Provider.php @@ -170,7 +170,7 @@ private function validateJwtToken(string $access_token): array ->header('typ', new TypeChecker(['JWT'], true)) ->claim('scp', new ScpChecker($scopes)) ->claim('sub', new SubEveCharacterChecker()) - ->claim('azp', new AzpChecker(config('esi.eseye_client_id'))) + ->claim('azp', new AzpChecker(config('eseye.esi.auth.client_id'))) ->claim('name', new NameChecker()) ->claim('owner', new OwnerChecker()) ->keyset($jwk_sets) From a72ab107d6658dd98470b519bc07c3386f39c14d Mon Sep 17 00:00:00 2001 From: Crypta Electrica Date: Wed, 8 Feb 2023 07:39:08 +1030 Subject: [PATCH 10/34] feat: call all registered plugin db seeders --- composer.json | 3 ++- src/database/seeders/PluginDatabaseSeeder.php | 26 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/database/seeders/PluginDatabaseSeeder.php diff --git a/composer.json b/composer.json index 94e0b7f6..d8ed0847 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,8 @@ ], "autoload": { "psr-4": { - "Seat\\Services\\": "src/" + "Seat\\Services\\": "src/", + "Seat\\Services\\Database\\Seeders\\": "src/database/seeders/" }, "files": [ "src/Helpers/helpers.php" diff --git a/src/database/seeders/PluginDatabaseSeeder.php b/src/database/seeders/PluginDatabaseSeeder.php new file mode 100644 index 00000000..111e154e --- /dev/null +++ b/src/database/seeders/PluginDatabaseSeeder.php @@ -0,0 +1,26 @@ +command->info('Running all unique registered seeders'); + $this->call(array_unique($seeders)); + $this->command->info('Registered seeders run complete'); + + } +} \ No newline at end of file From bde2828581976318ebf16c9a0d3a4f055ec43d77 Mon Sep 17 00:00:00 2001 From: Crypta Electrica Date: Wed, 15 Feb 2023 21:45:57 +1030 Subject: [PATCH 11/34] chore: bump to laravel 10 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index d8ed0847..11bbdbc1 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ "composer/semver": "^3.0", "doctrine/dbal": "^3.0", "guzzlehttp/guzzle": "^7.0", - "laravel/framework": "^9.0", + "laravel/framework": "^10.0", "psr/simple-cache": "^1.0|^2.0|^3.0", "psr/log": "^1.0|^2.0|^3.0", "web-token/jwt-easy": "^2.1", From da8bc351a1d6c9e7b544855baf798fd756235f47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Leuilliot?= Date: Sun, 5 Mar 2023 19:51:35 +0100 Subject: [PATCH 12/34] style: apply fixes from StyleCI (#160) Co-authored-by: StyleCI Bot --- src/AbstractSeatPlugin.php | 2 +- src/Settings/Settings.php | 4 +-- src/database/seeders/PluginDatabaseSeeder.php | 31 ++++++++++++++----- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/AbstractSeatPlugin.php b/src/AbstractSeatPlugin.php index 3b62e9b2..9c5c6e55 100644 --- a/src/AbstractSeatPlugin.php +++ b/src/AbstractSeatPlugin.php @@ -233,7 +233,7 @@ final public function registerSdeTables($tables) /** * Register database seeders in the stack. * - * @param string|array $classes + * @param string|array $classes * @return void */ final public function registerDatabaseSeeders(string|array $classes) diff --git a/src/Settings/Settings.php b/src/Settings/Settings.php index 00cf8180..cb60c3e5 100644 --- a/src/Settings/Settings.php +++ b/src/Settings/Settings.php @@ -64,8 +64,8 @@ abstract class Settings /** * Register new setting with its default value. * - * @param string $name - * @param mixed $value + * @param string $name + * @param mixed $value */ public static function define(string $name, $value) { diff --git a/src/database/seeders/PluginDatabaseSeeder.php b/src/database/seeders/PluginDatabaseSeeder.php index 111e154e..0bcb5163 100644 --- a/src/database/seeders/PluginDatabaseSeeder.php +++ b/src/database/seeders/PluginDatabaseSeeder.php @@ -1,12 +1,29 @@ command->info('Registered seeders run complete'); } -} \ No newline at end of file +} From dabfc9576d0a31e6cbb60de5d6bbc3397a6ac286 Mon Sep 17 00:00:00 2001 From: recursivetree <60423027+recursivetree@users.noreply.github.com> Date: Thu, 27 Apr 2023 22:33:28 +0200 Subject: [PATCH 13/34] feat: allow available skins to be configurable (#161) related to eveseat/web#647 --- src/Settings/Profile.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Settings/Profile.php b/src/Settings/Profile.php index 183e4962..5252b6a8 100644 --- a/src/Settings/Profile.php +++ b/src/Settings/Profile.php @@ -39,9 +39,6 @@ class Profile extends Settings public static $options = [ 'sidebar' => ['sidebar-full', 'sidebar-collapse'], - 'skins' => [ - 'default', 'jet', - ], 'thousand_seperator' => [' ', ',', '.'], 'decimal_seperator' => [',', '.'], 'mail_threads' => ['yes', 'no'], From 3a3e7ce6b7dca80630f6286c8fd45b6359be7a66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20LEUILLIOT?= Date: Sun, 21 May 2023 11:13:39 +0200 Subject: [PATCH 14/34] refactor: extract jwt validator from service provider --- composer.json | 9 +- .../EveOnline/Checker/Claim/AzpChecker.php | 71 --------------- .../EveOnline/Checker/Claim/NameChecker.php | 53 ------------ .../EveOnline/Checker/Claim/OwnerChecker.php | 53 ------------ .../EveOnline/Checker/Claim/ScpChecker.php | 74 ---------------- .../Checker/Claim/SubEveCharacterChecker.php | 56 ------------ .../EveOnline/Checker/Header/TypeChecker.php | 86 ------------------- src/Socialite/EveOnline/Provider.php | 59 +------------ 8 files changed, 6 insertions(+), 455 deletions(-) delete mode 100644 src/Socialite/EveOnline/Checker/Claim/AzpChecker.php delete mode 100644 src/Socialite/EveOnline/Checker/Claim/NameChecker.php delete mode 100644 src/Socialite/EveOnline/Checker/Claim/OwnerChecker.php delete mode 100644 src/Socialite/EveOnline/Checker/Claim/ScpChecker.php delete mode 100644 src/Socialite/EveOnline/Checker/Claim/SubEveCharacterChecker.php delete mode 100644 src/Socialite/EveOnline/Checker/Header/TypeChecker.php diff --git a/composer.json b/composer.json index 11bbdbc1..1064f809 100644 --- a/composer.json +++ b/composer.json @@ -30,14 +30,11 @@ "coduo/php-humanizer": "^4.0", "composer/semver": "^3.0", "doctrine/dbal": "^3.0", + "eveseat/eseye": "^5.0", "guzzlehttp/guzzle": "^7.0", "laravel/framework": "^10.0", - "psr/simple-cache": "^1.0|^2.0|^3.0", - "psr/log": "^1.0|^2.0|^3.0", - "web-token/jwt-easy": "^2.1", - "web-token/jwt-signature-algorithm-hmac": "^2.1", - "web-token/jwt-signature-algorithm-rsa": "^2.1", - "web-token/jwt-signature-algorithm-ecdsa": "^2.1" + "psr/simple-cache": "^3.0", + "psr/log": "^3.0" }, "require-dev": { "phpunit/phpunit": "^9.0" diff --git a/src/Socialite/EveOnline/Checker/Claim/AzpChecker.php b/src/Socialite/EveOnline/Checker/Claim/AzpChecker.php deleted file mode 100644 index 1d543237..00000000 --- a/src/Socialite/EveOnline/Checker/Claim/AzpChecker.php +++ /dev/null @@ -1,71 +0,0 @@ -client_id = $client_id; - } - - /** - * {@inheritdoc} - */ - public function checkClaim($value): void - { - if (! is_string($value)) - throw new InvalidClaimException('"azp" must be a string.', self::NAME, $value); - - if ($value !== $this->client_id) - throw new InvalidClaimException('"azp" must match the originating application.', self::NAME, $value); - } - - /** - * {@inheritdoc} - */ - public function supportedClaim(): string - { - return self::NAME; - } -} diff --git a/src/Socialite/EveOnline/Checker/Claim/NameChecker.php b/src/Socialite/EveOnline/Checker/Claim/NameChecker.php deleted file mode 100644 index 8b009834..00000000 --- a/src/Socialite/EveOnline/Checker/Claim/NameChecker.php +++ /dev/null @@ -1,53 +0,0 @@ -scopes = $scopes; - } - - /** - * {@inheritdoc} - */ - public function checkClaim($value): void - { - if (! is_array($value) && ! is_string($value)) - throw new InvalidClaimException('"scp" must be an array of scopes.', self::NAME, $value); - - if (! is_array($value)) - $value = [$value]; - - if (! empty(array_diff($this->scopes, $value))) - throw new InvalidClaimException('"scp" contains scopes which does not match requested ones or miss some requested scopes.', self::NAME, $value); - } - - /** - * {@inheritdoc} - */ - public function supportedClaim(): string - { - return self::NAME; - } -} diff --git a/src/Socialite/EveOnline/Checker/Claim/SubEveCharacterChecker.php b/src/Socialite/EveOnline/Checker/Claim/SubEveCharacterChecker.php deleted file mode 100644 index 3a74b75d..00000000 --- a/src/Socialite/EveOnline/Checker/Claim/SubEveCharacterChecker.php +++ /dev/null @@ -1,56 +0,0 @@ -supported_types = $supported_types; - $this->protected_header = $protected_header; - } - - /** - * {@inheritdoc} - */ - public function checkHeader($value): void - { - if (! is_string($value)) - throw new InvalidHeaderException('"typ" must be a string.', self::HEADER_NAME, $value); - - if (! in_array($value, $this->supported_types, true)) - throw new InvalidHeaderException('Unsupported type.', self::HEADER_NAME, $value); - } - - /** - * {@inheritdoc} - */ - public function supportedHeader(): string - { - return self::HEADER_NAME; - } - - /** - * {@inheritdoc} - */ - public function protectedHeaderOnly(): bool - { - return $this->protected_header; - } -} diff --git a/src/Socialite/EveOnline/Provider.php b/src/Socialite/EveOnline/Provider.php index ca8465a6..7d2cce66 100644 --- a/src/Socialite/EveOnline/Provider.php +++ b/src/Socialite/EveOnline/Provider.php @@ -22,16 +22,9 @@ namespace Seat\Services\Socialite\EveOnline; -use Jose\Component\Core\JWKSet; -use Jose\Easy\Load; +use Seat\Eseye\Checker\EsiTokenValidator; use Seat\Services\Exceptions\EveImageException; use Seat\Services\Image\Eve; -use Seat\Services\Socialite\EveOnline\Checker\Claim\AzpChecker; -use Seat\Services\Socialite\EveOnline\Checker\Claim\NameChecker; -use Seat\Services\Socialite\EveOnline\Checker\Claim\OwnerChecker; -use Seat\Services\Socialite\EveOnline\Checker\Claim\ScpChecker; -use Seat\Services\Socialite\EveOnline\Checker\Claim\SubEveCharacterChecker; -use Seat\Services\Socialite\EveOnline\Checker\Header\TypeChecker; use SocialiteProviders\Manager\OAuth2\AbstractProvider; use SocialiteProviders\Manager\OAuth2\User; @@ -120,32 +113,6 @@ protected function getTokenFields($code) return array_merge(parent::getTokenFields($code), ['grant_type' => 'authorization_code']); } - /** - * @return string - */ - private function getJwkUri(): string - { - $response = $this->getHttpClient() - ->get('https://login.eveonline.com/.well-known/oauth-authorization-server'); - - $metadata = json_decode($response->getBody()); - - return $metadata->jwks_uri; - } - - /** - * @return array An array representing the JWK Key Sets - */ - private function getJwkSets(): array - { - $jwk_uri = $this->getJwkUri(); - - $response = $this->getHttpClient() - ->get($jwk_uri); - - return json_decode($response->getBody(), true); - } - /** * @param string $access_token * @return array @@ -154,28 +121,8 @@ private function getJwkSets(): array */ private function validateJwtToken(string $access_token): array { - $scopes = session()->pull('scopes', []); - - // pulling JWK sets from CCP - $sets = $this->getJwkSets(); - - // loading JWK Sets Manager - $jwk_sets = JWKSet::createFromKeyData($sets); - - // attempt to parse the JWT and collect payload - $jws = Load::jws($access_token) - ->algs(['RS256', 'ES256', 'HS256']) - ->exp() - ->iss('login.eveonline.com') - ->header('typ', new TypeChecker(['JWT'], true)) - ->claim('scp', new ScpChecker($scopes)) - ->claim('sub', new SubEveCharacterChecker()) - ->claim('azp', new AzpChecker(config('eseye.esi.auth.client_id'))) - ->claim('name', new NameChecker()) - ->claim('owner', new OwnerChecker()) - ->keyset($jwk_sets) - ->run(); + $validator = new EsiTokenValidator(); - return $jws->claims->all(); + return $validator->validateToken(config('eseye.esi.auth.client_id'), $access_token); } } From 83cb22ea424232d057a77ed702f35f626d9ffe21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Leuilliot?= Date: Sun, 21 May 2023 12:15:21 +0200 Subject: [PATCH 15/34] chore: require proper eseye version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 1064f809..77c1e8e9 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ "coduo/php-humanizer": "^4.0", "composer/semver": "^3.0", "doctrine/dbal": "^3.0", - "eveseat/eseye": "^5.0", + "eveseat/eseye": "^3.x-dev", "guzzlehttp/guzzle": "^7.0", "laravel/framework": "^10.0", "psr/simple-cache": "^3.0", From 1c6b78d65d856dc8bb21ddff155624591e44a923 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Leuilliot?= Date: Sun, 21 May 2023 17:57:47 +0200 Subject: [PATCH 16/34] fix: ensure eseye is properly setup --- src/Socialite/EveOnline/Provider.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Socialite/EveOnline/Provider.php b/src/Socialite/EveOnline/Provider.php index 7d2cce66..cca68bd5 100644 --- a/src/Socialite/EveOnline/Provider.php +++ b/src/Socialite/EveOnline/Provider.php @@ -22,7 +22,9 @@ namespace Seat\Services\Socialite\EveOnline; +use GuzzleHttp\Client; use Seat\Eseye\Checker\EsiTokenValidator; +use Seat\Eseye\Configuration; use Seat\Services\Exceptions\EveImageException; use Seat\Services\Image\Eve; use SocialiteProviders\Manager\OAuth2\AbstractProvider; @@ -121,6 +123,9 @@ protected function getTokenFields($code) */ private function validateJwtToken(string $access_token): array { + $config = Configuration::getInstance(); + $config->http_client = Client::class; + $validator = new EsiTokenValidator(); return $validator->validateToken(config('eseye.esi.auth.client_id'), $access_token); From 9c6ead84661762276db39e1d3d6d85bf4110a4d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Leuilliot?= Date: Sun, 21 May 2023 22:12:16 +0200 Subject: [PATCH 17/34] fix: avoid duplicate seeder to be stored in config --- src/AbstractSeatPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AbstractSeatPlugin.php b/src/AbstractSeatPlugin.php index 9c5c6e55..57d339b6 100644 --- a/src/AbstractSeatPlugin.php +++ b/src/AbstractSeatPlugin.php @@ -244,7 +244,7 @@ final public function registerDatabaseSeeders(string|array $classes) $classes = [$classes]; config([ - 'seat.seeders' => array_merge($current_seeders, $classes), + 'seat.seeders' => array_unique(array_merge($current_seeders, $classes)), ]); } } From 01926be2ec72b68af69b7559d6a5865241223a02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Leuilliot?= Date: Tue, 30 May 2023 16:07:42 +0200 Subject: [PATCH 18/34] test: make tests compliant with phpunit 10 (#164) --- .github/workflows/tests.yml | 8 +++--- composer.json | 5 ++++ phpunit.xml | 27 +++++++++---------- tests/ReportParser/Elements/ElementTest.php | 3 +++ tests/ReportParser/Elements/GroupTest.php | 2 ++ tests/ReportParser/Parsers/MoonReportTest.php | 10 ++++--- 6 files changed, 32 insertions(+), 23 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 074eb550..4685a8e4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -2,9 +2,9 @@ name: Unit Testing on: push: - branches: [ "master" ] + branches: [ "master", "5.0.x" ] pull_request: - branches: [ "master" ] + branches: [ "master", "5.0.x" ] permissions: contents: read @@ -17,7 +17,7 @@ jobs: strategy: fail-fast: true matrix: - php: [7.4] + php: [8.1] steps: - uses: actions/checkout@v3 @@ -34,4 +34,4 @@ jobs: run: composer update --prefer-dist --no-interaction --no-progress - name: Execute tests - run: vendor/bin/phpunit --verbose + run: vendor/bin/phpunit --display-notices diff --git a/composer.json b/composer.json index 090bea0b..d117095e 100644 --- a/composer.json +++ b/composer.json @@ -17,6 +17,11 @@ "src/Helpers/helpers.php" ] }, + "autoload-dev": { + "psr-4": { + "Seat\\Tests\\Services\\": "tests/" + } + }, "minimum-stability": "dev", "prefer-stable": true, "require": { diff --git a/phpunit.xml b/phpunit.xml index 72259af9..eba3f6ac 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,17 +1,14 @@ - - - - ./src/ - - - - - ./tests/ReportParser - - + + + + + ./tests/ReportParser + + + + + ./src/ + + diff --git a/tests/ReportParser/Elements/ElementTest.php b/tests/ReportParser/Elements/ElementTest.php index 39dc2621..6e92b526 100644 --- a/tests/ReportParser/Elements/ElementTest.php +++ b/tests/ReportParser/Elements/ElementTest.php @@ -1,5 +1,8 @@ ['/../../artifacts/moon_report.txt'], @@ -22,21 +24,21 @@ public function correctFormatProvider(): array ]; } - public function malformedElementsProvider(): array + public static function malformedElementsProvider(): array { return [ 'no elements' => ['/../../artifacts/moon_report_without_elements.txt'] ]; } - public function malformedGroupsProvider(): array + public static function malformedGroupsProvider(): array { return [ 'no groups' => ['/../../artifacts/moon_report_without_groups.txt'] ]; } - public function malformedHeaderProvider(): array + public static function malformedHeaderProvider(): array { return [ 'no header' => ['/../../artifacts/moon_report_without_header.txt'] From d24c23e5d8c1ef38da9aff525824f6e043705a66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Leuilliot?= Date: Tue, 30 May 2023 17:02:45 +0200 Subject: [PATCH 19/34] style: apply fixes from StyleCI (#165) Co-authored-by: StyleCI Bot --- src/AbstractSeatPlugin.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/AbstractSeatPlugin.php b/src/AbstractSeatPlugin.php index 57d339b6..09a2490e 100644 --- a/src/AbstractSeatPlugin.php +++ b/src/AbstractSeatPlugin.php @@ -37,6 +37,7 @@ abstract class AbstractSeatPlugin extends ServiceProvider * Return an URI to a CHANGELOG.md file or an API path which will be providing changelog history. * * @example https://raw.githubusercontent.com/eveseat/seat/master/LICENSE + * * @exemple https://api.github.com/repos/eveseat/web/releases * * @return string|null From 5606381f9c862bbb0a9489662d74c5c6d595ea57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Leuilliot?= Date: Fri, 14 Jul 2023 13:13:26 +0200 Subject: [PATCH 20/34] deps: lock eseye to stable build --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index d117095e..205da3e4 100644 --- a/composer.json +++ b/composer.json @@ -35,7 +35,7 @@ "coduo/php-humanizer": "^4.0", "composer/semver": "^3.0", "doctrine/dbal": "^3.0", - "eveseat/eseye": "^3.x-dev", + "eveseat/eseye": "^3.0", "guzzlehttp/guzzle": "^7.0", "laravel/framework": "^10.0", "psr/simple-cache": "^3.0", From 1d4885412c3461cbd2ded55546b733e838802082 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Leuilliot?= Date: Fri, 14 Jul 2023 19:31:08 +0200 Subject: [PATCH 21/34] ci: on release push changes to 5.0.x --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 99c0344e..f6d20d4c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,6 +11,7 @@ jobs: - uses: actions/checkout@v2 with: repository: eveseat/seat-docker + ref: '5.0.x' ssh-key: '${{ secrets.SEAT_DOCKER_REPO }}' - run: | git config user.name github-actions From 5534f13911c1c944a6c8829c80dafd7300646cd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20LEUILLIOT?= Date: Sat, 15 Jul 2023 09:13:25 +0200 Subject: [PATCH 22/34] ci: remove docker image auto-tag --- .github/workflows/main.yml | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index f6d20d4c..00000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Tag a new seat-docker release -on: - release: - types: [released] - -jobs: - build: - name: Checkout and tag - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - repository: eveseat/seat-docker - ref: '5.0.x' - ssh-key: '${{ secrets.SEAT_DOCKER_REPO }}' - - run: | - git config user.name github-actions - git config user.email github-actions@github.com - currver=`cat version` - a=(${currver//./ }) - newrelease=${a[2]} - newrelease=$((newrelease+1)) - newver="${a[0]}.${a[1]}.${newrelease}" - echo $newver > version - git add version - git commit -m "bump to version $newver" - git push - git tag -a "$newver" -m "src: $GITHUB_REPOSITORY commit: ${GITHUB_SHA: -8}" - git push origin --tags - From 6c88cb843e198ce8dbc4a7840d7d5b598c5beca1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20LEUILLIOT?= Date: Sat, 15 Jul 2023 09:13:53 +0200 Subject: [PATCH 23/34] ci: move travis to github action for testing --- .github/workflows/tests.yml | 32 ++++++++++++++++++++++++-------- .travis.yml | 13 ------------- 2 files changed, 24 insertions(+), 21 deletions(-) delete mode 100644 .travis.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4685a8e4..db73397f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -2,23 +2,25 @@ name: Unit Testing on: push: - branches: [ "master", "5.0.x" ] + branches: [ "5.0.x" ] pull_request: - branches: [ "master", "5.0.x" ] + branches: [ "5.0.x" ] permissions: contents: read jobs: - build: + tests: runs-on: ubuntu-latest strategy: fail-fast: true matrix: - php: [8.1] + php: [8.1, 8.2] + stability: [prefer-stable] + name: PHP ${{ matrix.php }} - ${{ matrix.stability }} steps: - uses: actions/checkout@v3 @@ -28,10 +30,24 @@ jobs: php-version: ${{ matrix.php }} extensions: curl, gmp, json, mbstring, openssl tools: composer:v2 - coverage: none + coverage: xdebug - name: Install dependencies - run: composer update --prefer-dist --no-interaction --no-progress + run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress - - name: Execute tests - run: vendor/bin/phpunit --display-notices + - name: Download Codeclimate Tools + if: ${{ github.event_name != 'pull_request' }} + run: curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter && chmod +x ./cc-test-reporter + + - name: Init Codeclimate Tools + if: ${{ github.event_name != 'pull_request' }} + run: ./cc-test-reporter before-build + + - name: Run Tests + run: vendor/bin/phpunit --coverage-clover build/logs/clover.xml + + - name: Publish code coverage + if: ${{ github.event_name != 'pull_request' }} + env: + CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} + run: ./cc-test-reporter after-build -t clover \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e09b7125..00000000 --- a/.travis.yml +++ /dev/null @@ -1,13 +0,0 @@ -language: php -php: - - 7.3 -before_script: - - pecl install -o -f redis <<<"" - - COMPOSER_MEMORY_LIMIT=-1 composer update - - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter - - chmod +x ./cc-test-reporter - - ./cc-test-reporter before-build -script: - - vendor/bin/phpunit -c phpunit.xml -after_script: - - ./cc-test-reporter after-build From c367d47eedba4afccfb097d303b8e0aa116e3a2e Mon Sep 17 00:00:00 2001 From: recursivetree <60423027+recursivetree@users.noreply.github.com> Date: Mon, 14 Aug 2023 20:32:01 +0200 Subject: [PATCH 24/34] fix: address ccp richtext parsing with utf-8 encoding issue (#169) --- phpunit.xml | 3 +++ src/Helpers/helpers.php | 21 +++++++++++++++------ tests/CleanCCPHtml/CleanCCPHtmlTest.php | 25 +++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 tests/CleanCCPHtml/CleanCCPHtmlTest.php diff --git a/phpunit.xml b/phpunit.xml index eba3f6ac..cd8dcefb 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -5,6 +5,9 @@ ./tests/ReportParser + + ./tests/CleanCCPHtml + diff --git a/src/Helpers/helpers.php b/src/Helpers/helpers.php index 3d1fa066..60d8a30f 100644 --- a/src/Helpers/helpers.php +++ b/src/Helpers/helpers.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -44,7 +44,7 @@ function carbon($data = null) * Return the time difference from now in a * format that humans can read. * - * @param $time + * @param $time * @return string */ function human_diff($time) @@ -84,8 +84,8 @@ function img(string $type, string $variation, ?int $id, int $size, array $attr = /** * Return a formatted number. * - * @param $number - * @param $dec + * @param $number + * @param $dec * @return string * * @throws \Seat\Services\Exceptions\SettingException @@ -104,7 +104,7 @@ function number($number, $dec = 2) * Return a shortened number with a suffix. * Depends on php5-intl. * - * @param $number + * @param $number * @return bool|string */ function number_metric($number) @@ -128,6 +128,15 @@ function clean_ccp_html($html, $acceptable_tags = '
') if (empty($html)) return ''; + // CCP's rich text might be encapsulated in u''. Remove the u' + $html = preg_match("/u'(.*)'/", $html, $match) ? $match[1] : $html; + + // handle escaped UTF-8 data + // taken from https://stackoverflow.com/questions/2934563/how-to-decode-unicode-escape-sequences-like-u00ed-to-proper-utf-8-encoded-cha + $html = preg_replace_callback('/\\\\u([0-9a-fA-F]{4})/', function ($match) { + return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UTF-16BE'); + }, $html); + // Handle Unicode cases. $html = mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'); @@ -159,7 +168,7 @@ function clean_ccp_html($html, $acceptable_tags = '
') * Attempt to 'thread' evemails based on the separator * that is automatically added using the eve client. * - * @param $message + * @param $message * @return \Illuminate\Support\Collection */ function evemail_threads($message) diff --git a/tests/CleanCCPHtml/CleanCCPHtmlTest.php b/tests/CleanCCPHtml/CleanCCPHtmlTest.php new file mode 100644 index 00000000..a6db93e1 --- /dev/null +++ b/tests/CleanCCPHtml/CleanCCPHtmlTest.php @@ -0,0 +1,25 @@ +assertEquals('test', clean_ccp_html("u'test'")); + } + + public function testWithoutEncapsulation() + { + $this->assertEquals('test', clean_ccp_html('test')); + // also test that the other feature continue to work + $this->assertEquals('test', clean_ccp_html('test')); + } + + public function testEscapedUnicodeDecoding() + { + $this->assertEquals('创 ä 😀', clean_ccp_html('\u521b ä 😀')); + } +} \ No newline at end of file From 673c6cf891f0df41ba894ab6fd63def9b6065463 Mon Sep 17 00:00:00 2001 From: recursivetree <60423027+recursivetree@users.noreply.github.com> Date: Thu, 9 Nov 2023 15:10:06 +0100 Subject: [PATCH 25/34] Injectable Relations (#166) * add model extensions * fix method-call-style relations * clean up code * add fascade * add fascade * remove facade, add to model * remove unused imports * add documentation * remove imports * add tests * styleci * fix injected relations * add more tests * add testbench dependency * test eager loading --- composer.json | 3 +- phpunit.xml | 3 + .../InjectedRelationConflictException.php | 30 ++++ src/Models/ExtensibleModel.php | 127 +++++++++++++++++ src/Models/GlobalSetting.php | 6 +- src/Models/Note.php | 5 +- src/Models/Schedule.php | 6 +- src/Models/UserSetting.php | 6 +- src/Services/InjectedRelationRegistry.php | 100 +++++++++++++ src/ServicesServiceProvider.php | 7 +- .../Extensions/ModelAExtension.php | 13 ++ .../InjectedRelationsTest.php | 131 ++++++++++++++++++ tests/InjectedRelations/Models/ModelA.php | 31 +++++ tests/InjectedRelations/Models/ModelB.php | 31 +++++ tests/database/factories/ModelAFactory.php | 44 ++++++ tests/database/factories/ModelBFactory.php | 46 ++++++ ...eate_relation_injection_testing_models.php | 57 ++++++++ 17 files changed, 629 insertions(+), 17 deletions(-) create mode 100644 src/Exceptions/InjectedRelationConflictException.php create mode 100644 src/Models/ExtensibleModel.php create mode 100644 src/Services/InjectedRelationRegistry.php create mode 100644 tests/InjectedRelations/Extensions/ModelAExtension.php create mode 100644 tests/InjectedRelations/InjectedRelationsTest.php create mode 100644 tests/InjectedRelations/Models/ModelA.php create mode 100644 tests/InjectedRelations/Models/ModelB.php create mode 100644 tests/database/factories/ModelAFactory.php create mode 100644 tests/database/factories/ModelBFactory.php create mode 100644 tests/database/migrations/2023_07_27_053529_create_relation_injection_testing_models.php diff --git a/composer.json b/composer.json index 205da3e4..4754cda0 100644 --- a/composer.json +++ b/composer.json @@ -42,7 +42,8 @@ "psr/log": "^3.0" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^10.0", + "orchestra/testbench": "^8.0" }, "extra": { "laravel": { diff --git a/phpunit.xml b/phpunit.xml index cd8dcefb..89ec3f3c 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -5,6 +5,9 @@ ./tests/ReportParser + + ./tests/InjectedRelations + ./tests/CleanCCPHtml diff --git a/src/Exceptions/InjectedRelationConflictException.php b/src/Exceptions/InjectedRelationConflictException.php new file mode 100644 index 00000000..3d6dedf2 --- /dev/null +++ b/src/Exceptions/InjectedRelationConflictException.php @@ -0,0 +1,30 @@ +make(InjectedRelationRegistry::class); + $extension_class = $extension_registry->getExtensionClassFor($this::class, $key); + + // check if we have an injected relation + if($extension_class){ + // we have an injected relation + // since what we are doing is not intended, we have to roughly reimplement laravel's code from here on + + //check if relation data is cached + // the relation cache continues to work even for 'fake' relations, but we have to manually call it + if($this->relationLoaded($key)){ + return $this->getRelationValue($key); + } + + // it is NOT cached, we have to load it and put it into the cache + // get relation from extension + $extension_class_instance = new $extension_class; + $relation = $extension_class_instance->$key($this); + + // the following code is taken from laravel's \Illuminate\Database\Eloquent\Concerns\HasAttributes::getRelationshipFromMethod + // check if we actually got a relation returned + if (! $relation instanceof Relation) { + if (is_null($relation)) { + throw new LogicException(sprintf( + '%s::%s must return a relationship instance, but "null" was returned. Was the "return" keyword used?', static::class, $key + )); + } + + throw new LogicException(sprintf( + '%s::%s must return a relationship instance.', static::class, $key + )); + } + + return tap($relation->getResults(), function ($results) use ($key) { + $this->setRelation($key, $results); + }); + } + + // use the default behaviour if no relation is injected + return parent::__get($key); + } + + /** + * Redirects calls to injected relations or behaves like a normal class. + * + * @param string $method + * @param $parameters + * @return mixed + * + * @throws BindingResolutionException + */ + public function __call($method, $parameters) + { + // fetch injected relations + $extension_registry = app()->make(InjectedRelationRegistry::class); + $extension_class = $extension_registry->getExtensionClassFor($this::class, $method); + + // check if we have an injected relation + if($extension_class) { + // return the injected relation + $extension_class_instance = new $extension_class; + + return $extension_class_instance->$method($this); + } + + // use the default behaviour if no relation is injected + return parent::__call($method, $parameters); + } + + /** + * Injects relations into this model. + * + * @param string $extension_class the class that provides the injected relations + * @return void + * + * @throws BindingResolutionException + * @throws InjectedRelationConflictException A conflict arises when trying to inject two relations with the same name into a target. + */ + public static function injectRelationsFrom(string $extension_class): void { + $registry = app()->make(InjectedRelationRegistry::class); + $registry->injectRelations(static::class, $extension_class); + } +} diff --git a/src/Models/GlobalSetting.php b/src/Models/GlobalSetting.php index 98a22efb..4f97e59b 100644 --- a/src/Models/GlobalSetting.php +++ b/src/Models/GlobalSetting.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,14 +22,12 @@ namespace Seat\Services\Models; -use Illuminate\Database\Eloquent\Model; - /** * Class GlobalSetting. * * @package Seat\Services\Models */ -class GlobalSetting extends Model +class GlobalSetting extends ExtensibleModel { /** * @var array diff --git a/src/Models/Note.php b/src/Models/Note.php index 5493ba6d..8086aac8 100644 --- a/src/Models/Note.php +++ b/src/Models/Note.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,14 +23,13 @@ namespace Seat\Services\Models; use Illuminate\Database\Eloquent\Builder; -use Illuminate\Database\Eloquent\Model; /** * Class Note. * * @package Seat\Services\Models */ -class Note extends Model +class Note extends ExtensibleModel { /** * @var array diff --git a/src/Models/Schedule.php b/src/Models/Schedule.php index 9efcd5eb..c76d3ca7 100644 --- a/src/Models/Schedule.php +++ b/src/Models/Schedule.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,14 +22,12 @@ namespace Seat\Services\Models; -use Illuminate\Database\Eloquent\Model; - /** * Class Schedule. * * @package Seat\Services\Models */ -class Schedule extends Model +class Schedule extends ExtensibleModel { /** * @var array diff --git a/src/Models/UserSetting.php b/src/Models/UserSetting.php index cdc4ddbf..d4c0c579 100644 --- a/src/Models/UserSetting.php +++ b/src/Models/UserSetting.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,14 +22,12 @@ namespace Seat\Services\Models; -use Illuminate\Database\Eloquent\Model; - /** * Class UserSetting. * * @package Seat\Services\Models */ -class UserSetting extends Model +class UserSetting extends ExtensibleModel { /** * @var array diff --git a/src/Services/InjectedRelationRegistry.php b/src/Services/InjectedRelationRegistry.php new file mode 100644 index 00000000..2a5c6d9a --- /dev/null +++ b/src/Services/InjectedRelationRegistry.php @@ -0,0 +1,100 @@ + + */ + private array $relations = []; + + /** + * Injects all relations from a class into a model. + * + * @param string $target_model the model to inject relations into + * @param string $extension_class the class to take the relations from + * @return void + * + * @throws InjectedRelationConflictException A conflict arises when trying to inject two relations with the same name into a target. + */ + public function injectRelations(string $target_model, string $extension_class): void + { + $methods = get_class_methods($extension_class); + + foreach ($methods as $relation_name){ + $this->injectSingleRelation($target_model, $extension_class, $relation_name); + } + } + + /** + * Injects a single relation into a model. + * + * @param string $model the model to inject the relation into + * @param string $extension_class the class holding the relation function + * @param string $relation the name of the relation to be injected. The method providing the relation in $extension_class must have the same name, and the relation will be accessible under this name. + * @return void + * + * @throws InjectedRelationConflictException A conflict arises when trying to inject two relations with the same name into a target. + */ + public function injectSingleRelation(string $model, string $extension_class, string $relation): void + { + $key = $this->getInjectionTargetKey($model, $relation); + + // check for conflicts, as there can't be two relations with the same name + if(array_key_exists($key, $this->relations)) { + $conflict = $this->relations[$key]; + throw new InjectedRelationConflictException(sprintf('Relation \'%s\' from \'%s\' is name-conflicting with \'%s\'', $relation, $model, $conflict)); + } + + $this->relations[$key] = $extension_class; + } + + /** + * Searches for injected relations for a model. + * + * @param string $model the model to search for + * @param string $relation the relation name to search for + * @return string|null the class providing the injected relation, or null if there is no injected relation + */ + public function getExtensionClassFor(string $model, string $relation): ?string + { + return $this->relations[$this->getInjectionTargetKey($model, $relation)] ?? null; + } + + /** + * Generates a key for $this->$relations. + * + * @param string $model the injection target class + * @param string $relation_name the relation name + * @return string a key to use with $this->$relations + */ + private function getInjectionTargetKey(string $model, string $relation_name): string { + return sprintf('%s.%s', $model, $relation_name); + } +} diff --git a/src/ServicesServiceProvider.php b/src/ServicesServiceProvider.php index 4e9746f8..5b63afb4 100644 --- a/src/ServicesServiceProvider.php +++ b/src/ServicesServiceProvider.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,6 +25,7 @@ use Illuminate\Support\Facades\DB; use Seat\Services\Commands\Seat\Admin\Email; use Seat\Services\Commands\Seat\Version; +use Seat\Services\Services\InjectedRelationRegistry; class ServicesServiceProvider extends AbstractSeatPlugin { @@ -87,6 +88,10 @@ public function register() $this->mergeConfigFrom( __DIR__ . '/Config/services.config.php', 'services.config'); + + $this->app->singleton(InjectedRelationRegistry::class, function () { + return new InjectedRelationRegistry(); + }); } private function addCommands() diff --git a/tests/InjectedRelations/Extensions/ModelAExtension.php b/tests/InjectedRelations/Extensions/ModelAExtension.php new file mode 100644 index 00000000..49cb87de --- /dev/null +++ b/tests/InjectedRelations/Extensions/ModelAExtension.php @@ -0,0 +1,13 @@ +hasOne(ModelB::class); + } +} \ No newline at end of file diff --git a/tests/InjectedRelations/InjectedRelationsTest.php b/tests/InjectedRelations/InjectedRelationsTest.php new file mode 100644 index 00000000..e6ebf182 --- /dev/null +++ b/tests/InjectedRelations/InjectedRelationsTest.php @@ -0,0 +1,131 @@ +set('database.default', 'testbench'); + $app['config']->set('database.connections.testbench', [ + 'driver' => 'sqlite', + 'database' => ':memory:', + 'prefix' => '', + ]); + $app['config']->set('database.redis.client', 'mock'); + } + + /** + * @param \Illuminate\Foundation\Application $app + * @return array|string[] + */ + protected function getPackageProviders($app) + { + return [ + ServicesServiceProvider::class + ]; + } + + /** + * Define database migrations. + * + * @return void + */ + protected function defineDatabaseMigrations() + { + $this->loadMigrationsFrom(__DIR__ . '/../database/migrations'); + } + + /** + * Test if InjectedRelationRegistry works + * @throws \Seat\Services\Exceptions\InjectedRelationConflictException + * @throws \Illuminate\Contracts\Container\BindingResolutionException + */ + public function testRegistry(){ + ModelA::injectRelationsFrom(ModelAExtension::class); + $registry = app()->make(InjectedRelationRegistry::class); + + $this->assertEquals(ModelAExtension::class,$registry->getExtensionClassFor(ModelA::class,'modelBInjected')); + $this->assertEquals(null,$registry->getExtensionClassFor(ModelA::class,'doesntexist')); + } + + /** + * Test if registering the same relation twice errors + * @throws \Illuminate\Contracts\Container\BindingResolutionException + * @throws \Seat\Services\Exceptions\InjectedRelationConflictException + */ + public function testInjectionConflict(){ + $this->expectException(InjectedRelationConflictException::class); + ModelA::injectRelationsFrom(ModelAExtension::class); + ModelA::injectRelationsFrom(ModelAExtension::class); + } + + /** + * Test if injected relations are working + * @return void + * @throws InjectedRelationConflictException + * @throws \Illuminate\Contracts\Container\BindingResolutionException + */ + public function testInjectedRelations(){ + $a = ModelA::factory()->create(); + ModelB::factory() + ->for($a) + ->create(); + + ModelA::injectRelationsFrom(ModelAExtension::class); + + // factory might already trigger the cache, therefore make sure we have new models + $a = ModelA::first(); + $b = ModelB::first(); + + // ensure normal relations are still working + // b->a + $this->assertNotEquals(null, $b->modelA->id); + $this->assertEquals($a->id, $b->modelA->id); + // a->b + $this->assertNotEquals(null, $a->modelB->id); + $this->assertEquals($b->id, $a->modelB->id); + + //test injected relationship + // as attributes + $this->assertNotEquals(null, $a->modelBInjected->id); + $this->assertEquals($b->id, $a->modelBInjected->id); + // as function calls + $this->assertNotEquals(null, $a->modelBInjected()->first()->id); + $this->assertEquals($b->id, $a->modelBInjected()->first()->id); + } + + /** + * Test if eager loading with 'with' works + * @throws InjectedRelationConflictException + * @throws BindingResolutionException + */ + public function testEagerLoading(){ + $a = ModelA::factory()->create(); + $b = ModelB::factory() + ->for($a) + ->create(); + + ModelA::injectRelationsFrom(ModelAExtension::class); + + $result = ModelA::with("modelBInjected")->first(); + $loaded_relations = $result->getRelations(); + + $this->assertArrayHasKey('modelBInjected', $loaded_relations); + + $model_b = $loaded_relations['modelBInjected']; + $this->assertInstanceOf(ModelB::class, $model_b); + $this->assertEquals($model_b->id, $b->id); + } +} \ No newline at end of file diff --git a/tests/InjectedRelations/Models/ModelA.php b/tests/InjectedRelations/Models/ModelA.php new file mode 100644 index 00000000..ed2340d5 --- /dev/null +++ b/tests/InjectedRelations/Models/ModelA.php @@ -0,0 +1,31 @@ +hasOne(ModelB::class); + } +} \ No newline at end of file diff --git a/tests/InjectedRelations/Models/ModelB.php b/tests/InjectedRelations/Models/ModelB.php new file mode 100644 index 00000000..3bd19315 --- /dev/null +++ b/tests/InjectedRelations/Models/ModelB.php @@ -0,0 +1,31 @@ +belongsTo(ModelA::class); + } +} \ No newline at end of file diff --git a/tests/database/factories/ModelAFactory.php b/tests/database/factories/ModelAFactory.php new file mode 100644 index 00000000..7c70fddc --- /dev/null +++ b/tests/database/factories/ModelAFactory.php @@ -0,0 +1,44 @@ +ModelA::factory() + ]; + } +} diff --git a/tests/database/migrations/2023_07_27_053529_create_relation_injection_testing_models.php b/tests/database/migrations/2023_07_27_053529_create_relation_injection_testing_models.php new file mode 100644 index 00000000..fff9bb07 --- /dev/null +++ b/tests/database/migrations/2023_07_27_053529_create_relation_injection_testing_models.php @@ -0,0 +1,57 @@ +increments('id'); + }); + + Schema::create('model_b', function (Blueprint $table) { + $table->increments('id'); + $table->integer('model_a_id')->unsigned(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + + Schema::drop('model_a'); + Schema::drop('model_m'); + } +} From cc17fe274b0e22db3d37f27133f5f99ff7da06cd Mon Sep 17 00:00:00 2001 From: recursivetree <60423027+recursivetree@users.noreply.github.com> Date: Thu, 9 Nov 2023 15:12:39 +0100 Subject: [PATCH 26/34] Start integrating recursivetree/seat-prices-core into the seat core (#170) * move first things over * add documentation * styleci --- src/Contracts/HasTypeID.php | 34 ++++++ src/Contracts/IPriceable.php | 44 ++++++++ src/Helpers/UserAgentBuilder.php | 179 +++++++++++++++++++++++++++++++ src/Items/EveType.php | 53 +++++++++ src/Items/PriceableEveType.php | 71 ++++++++++++ 5 files changed, 381 insertions(+) create mode 100644 src/Contracts/HasTypeID.php create mode 100644 src/Contracts/IPriceable.php create mode 100644 src/Helpers/UserAgentBuilder.php create mode 100644 src/Items/EveType.php create mode 100644 src/Items/PriceableEveType.php diff --git a/src/Contracts/HasTypeID.php b/src/Contracts/HasTypeID.php new file mode 100644 index 00000000..a31b1dbe --- /dev/null +++ b/src/Contracts/HasTypeID.php @@ -0,0 +1,34 @@ +product = $product; + + return $this; + } + + /** + * Set the version of the product. + * + * @param string $version + * @return $this + */ + public function version(string $version): UserAgentBuilder { + $this->version = $version; + + return $this; + } + + /** + * Configures the product and version of the user agent for a seat plugin. + * + * @param string|AbstractSeatPlugin $plugin A plugin service provider instance or the FCQN of the service provider (e.g. MyServiceProvider::class) + * @return $this + */ + public function seatPlugin(string|AbstractSeatPlugin $plugin): UserAgentBuilder { + if(is_string($plugin)){ + $plugin = new $plugin(null); + } + + $this->packagist($plugin->getPackagistVendorName(), $plugin->getPackagistPackageName()); + + return $this; + } + + /** + * Configures the product and version of the user agent for a packagist package. + * + * @param string $vendor The packagist vendor name + * @param string $package The packagist package name + * @return $this + */ + public function packagist(string $vendor, string $package): UserAgentBuilder { + $this->product = sprintf('%s:%s', $vendor, $package); + $this->version = $this->getPackageVersion($vendor, $package); + + return $this; + } + + /** + * Adds a comment containing the product and version of the user agent for a seat plugin. + * + * @param string|AbstractSeatPlugin $plugin A plugin service provider instance or the FCQN of the service provider (e.g. MyServiceProvider::class) + * @return $this + */ + public function commentSeatPlugin(string|AbstractSeatPlugin $plugin): UserAgentBuilder { + if(is_string($plugin)){ + $plugin = new $plugin(null); + } + + $this->commentPackagist($plugin->getPackagistVendorName(), $plugin->getPackagistPackageName()); + + return $this; + } + + /** + * Adds a comment containing the product and version of the user agent for a packagist package. + * + * @param string $vendor The packagist vendor name + * @param string $package The packagist package name + * @return $this + */ + public function commentPackagist(string $vendor, string $package): UserAgentBuilder { + $this->comment(sprintf('%s:%s/%s', $vendor, $package, $this->getPackageVersion($vendor, $package))); + + return $this; + } + + /** + * Add a comment to the user agent. + * + * @param string $comment the comment + * @return $this + */ + public function comment(string $comment): UserAgentBuilder { + $this->comments[] = $comment; + + return $this; + } + + /** + * Adds a reasonable set of default comments for any seat plugin. + * + * @return $this + * + * @throws SettingException + */ + public function defaultComments(): UserAgentBuilder { + $this->comment(sprintf('(admin contact: %s)', setting('admin_contact', true) ?? 'not specified')); + $this->comment('(https://github.com/eveseat/seat)'); + $this->commentPackagist('eveseat', 'seat'); + $this->commentPackagist('eveseat', 'web'); + $this->commentPackagist('eveseat', 'eveapi'); + + return $this; + } + + /** + * Assembles the user agent form its product, version, and comments into a string. + * + * @return string The user agent + */ + public function build(): string { + if($this->product === null || $this->version === null) { + throw new \Error('version or product not set.'); + } + + return sprintf('%s/%s %s', $this->product, $this->version, implode(' ', $this->comments)); + } + + /** + * Gets the installed version of a packagist package. + * + * @param string $vendor The packagist vendor name + * @param string $package The packagist package name + * @return string + */ + private function getPackageVersion(string $vendor, string $package): string { + try { + return InstalledVersions::getPrettyVersion(sprintf('%s/%s', $vendor, $package)) ?? 'unknown'; + } catch (OutOfBoundsException $e) { + return 'unknown'; + } + } +} diff --git a/src/Items/EveType.php b/src/Items/EveType.php new file mode 100644 index 00000000..a23fcf48 --- /dev/null +++ b/src/Items/EveType.php @@ -0,0 +1,53 @@ +getTypeID(); + } + + $this->type_id = $type_id; + } + + /** + * @return int The type id + */ + public function getTypeID(): int + { + return $this->type_id; + } +} diff --git a/src/Items/PriceableEveType.php b/src/Items/PriceableEveType.php new file mode 100644 index 00000000..dbe6b95b --- /dev/null +++ b/src/Items/PriceableEveType.php @@ -0,0 +1,71 @@ +price = 0; + $this->amount = $amount; + } + + /** + * @return int The amount of this item to be appraised + */ + public function getAmount(): int + { + return $this->amount; + } + + /** + * @return float The price of this item stack + */ + public function getPrice(): float + { + return $this->price; + } + + /** + * @param float $price The new price of this item stack + * @return void + */ + public function setPrice(float $price): void + { + $this->price = $price; + } +} From 09d8b559bc4536432b16b4c9308a6838ba6d9936 Mon Sep 17 00:00:00 2001 From: recursivetree <60423027+recursivetree@users.noreply.github.com> Date: Wed, 14 Feb 2024 10:50:33 +0100 Subject: [PATCH 27/34] deferred migrations system (#175) --- src/Facades/DeferredMigration.php | 18 ++++++++++++++++ src/Listeners/RunDeferredMigrations.php | 19 ++++++++++++++++ src/Services/DeferredMigrationRegistry.php | 25 ++++++++++++++++++++++ src/ServicesServiceProvider.php | 17 +++++++++++++++ 4 files changed, 79 insertions(+) create mode 100644 src/Facades/DeferredMigration.php create mode 100644 src/Listeners/RunDeferredMigrations.php create mode 100644 src/Services/DeferredMigrationRegistry.php diff --git a/src/Facades/DeferredMigration.php b/src/Facades/DeferredMigration.php new file mode 100644 index 00000000..a0177af2 --- /dev/null +++ b/src/Facades/DeferredMigration.php @@ -0,0 +1,18 @@ +make(DeferredMigrationRegistry::class); + + $registry->runMigrations(); + } +} \ No newline at end of file diff --git a/src/Services/DeferredMigrationRegistry.php b/src/Services/DeferredMigrationRegistry.php new file mode 100644 index 00000000..d0ce0c71 --- /dev/null +++ b/src/Services/DeferredMigrationRegistry.php @@ -0,0 +1,25 @@ + + */ + protected array $deferred_migrations = []; + + public function schedule(Closure $migration): void { + $this->deferred_migrations[] = $migration; + } + + public function runMigrations(): void { + logger()->info(sprintf("[Deferred Migrations] Running %d deferred migrations", count($this->deferred_migrations))); + + foreach ($this->deferred_migrations as $migration){ + $migration(); + } + } +} \ No newline at end of file diff --git a/src/ServicesServiceProvider.php b/src/ServicesServiceProvider.php index 5b63afb4..05fdd677 100644 --- a/src/ServicesServiceProvider.php +++ b/src/ServicesServiceProvider.php @@ -22,9 +22,14 @@ namespace Seat\Services; +use Illuminate\Database\Events\MigrationsEnded; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Event; use Seat\Services\Commands\Seat\Admin\Email; use Seat\Services\Commands\Seat\Version; +use Seat\Services\Contracts\DeferredMigration; +use Seat\Services\Listeners\RunDeferredMigrations; +use Seat\Services\Services\DeferredMigrationRegistry; use Seat\Services\Services\InjectedRelationRegistry; class ServicesServiceProvider extends AbstractSeatPlugin @@ -76,6 +81,9 @@ public function boot() // Inform Laravel how to load migrations $this->add_migrations(); + + // add event listener + $this->add_event_listeners(); } /** @@ -92,6 +100,10 @@ public function register() $this->app->singleton(InjectedRelationRegistry::class, function () { return new InjectedRelationRegistry(); }); + + $this->app->singleton(DeferredMigrationRegistry::class, function () { + return new DeferredMigrationRegistry(); + }); } private function addCommands() @@ -102,6 +114,11 @@ private function addCommands() ]); } + private function add_event_listeners(): void + { + Event::listen(MigrationsEnded::class,RunDeferredMigrations::class); + } + /** * Set the path for migrations which should * be migrated by laravel. More informations: From 756ed09e010ea3a4dbd3845ac4b1a012258dd90d Mon Sep 17 00:00:00 2001 From: Jay's Date: Fri, 16 Feb 2024 01:12:15 +0100 Subject: [PATCH 28/34] Fix socialite provider (#176) * Fix socialite provider * styleCI * styleCI * styleCI * styleCI * styleCI --- src/Socialite/EveOnline/Provider.php | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/Socialite/EveOnline/Provider.php b/src/Socialite/EveOnline/Provider.php index cca68bd5..d8b6263c 100644 --- a/src/Socialite/EveOnline/Provider.php +++ b/src/Socialite/EveOnline/Provider.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -94,13 +94,13 @@ protected function mapUserToObject(array $user) } return (new User)->setRaw($user)->map([ - 'id' => $character_id, - 'name' => $user['name'], - 'nickname' => $user['name'], + 'id' => $character_id, + 'name' => $user['name'], + 'nickname' => $user['name'], 'character_owner_hash' => $user['owner'], - 'scopes' => is_array($user['scp']) ? $user['scp'] : [$user['scp']], - 'expires_on' => $user['exp'], - 'avatar' => $avatar, + 'scopes' => is_array($user['scp']) ? $user['scp'] : [$user['scp']], + 'expires_on' => $user['exp'], + 'avatar' => $avatar, ]); } @@ -112,7 +112,17 @@ protected function mapUserToObject(array $user) */ protected function getTokenFields($code) { - return array_merge(parent::getTokenFields($code), ['grant_type' => 'authorization_code']); + $fields = [ + 'grant_type' => 'authorization_code', + 'code' => $code, + 'redirect_uri' => $this->redirectUrl, + ]; + + if ($this->usesPKCE()) { + $fields['code_verifier'] = $this->request->session()->pull('code_verifier'); + } + + return $fields; } /** From a0ea02fbb306245078f24fca81eaa2fb002b1491 Mon Sep 17 00:00:00 2001 From: Crypta Eve Date: Fri, 16 Feb 2024 11:16:12 +1100 Subject: [PATCH 29/34] Apply fixes from StyleCI (#177) Co-authored-by: StyleCI Bot --- src/AbstractSeatPlugin.php | 2 +- src/Commands/Seat/Admin/Email.php | 2 +- src/Commands/Seat/Version.php | 2 +- src/Config/services.config.php | 2 +- src/Contracts/EsiClient.php | 2 +- src/Contracts/EsiResponse.php | 2 +- src/Contracts/EsiToken.php | 2 +- src/Exceptions/EveImageException.php | 2 +- src/Exceptions/FilterException.php | 2 +- src/Exceptions/SettingException.php | 2 +- src/Facades/DeferredMigration.php | 22 ++++++++++++++++- src/Helpers/AnalyticsContainer.php | 24 +++++++++---------- src/Helpers/helpers.php | 12 +++++----- src/Image/Eve.php | 6 ++--- src/Jobs/Analytics.php | 14 +++++------ src/Listeners/RunDeferredMigrations.php | 22 ++++++++++++++++- src/ReportParser/Elements/Element.php | 8 +++---- src/ReportParser/Elements/Group.php | 2 +- .../Exceptions/EmptyReportException.php | 2 +- .../InvalidReportElementException.php | 2 +- .../Exceptions/InvalidReportException.php | 2 +- .../InvalidReportGroupException.php | 2 +- .../MissingReportGroupException.php | 2 +- .../MissingReportHeaderException.php | 2 +- src/ReportParser/Parsers/MoonReport.php | 2 +- src/ReportParser/ReportParser.php | 2 +- src/Services/DeferredMigrationRegistry.php | 24 +++++++++++++++++-- src/ServicesServiceProvider.php | 3 +-- src/Settings/Profile.php | 8 +++---- src/Settings/Seat.php | 12 +++++----- src/Settings/Settings.php | 10 ++++---- .../EveOnline/EveOnlineExtendSocialite.php | 2 +- src/Traits/NotableTrait.php | 8 +++---- src/Traits/VersionsManagementTrait.php | 2 +- ...12_create_eve_notification_types_table.php | 2 +- ...1_28_053529_create_user_settings_table.php | 2 +- ...28_071315_create_global_settings_table.php | 2 +- ...15_12_01_201414_create_schedules_table.php | 2 +- .../2016_11_19_065120_create_notes_table.php | 2 +- ...5441_convert_value_from_string_to_text.php | 2 +- ...8_05_18_185619_move_settings_to_groups.php | 2 +- ..._181511_create_historical_prices_table.php | 2 +- ...064533_alter_historical_prices_columns.php | 2 +- ...4_27_231132_convert_sso_scopes_to_list.php | 8 +++---- ...20_05_10_101541_drop_historical_prices.php | 2 +- ..._120325_convert_chinese_language_value.php | 2 +- src/database/seeders/PluginDatabaseSeeder.php | 2 +- 47 files changed, 153 insertions(+), 94 deletions(-) diff --git a/src/AbstractSeatPlugin.php b/src/AbstractSeatPlugin.php index 09a2490e..a6c205c5 100644 --- a/src/AbstractSeatPlugin.php +++ b/src/AbstractSeatPlugin.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/Commands/Seat/Admin/Email.php b/src/Commands/Seat/Admin/Email.php index bd032968..67dbb761 100644 --- a/src/Commands/Seat/Admin/Email.php +++ b/src/Commands/Seat/Admin/Email.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/Commands/Seat/Version.php b/src/Commands/Seat/Version.php index 9b05c72b..996f5d57 100644 --- a/src/Commands/Seat/Version.php +++ b/src/Commands/Seat/Version.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/Config/services.config.php b/src/Config/services.config.php index a4f02b1e..1a9082e7 100644 --- a/src/Config/services.config.php +++ b/src/Config/services.config.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/Contracts/EsiClient.php b/src/Contracts/EsiClient.php index 9c3004b0..4b468430 100644 --- a/src/Contracts/EsiClient.php +++ b/src/Contracts/EsiClient.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/Contracts/EsiResponse.php b/src/Contracts/EsiResponse.php index 617ed2bd..b91ee9e1 100644 --- a/src/Contracts/EsiResponse.php +++ b/src/Contracts/EsiResponse.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/Contracts/EsiToken.php b/src/Contracts/EsiToken.php index 1a69e873..4b638c8c 100644 --- a/src/Contracts/EsiToken.php +++ b/src/Contracts/EsiToken.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/Exceptions/EveImageException.php b/src/Exceptions/EveImageException.php index d8ab39d2..e9ce72c4 100644 --- a/src/Exceptions/EveImageException.php +++ b/src/Exceptions/EveImageException.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/Exceptions/FilterException.php b/src/Exceptions/FilterException.php index d5ea2a5d..35506582 100644 --- a/src/Exceptions/FilterException.php +++ b/src/Exceptions/FilterException.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/Exceptions/SettingException.php b/src/Exceptions/SettingException.php index 90427d20..247d0a1a 100644 --- a/src/Exceptions/SettingException.php +++ b/src/Exceptions/SettingException.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/Facades/DeferredMigration.php b/src/Facades/DeferredMigration.php index a0177af2..b13fe06d 100644 --- a/src/Facades/DeferredMigration.php +++ b/src/Facades/DeferredMigration.php @@ -1,5 +1,25 @@ null, // Hit Type // Event Values - 'ec' => null, // Event Category - 'ea' => null, // Event Action - 'el' => null, // Event Label - 'ev' => null, // Event Value + 'ec' => null, // Event Category + 'ea' => null, // Event Action + 'el' => null, // Event Label + 'ev' => null, // Event Value // Exception Values - 'exd' => null, // Exception Description - 'exf' => null, // Is Fatal Exception? + 'exd' => null, // Exception Description + 'exf' => null, // Is Fatal Exception? ]; /** @@ -93,7 +93,7 @@ public function offsetUnset(mixed $offset): void } /** - * @param $key + * @param $key * @return mixed */ public function __get($key) @@ -103,8 +103,8 @@ public function __get($key) } /** - * @param $key - * @param $val + * @param $key + * @param $val */ public function __set($key, $val) { @@ -113,8 +113,8 @@ public function __set($key, $val) } /** - * @param $key - * @param $val + * @param $key + * @param $val * @return $this */ public function set($key, $val): self diff --git a/src/Helpers/helpers.php b/src/Helpers/helpers.php index 60d8a30f..f02955d8 100644 --- a/src/Helpers/helpers.php +++ b/src/Helpers/helpers.php @@ -182,11 +182,11 @@ function evemail_threads($message) // Message headers array. $headers = [ - 'subject' => null, - 'from' => null, - 'sent' => null, - 'to' => null, - 'message' => null, + 'subject' => null, + 'from' => null, + 'sent' => null, + 'to' => null, + 'message' => null, 'headers_ok' => false, ]; @@ -309,7 +309,7 @@ function number_roman($number) { $map = [ - 'M' => 1000, 'CM' => 900, 'D' => 500, 'CD' => 400, 'C' => 100, 'XC' => 90, 'L' => 50, + 'M' => 1000, 'CM' => 900, 'D' => 500, 'CD' => 400, 'C' => 100, 'XC' => 90, 'L' => 50, 'XL' => 40, 'X' => 10, 'IX' => 9, 'V' => 5, 'IV' => 4, 'I' => 1, ]; diff --git a/src/Image/Eve.php b/src/Image/Eve.php index 04df18d4..c3453f85 100644 --- a/src/Image/Eve.php +++ b/src/Image/Eve.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -136,7 +136,7 @@ public function __construct(string $type, string $variation, ?int $id, int $size * Attempt to detect the image type based on the * range in which an integer falls. * - * @param $id + * @param $id * @return string */ public function detect_type($id) @@ -213,7 +213,7 @@ public function html() } /** - * @param $size + * @param $size * @return string */ public function url($size) diff --git a/src/Jobs/Analytics.php b/src/Jobs/Analytics.php index df3bdcfd..6ce5db55 100644 --- a/src/Jobs/Analytics.php +++ b/src/Jobs/Analytics.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -157,7 +157,7 @@ private function send($type, array $query) $client = new Client([ 'base_uri' => 'https://www.google-analytics.com/', - 'timeout' => 5.0, + 'timeout' => 5.0, ]); // Check if we are in debug mode @@ -172,17 +172,17 @@ private function send($type, array $query) // Required Fields // https://developers.google.com/analytics/devguides/collection/protocol/v1/devguide#required - 'v' => 1, // Protocol Version + 'v' => 1, // Protocol Version 'tid' => $this->tracking_id, // Google Tracking-ID 'cid' => $this->getClientID(), // Unique Client-ID - 't' => $type, // Event + 't' => $type, // Event // Optional Fields 'aip' => 1, // Anonymize the IP of the calling client - 'an' => 'SeAT', // App Name + 'an' => 'SeAT', // App Name // Versions of the currently installed packages. - 'av' => $versions->implode(', '), + 'av' => $versions->implode(', '), // User Agent is comprised of OS Name(s), Release(r) // and Machine Type(m). Examples: @@ -191,7 +191,7 @@ private function send($type, array $query) // // See: // http://php.net/manual/en/function.php-uname.php - 'ua' => 'SeAT/' . php_uname('s') . + 'ua' => 'SeAT/' . php_uname('s') . '/' . php_uname('r') . '/' . php_uname('m'), diff --git a/src/Listeners/RunDeferredMigrations.php b/src/Listeners/RunDeferredMigrations.php index 53c2c958..a4b2467f 100644 --- a/src/Listeners/RunDeferredMigrations.php +++ b/src/Listeners/RunDeferredMigrations.php @@ -1,5 +1,25 @@ runMigrations(); } -} \ No newline at end of file +} diff --git a/src/ReportParser/Elements/Element.php b/src/ReportParser/Elements/Element.php index 1cb209f3..e9c1b6bb 100644 --- a/src/ReportParser/Elements/Element.php +++ b/src/ReportParser/Elements/Element.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -47,7 +47,7 @@ public function __construct(array $fields) } /** - * @param $field + * @param $field */ public function add($field) { @@ -55,7 +55,7 @@ public function add($field) } /** - * @param $field + * @param $field */ public function remove($field) { @@ -81,7 +81,7 @@ public function isEmpty(): bool } /** - * @param $name + * @param $name * @return mixed * * @throws \ErrorException diff --git a/src/ReportParser/Elements/Group.php b/src/ReportParser/Elements/Group.php index dda728a1..253fc3e8 100644 --- a/src/ReportParser/Elements/Group.php +++ b/src/ReportParser/Elements/Group.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ReportParser/Exceptions/EmptyReportException.php b/src/ReportParser/Exceptions/EmptyReportException.php index 100c803f..58ec39b8 100644 --- a/src/ReportParser/Exceptions/EmptyReportException.php +++ b/src/ReportParser/Exceptions/EmptyReportException.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ReportParser/Exceptions/InvalidReportElementException.php b/src/ReportParser/Exceptions/InvalidReportElementException.php index 162e9686..93fae489 100644 --- a/src/ReportParser/Exceptions/InvalidReportElementException.php +++ b/src/ReportParser/Exceptions/InvalidReportElementException.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ReportParser/Exceptions/InvalidReportException.php b/src/ReportParser/Exceptions/InvalidReportException.php index 730525b5..2fde5129 100644 --- a/src/ReportParser/Exceptions/InvalidReportException.php +++ b/src/ReportParser/Exceptions/InvalidReportException.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ReportParser/Exceptions/InvalidReportGroupException.php b/src/ReportParser/Exceptions/InvalidReportGroupException.php index cd5f5407..6af50f9f 100644 --- a/src/ReportParser/Exceptions/InvalidReportGroupException.php +++ b/src/ReportParser/Exceptions/InvalidReportGroupException.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ReportParser/Exceptions/MissingReportGroupException.php b/src/ReportParser/Exceptions/MissingReportGroupException.php index 147681c2..89cbd8c5 100644 --- a/src/ReportParser/Exceptions/MissingReportGroupException.php +++ b/src/ReportParser/Exceptions/MissingReportGroupException.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ReportParser/Exceptions/MissingReportHeaderException.php b/src/ReportParser/Exceptions/MissingReportHeaderException.php index 5b2710f6..a7999e4e 100644 --- a/src/ReportParser/Exceptions/MissingReportHeaderException.php +++ b/src/ReportParser/Exceptions/MissingReportHeaderException.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ReportParser/Parsers/MoonReport.php b/src/ReportParser/Parsers/MoonReport.php index 2f9826ce..f692e5de 100644 --- a/src/ReportParser/Parsers/MoonReport.php +++ b/src/ReportParser/Parsers/MoonReport.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ReportParser/ReportParser.php b/src/ReportParser/ReportParser.php index 3fb61a96..017a097e 100644 --- a/src/ReportParser/ReportParser.php +++ b/src/ReportParser/ReportParser.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/Services/DeferredMigrationRegistry.php b/src/Services/DeferredMigrationRegistry.php index d0ce0c71..981c54dc 100644 --- a/src/Services/DeferredMigrationRegistry.php +++ b/src/Services/DeferredMigrationRegistry.php @@ -1,5 +1,25 @@ info(sprintf("[Deferred Migrations] Running %d deferred migrations", count($this->deferred_migrations))); + logger()->info(sprintf('[Deferred Migrations] Running %d deferred migrations', count($this->deferred_migrations))); foreach ($this->deferred_migrations as $migration){ $migration(); } } -} \ No newline at end of file +} diff --git a/src/ServicesServiceProvider.php b/src/ServicesServiceProvider.php index 05fdd677..ed79a1b6 100644 --- a/src/ServicesServiceProvider.php +++ b/src/ServicesServiceProvider.php @@ -27,7 +27,6 @@ use Illuminate\Support\Facades\Event; use Seat\Services\Commands\Seat\Admin\Email; use Seat\Services\Commands\Seat\Version; -use Seat\Services\Contracts\DeferredMigration; use Seat\Services\Listeners\RunDeferredMigrations; use Seat\Services\Services\DeferredMigrationRegistry; use Seat\Services\Services\InjectedRelationRegistry; @@ -116,7 +115,7 @@ private function addCommands() private function add_event_listeners(): void { - Event::listen(MigrationsEnded::class,RunDeferredMigrations::class); + Event::listen(MigrationsEnded::class, RunDeferredMigrations::class); } /** diff --git a/src/Settings/Profile.php b/src/Settings/Profile.php index 5252b6a8..cf327298 100644 --- a/src/Settings/Profile.php +++ b/src/Settings/Profile.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -38,10 +38,10 @@ class Profile extends Settings */ public static $options = [ - 'sidebar' => ['sidebar-full', 'sidebar-collapse'], + 'sidebar' => ['sidebar-full', 'sidebar-collapse'], 'thousand_seperator' => [' ', ',', '.'], - 'decimal_seperator' => [',', '.'], - 'mail_threads' => ['yes', 'no'], + 'decimal_seperator' => [',', '.'], + 'mail_threads' => ['yes', 'no'], ]; /** diff --git a/src/Settings/Seat.php b/src/Settings/Seat.php index eb001377..182b874e 100644 --- a/src/Settings/Seat.php +++ b/src/Settings/Seat.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -38,12 +38,12 @@ class Seat extends Settings */ public static $options = [ - 'registration' => ['yes', 'no'], - 'force_min_mask' => ['yes', 'no'], - 'allow_sso' => ['yes', 'no'], - 'allow_tracking' => ['yes', 'no'], + 'registration' => ['yes', 'no'], + 'force_min_mask' => ['yes', 'no'], + 'allow_sso' => ['yes', 'no'], + 'allow_tracking' => ['yes', 'no'], 'require_activation' => ['yes', 'no'], - 'cleanup_data' => ['yes', 'no'], + 'cleanup_data' => ['yes', 'no'], ]; /** diff --git a/src/Settings/Settings.php b/src/Settings/Settings.php index cb60c3e5..e567811a 100644 --- a/src/Settings/Settings.php +++ b/src/Settings/Settings.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -117,8 +117,8 @@ public static function get($name, $for_id = null) /** * Determine the unique prefix for the key by name. * - * @param $name - * @param $for_id + * @param $name + * @param $for_id * @return string * * @throws \Seat\Services\Exceptions\SettingException @@ -146,7 +146,7 @@ public static function get_key_prefix($name, $for_id = null) * dont have an already logged in session, well then * we make the $for_id null. * - * @param $for_id + * @param $for_id * @return int|null */ public static function get_affected_id($for_id) @@ -193,7 +193,7 @@ public static function set($name, $value, $for_id = null) $db = new static::$model; $db->fill([ - 'name' => $name, + 'name' => $name, 'value' => $encoded_value, ]); diff --git a/src/Socialite/EveOnline/EveOnlineExtendSocialite.php b/src/Socialite/EveOnline/EveOnlineExtendSocialite.php index 1d1612fe..15cbeb73 100644 --- a/src/Socialite/EveOnline/EveOnlineExtendSocialite.php +++ b/src/Socialite/EveOnline/EveOnlineExtendSocialite.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/Traits/NotableTrait.php b/src/Traits/NotableTrait.php index c690c689..68c549be 100644 --- a/src/Traits/NotableTrait.php +++ b/src/Traits/NotableTrait.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -46,9 +46,9 @@ public static function addNote( return Note::create([ 'object_type' => __CLASS__, - 'object_id' => $object_id, - 'title' => $title, - 'note' => $note, + 'object_id' => $object_id, + 'title' => $title, + 'note' => $note, ]); } diff --git a/src/Traits/VersionsManagementTrait.php b/src/Traits/VersionsManagementTrait.php index 1886c1f0..92abc522 100644 --- a/src/Traits/VersionsManagementTrait.php +++ b/src/Traits/VersionsManagementTrait.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/database/migrations/2015_10_30_140512_create_eve_notification_types_table.php b/src/database/migrations/2015_10_30_140512_create_eve_notification_types_table.php index 471cf8f2..2e6a7930 100644 --- a/src/database/migrations/2015_10_30_140512_create_eve_notification_types_table.php +++ b/src/database/migrations/2015_10_30_140512_create_eve_notification_types_table.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/database/migrations/2015_11_28_053529_create_user_settings_table.php b/src/database/migrations/2015_11_28_053529_create_user_settings_table.php index 3389e2c1..f81de939 100644 --- a/src/database/migrations/2015_11_28_053529_create_user_settings_table.php +++ b/src/database/migrations/2015_11_28_053529_create_user_settings_table.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/database/migrations/2015_11_28_071315_create_global_settings_table.php b/src/database/migrations/2015_11_28_071315_create_global_settings_table.php index df0aa8d6..ca14823a 100644 --- a/src/database/migrations/2015_11_28_071315_create_global_settings_table.php +++ b/src/database/migrations/2015_11_28_071315_create_global_settings_table.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/database/migrations/2015_12_01_201414_create_schedules_table.php b/src/database/migrations/2015_12_01_201414_create_schedules_table.php index ba0e46e7..65f2e034 100644 --- a/src/database/migrations/2015_12_01_201414_create_schedules_table.php +++ b/src/database/migrations/2015_12_01_201414_create_schedules_table.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/database/migrations/2016_11_19_065120_create_notes_table.php b/src/database/migrations/2016_11_19_065120_create_notes_table.php index c8bd6059..fe40014c 100644 --- a/src/database/migrations/2016_11_19_065120_create_notes_table.php +++ b/src/database/migrations/2016_11_19_065120_create_notes_table.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/database/migrations/2016_11_29_195441_convert_value_from_string_to_text.php b/src/database/migrations/2016_11_29_195441_convert_value_from_string_to_text.php index 4ead3602..fa8532d3 100644 --- a/src/database/migrations/2016_11_29_195441_convert_value_from_string_to_text.php +++ b/src/database/migrations/2016_11_29_195441_convert_value_from_string_to_text.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/database/migrations/2018_05_18_185619_move_settings_to_groups.php b/src/database/migrations/2018_05_18_185619_move_settings_to_groups.php index 1144e672..a8fe69ba 100644 --- a/src/database/migrations/2018_05_18_185619_move_settings_to_groups.php +++ b/src/database/migrations/2018_05_18_185619_move_settings_to_groups.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/database/migrations/2018_09_12_181511_create_historical_prices_table.php b/src/database/migrations/2018_09_12_181511_create_historical_prices_table.php index 4ef3415d..3d23d508 100644 --- a/src/database/migrations/2018_09_12_181511_create_historical_prices_table.php +++ b/src/database/migrations/2018_09_12_181511_create_historical_prices_table.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/database/migrations/2018_10_05_064533_alter_historical_prices_columns.php b/src/database/migrations/2018_10_05_064533_alter_historical_prices_columns.php index 90e8bc41..7503c6ee 100644 --- a/src/database/migrations/2018_10_05_064533_alter_historical_prices_columns.php +++ b/src/database/migrations/2018_10_05_064533_alter_historical_prices_columns.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/database/migrations/2020_04_27_231132_convert_sso_scopes_to_list.php b/src/database/migrations/2020_04_27_231132_convert_sso_scopes_to_list.php index c0cb8ecf..7745f41a 100644 --- a/src/database/migrations/2020_04_27_231132_convert_sso_scopes_to_list.php +++ b/src/database/migrations/2020_04_27_231132_convert_sso_scopes_to_list.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -42,9 +42,9 @@ public function up() $new_sso_scopes = [ [ - 'id' => 0, - 'name' => 'default', - 'scopes' => json_decode($sso_scopes->value), + 'id' => 0, + 'name' => 'default', + 'scopes' => json_decode($sso_scopes->value), 'default' => true, ], ]; diff --git a/src/database/migrations/2020_05_10_101541_drop_historical_prices.php b/src/database/migrations/2020_05_10_101541_drop_historical_prices.php index 73e5ba9d..aa9f13a1 100644 --- a/src/database/migrations/2020_05_10_101541_drop_historical_prices.php +++ b/src/database/migrations/2020_05_10_101541_drop_historical_prices.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/database/migrations/2021_01_02_120325_convert_chinese_language_value.php b/src/database/migrations/2021_01_02_120325_convert_chinese_language_value.php index 4a984191..051ae616 100644 --- a/src/database/migrations/2021_01_02_120325_convert_chinese_language_value.php +++ b/src/database/migrations/2021_01_02_120325_convert_chinese_language_value.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/database/seeders/PluginDatabaseSeeder.php b/src/database/seeders/PluginDatabaseSeeder.php index 0bcb5163..45d39e74 100644 --- a/src/database/seeders/PluginDatabaseSeeder.php +++ b/src/database/seeders/PluginDatabaseSeeder.php @@ -3,7 +3,7 @@ /* * This file is part of SeAT * - * Copyright (C) 2015 to 2022 Leon Jacobs + * Copyright (C) 2015 to present Leon Jacobs * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by From 8bb84aa826eca9ba1badabde54a8012c3de5004c Mon Sep 17 00:00:00 2001 From: Jay's Date: Tue, 20 Feb 2024 09:58:30 +0100 Subject: [PATCH 30/34] Fix the socialite provider after they pushed a revert (#178) * Fix socialite provider * styleCI * Fix provider again after socialite reverted their previous change --- src/Socialite/EveOnline/Provider.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Socialite/EveOnline/Provider.php b/src/Socialite/EveOnline/Provider.php index d8b6263c..b32a33f6 100644 --- a/src/Socialite/EveOnline/Provider.php +++ b/src/Socialite/EveOnline/Provider.php @@ -140,4 +140,15 @@ private function validateJwtToken(string $access_token): array return $validator->validateToken(config('eseye.esi.auth.client_id'), $access_token); } + + /** + * {@inheritDoc} + */ + protected function getTokenHeaders($code) + { + return [ + 'Accept' => 'application/json', + 'Authorization' => 'Basic ' . base64_encode($this->clientId . ':' . $this->clientSecret), + ]; + } } From 1504474a815e0e7164b87abdb36856f14f2b44b4 Mon Sep 17 00:00:00 2001 From: recursivetree <60423027+recursivetree@users.noreply.github.com> Date: Tue, 26 Mar 2024 12:41:37 +0100 Subject: [PATCH 31/34] add schedule seeder helper (#179) * add schedule seeder helper * styleci --- src/Seeding/AbstractScheduleSeeder.php | 62 ++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/Seeding/AbstractScheduleSeeder.php diff --git a/src/Seeding/AbstractScheduleSeeder.php b/src/Seeding/AbstractScheduleSeeder.php new file mode 100644 index 00000000..433c6a4b --- /dev/null +++ b/src/Seeding/AbstractScheduleSeeder.php @@ -0,0 +1,62 @@ +getSchedules(); + foreach ($schedules as $job) { + if (! DB::table('schedules')->where('command', $job['command'])->exists()) { + DB::table('schedules')->insert($job); + } + } + + // drop deprecated commands + DB::table('schedules')->whereIn('command', $this->getDeprecatedSchedules())->delete(); + } +} From f378db384c9cd960ff596bf49e89506116a5b3cf Mon Sep 17 00:00:00 2001 From: recursivetree <60423027+recursivetree@users.noreply.github.com> Date: Wed, 3 Apr 2024 13:49:07 +0200 Subject: [PATCH 32/34] feat: add HasTypeIDWithAmount interface (#180) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: add HasTypeIDWithAmount interface * styleci * Update src/Contracts/IPriceable.php Remove redundant extends Co-authored-by: Loïc Leuilliot --------- Co-authored-by: Crypta Eve Co-authored-by: Loïc Leuilliot --- src/Contracts/HasTypeIDWithAmount.php | 35 ++++++++++++++++++ src/Contracts/IPriceable.php | 7 +--- src/Items/EveTypeWithAmount.php | 52 +++++++++++++++++++++++++++ src/Items/PriceableEveType.php | 18 +++------- 4 files changed, 92 insertions(+), 20 deletions(-) create mode 100644 src/Contracts/HasTypeIDWithAmount.php create mode 100644 src/Items/EveTypeWithAmount.php diff --git a/src/Contracts/HasTypeIDWithAmount.php b/src/Contracts/HasTypeIDWithAmount.php new file mode 100644 index 00000000..5d46d9d8 --- /dev/null +++ b/src/Contracts/HasTypeIDWithAmount.php @@ -0,0 +1,35 @@ +amount = $amount; + } + + /** + * @return int The amount of items + */ + public function getAmount(): int + { + return $this->amount; + } +} diff --git a/src/Items/PriceableEveType.php b/src/Items/PriceableEveType.php index dbe6b95b..6d00de93 100644 --- a/src/Items/PriceableEveType.php +++ b/src/Items/PriceableEveType.php @@ -28,28 +28,18 @@ /** * A basic implementation od IPriceable. */ -class PriceableEveType extends EveType implements IPriceable +class PriceableEveType extends EveTypeWithAmount implements IPriceable { protected float $price; - protected float $amount; /** * @param int|HasTypeID $type_id The eve type to be appraised - * @param float $amount The amount of this type to be appraised + * @param float|int $amount The amount of this type to be appraised */ - public function __construct(int|HasTypeID $type_id, float $amount) + public function __construct(int|HasTypeID $type_id, float|int $amount) { - parent::__construct($type_id); + parent::__construct($type_id, (int) $amount); $this->price = 0; - $this->amount = $amount; - } - - /** - * @return int The amount of this item to be appraised - */ - public function getAmount(): int - { - return $this->amount; } /** From 31974c9de338c44078a579d90108c3e70d480a25 Mon Sep 17 00:00:00 2001 From: recursivetree <60423027+recursivetree@users.noreply.github.com> Date: Fri, 6 Sep 2024 13:20:30 +0200 Subject: [PATCH 33/34] eseye-bindings: allow access token refreshing (#181) --- src/Contracts/EsiClient.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Contracts/EsiClient.php b/src/Contracts/EsiClient.php index 4b468430..815473d6 100644 --- a/src/Contracts/EsiClient.php +++ b/src/Contracts/EsiClient.php @@ -99,4 +99,6 @@ public function getLogger(): LoggerInterface; * @return \Psr\SimpleCache\CacheInterface */ public function getCache(): CacheInterface; + + public function getValidAccessToken(): string; } From e0dae2fb33414ba055a6e0a0624803913b2154c5 Mon Sep 17 00:00:00 2001 From: Crypta Eve Date: Fri, 6 Sep 2024 20:57:38 +0930 Subject: [PATCH 34/34] chore: bump eseye dep --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 4754cda0..cd76a773 100644 --- a/composer.json +++ b/composer.json @@ -35,7 +35,7 @@ "coduo/php-humanizer": "^4.0", "composer/semver": "^3.0", "doctrine/dbal": "^3.0", - "eveseat/eseye": "^3.0", + "eveseat/eseye": "^3.1", "guzzlehttp/guzzle": "^7.0", "laravel/framework": "^10.0", "psr/simple-cache": "^3.0",