From 40a8cf8de82621db1084ec77c5f554638c202493 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dicky=20Herlambang=20=28=E8=8A=B1=EF=BC=89?= Date: Tue, 5 Nov 2024 20:04:46 +0700 Subject: [PATCH 1/3] Models: Reset MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Dicky Herlambang (花) --- app/Models/AppLogModel.php | 23 -------------- app/Models/JobLogModel.php | 28 ----------------- app/Models/NotifyLogModel.php | 24 --------------- app/Models/User.php | 58 ----------------------------------- app/Models/cnvModel.php | 31 ------------------- app/Models/compressModel.php | 31 ------------------- app/Models/htmlModel.php | 30 ------------------ app/Models/mergeModel.php | 29 ------------------ app/Models/splitModel.php | 36 ---------------------- app/Models/watermarkModel.php | 40 ------------------------ 10 files changed, 330 deletions(-) delete mode 100644 app/Models/AppLogModel.php delete mode 100644 app/Models/JobLogModel.php delete mode 100644 app/Models/NotifyLogModel.php delete mode 100644 app/Models/User.php delete mode 100644 app/Models/cnvModel.php delete mode 100644 app/Models/compressModel.php delete mode 100644 app/Models/htmlModel.php delete mode 100644 app/Models/mergeModel.php delete mode 100644 app/Models/splitModel.php delete mode 100644 app/Models/watermarkModel.php diff --git a/app/Models/AppLogModel.php b/app/Models/AppLogModel.php deleted file mode 100644 index 3904c70..0000000 --- a/app/Models/AppLogModel.php +++ /dev/null @@ -1,23 +0,0 @@ - - */ - protected $fillable = [ - 'name', - 'email', - 'password', - ]; - - /** - * The attributes that should be hidden for serialization. - * - * @var array - */ - protected $hidden = [ - 'password', - 'remember_token', - ]; - - /** - * Get the attributes that should be cast. - * - * @return array - */ - protected function casts(): array - { - return [ - 'email_verified_at' => 'datetime', - 'password' => 'hashed', - ]; - } - - public function getJWTIdentifier() - { - return $this->getKey(); - } - - public function getJWTCustomClaims() - { - return []; - } -} diff --git a/app/Models/cnvModel.php b/app/Models/cnvModel.php deleted file mode 100644 index 437470c..0000000 --- a/app/Models/cnvModel.php +++ /dev/null @@ -1,31 +0,0 @@ - Date: Tue, 5 Nov 2024 20:05:12 +0700 Subject: [PATCH 2/3] Models: Re-init MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Dicky Herlambang (花) --- app/Models/User.php | 58 +++++++++++++++++++++++++++++++++++ app/Models/appLogModel.php | 23 ++++++++++++++ app/Models/cnvModel.php | 31 +++++++++++++++++++ app/Models/compressModel.php | 31 +++++++++++++++++++ app/Models/htmlModel.php | 30 ++++++++++++++++++ app/Models/jobLogModel.php | 28 +++++++++++++++++ app/Models/mergeModel.php | 29 ++++++++++++++++++ app/Models/notifyLogModel.php | 24 +++++++++++++++ app/Models/splitModel.php | 36 ++++++++++++++++++++++ app/Models/watermarkModel.php | 40 ++++++++++++++++++++++++ 10 files changed, 330 insertions(+) create mode 100644 app/Models/User.php create mode 100644 app/Models/appLogModel.php create mode 100644 app/Models/cnvModel.php create mode 100644 app/Models/compressModel.php create mode 100644 app/Models/htmlModel.php create mode 100644 app/Models/jobLogModel.php create mode 100644 app/Models/mergeModel.php create mode 100644 app/Models/notifyLogModel.php create mode 100644 app/Models/splitModel.php create mode 100644 app/Models/watermarkModel.php diff --git a/app/Models/User.php b/app/Models/User.php new file mode 100644 index 0000000..80e7259 --- /dev/null +++ b/app/Models/User.php @@ -0,0 +1,58 @@ + + */ + protected $fillable = [ + 'name', + 'email', + 'password', + ]; + + /** + * The attributes that should be hidden for serialization. + * + * @var array + */ + protected $hidden = [ + 'password', + 'remember_token', + ]; + + /** + * Get the attributes that should be cast. + * + * @return array + */ + protected function casts(): array + { + return [ + 'email_verified_at' => 'datetime', + 'password' => 'hashed', + ]; + } + + public function getJWTIdentifier() + { + return $this->getKey(); + } + + public function getJWTCustomClaims() + { + return []; + } +} diff --git a/app/Models/appLogModel.php b/app/Models/appLogModel.php new file mode 100644 index 0000000..3904c70 --- /dev/null +++ b/app/Models/appLogModel.php @@ -0,0 +1,23 @@ + Date: Tue, 5 Nov 2024 20:15:25 +0700 Subject: [PATCH 3/3] HOTFIX: Fix may-duplicate logic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Dicky Herlambang (花) --- .../Controllers/Api/Auth/AuthController.php | 3 +- .../Api/Misc/versionController.php | 95 +++++++++++-------- 2 files changed, 57 insertions(+), 41 deletions(-) diff --git a/app/Http/Controllers/Api/Auth/AuthController.php b/app/Http/Controllers/Api/Auth/AuthController.php index 15c09d0..3bf9b88 100644 --- a/app/Http/Controllers/Api/Auth/AuthController.php +++ b/app/Http/Controllers/Api/Auth/AuthController.php @@ -42,7 +42,8 @@ public function getToken() 'Access unauthorized', null, null, - 'Auth breach detected' + null, + 'Auth breach detected, requested with '.json_encode($credentials) ); } diff --git a/app/Http/Controllers/Api/Misc/versionController.php b/app/Http/Controllers/Api/Misc/versionController.php index ca906b9..a133351 100644 --- a/app/Http/Controllers/Api/Misc/versionController.php +++ b/app/Http/Controllers/Api/Misc/versionController.php @@ -24,6 +24,7 @@ public function versioningCheck(Request $request) { ]); $uuid = AppHelper::Instance()->generateSingleUniqueUuid(appLogModel::class, 'processId'); + $Muuid = AppHelper::Instance()->generateSingleUniqueUuid(appLogModel::class, 'groupId'); if ($validator->fails()) { return $this->returnDataMesage( @@ -52,6 +53,13 @@ public function versioningCheck(Request $request) { $validateMessage = ''; $url = 'https://raw.githubusercontent.com/Nicklas373/Hana-PDF/versioning/versioning.json'; + appLogModel::create([ + 'processId' => $uuid, + 'groupId' => $Muuid, + 'errReason' => null, + 'errStatus' => null + ]); + if (appHelper::instance()->checkWebAvailable($url)) { $response = Http::get($url); if ($response->successful()) { @@ -100,19 +108,18 @@ public function versioningCheck(Request $request) { null ); } else { - appLogModel::create([ - 'processId' => $uuid, - 'groupId' => $uuid, - 'errReason' => 'Version Check Failed !', - 'errStatus' => $validateMessage - ]); + appLogModel::where('groupId', '=', $Muuid) + ->update([ + 'errReason' => 'Version Check Failed !', + 'errStatus' => $validateMessage + ]); NotificationHelper::Instance()->sendVersioningErrNotify( $appVersioningFE, $versioningFE, $appVersioningBE, $versioningBE, 'FAIL', - $uuid, + $Muuid, 'Version Check Failed !', $validateMessage ); @@ -127,19 +134,18 @@ public function versioningCheck(Request $request) { ); } } catch (\Exception $e) { - appLogModel::create([ - 'processId' => $uuid, - 'groupId' => $uuid, - 'errReason' => 'Unable to parsing JSON versioning !', - 'errStatus' => $e->getMessage() - ]); + appLogModel::where('groupId', '=', $Muuid) + ->update([ + 'errReason' => 'Unable to parsing JSON versioning !', + 'errStatus' => $e->getMessage() + ]); NotificationHelper::Instance()->sendVersioningErrNotify( null, null, null, null, 'FAIL', - $uuid, + $Muuid, 'Unable to parsing JSON versioning !', $e->getMessage() ); @@ -154,19 +160,18 @@ public function versioningCheck(Request $request) { ); } } else { - appLogModel::create([ - 'processId' => $uuid, - 'groupId' => $uuid, - 'errReason' => 'Version Check Failed !', - 'errStatus' => 'Cannot establish response with the server' - ]); + appLogModel::where('groupId', '=', $Muuid) + ->update([ + 'errReason' => 'Version Check Failed !', + 'errStatus' => 'Cannot establish response with the server' + ]); NotificationHelper::Instance()->sendVersioningErrNotify( null, null, null, null, 'FAIL', - $uuid, + $Muuid, 'Version Check failed !', 'Cannot establish response with the server' ); @@ -181,12 +186,11 @@ public function versioningCheck(Request $request) { ); } } else { - appLogModel::create([ - 'processId' => $uuid, - 'groupId' => $uuid, - 'errReason' => 'Version Check Failed !', - 'errStatus' => 'Cannot establish connection with the server' - ]); + appLogModel::where('groupId', '=', $Muuid) + ->update([ + 'errReason' => 'Version Check Failed !', + 'errStatus' => 'Cannot establish response with the server' + ]); NotificationHelper::Instance()->sendVersioningErrNotify( null, null, @@ -212,9 +216,17 @@ public function versioningCheck(Request $request) { public function versioningFetch(Request $request) { $uuid = AppHelper::Instance()->generateSingleUniqueUuid(appLogModel::class, 'processId'); + $Muuid = AppHelper::Instance()->generateSingleUniqueUuid(appLogModel::class, 'groupId'); $endpoint = 'api/v1/version/fetch'; $versionFetch = 'https://raw.githubusercontent.com/Nicklas373/Hana-PDF/versioning/changelog.json'; + appLogModel::create([ + 'processId' => $uuid, + 'groupId' => $Muuid, + 'errReason' => null, + 'errStatus' => null + ]); + if (appHelper::instance()->checkWebAvailable($versionFetch)) { $response = Http::get($versionFetch); if ($response->successful()) { @@ -229,7 +241,12 @@ public function versioningFetch(Request $request) { null ); } catch (\Exception $e) { - NotificationHelper::Instance()->sendErrGlobalNotify($endpoint, 'Version Fetch', 'FAIL', $uuid,'Failed to parsing JSON !', $e->getMessage(), false); + appLogModel::where('groupId', '=', $Muuid) + ->update([ + 'errReason' => 'Failed to parsing JSON !', + 'errStatus' => $e->getMessage() + ]); + NotificationHelper::Instance()->sendErrGlobalNotify($endpoint, 'Version Fetch', 'FAIL', $Muuid,'Failed to parsing JSON !', $e->getMessage(), false); return $this->returnDataMesage( 400, 'Failed to parsing JSON !', @@ -240,12 +257,11 @@ public function versioningFetch(Request $request) { ); } } else { - appLogModel::create([ - 'processId' => $uuid, - 'groupId' => $uuid, - 'errReason' => 'Versioning Fetch Failed !', - 'errStatus' => 'Failed to fetch response with the server' - ]); + appLogModel::where('groupId', '=', $Muuid) + ->update([ + 'Version fetch failed !', + 'Failed to fetch response with the server' + ]); NotificationHelper::Instance()->sendErrGlobalNotify( $endpoint, 'Version Fetch', @@ -264,12 +280,11 @@ public function versioningFetch(Request $request) { ); } } else { - appLogModel::create([ - 'processId' => $uuid, - 'groupId' => $uuid, - 'errReason' => 'Versioning Fetch Failed !', - 'errStatus' => 'Failed to fetch response with the server' - ]); + appLogModel::where('groupId', '=', $Muuid) + ->update([ + 'Version fetch failed !', + 'Failed to fetch response with the server' + ]); NotificationHelper::Instance()->sendErrGlobalNotify( $endpoint, 'Version Fetch',