Skip to content

Commit

Permalink
[HOTFIX][BE] Fix duplicateable logic (#268)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicklas373 authored Nov 5, 2024
2 parents 618ee2f + 06b0009 commit 192de49
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 41 deletions.
3 changes: 2 additions & 1 deletion app/Http/Controllers/Api/Auth/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public function getToken()
'Access unauthorized',
null,
null,
'Auth breach detected'
null,
'Auth breach detected, requested with '.json_encode($credentials)
);
}

Expand Down
95 changes: 55 additions & 40 deletions app/Http/Controllers/Api/Misc/versionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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
);
Expand All @@ -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()
);
Expand All @@ -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'
);
Expand All @@ -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,
Expand All @@ -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()) {
Expand All @@ -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 !',
Expand All @@ -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',
Expand All @@ -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',
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 192de49

Please sign in to comment.