Skip to content

Commit

Permalink
Helpers: Notification: Fixup overleft database update scheme
Browse files Browse the repository at this point in the history
Signed-off-by: Dicky Herlambang (花) <herlambangdicky5@gmail.com>
  • Loading branch information
Nicklas373 committed May 12, 2024
1 parent f0d6e9d commit 3db106c
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions app/Helpers/NotificationHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,17 @@ function sendRouteErrNotify($processId, $status, $errReason, $errRoute, $errCode
$messageId = $response->getMessageId();

try {
DB::table('appLogs')->insert([
'processId' => $processId,
'errReason' => null,
'errApiReason' => null,
]);
DB::table('notifyLogs')->insert([
'processId' => $processId,
'notifyName' => 'Telegram SDK',
'notifyResult' => true,
'notifyMessage' => 'Message has been sent !',
'notifyResponse' => $response,
'notifyErrStatus' => $errReason,
'notifyErrMessage' => $errCode
'notifyResponse' => $response
]);
} catch (QueryException $ex) {
Log::error('Query Exception failed with: '. $ex->getMessage());
Expand All @@ -55,28 +58,34 @@ function sendRouteErrNotify($processId, $status, $errReason, $errRoute, $errCode
} else {
$httpStatus = $e->getHttpStatusCode();
}
DB::table('appLogs')->insert([
'processId' => $processId,
'errReason' => 'TelegramResponseException',
'errApiReason' => $e->getMessage(),
]);
DB::table('notifyLogs')->insert([
'processId' => $processId,
'notifyName' => 'Telegram SDK',
'notifyResult' => false,
'notifyMessage' => $e->getMessage(),
'notifyResponse' => null,
'notifyErrStatus' => $httpStatus,
'notifyErrMessage' => $e->getErrorType()
'notifyMessage' => 'TelegramResponseException',
'notifyResponse' => $e->getMessage()+' | '+$httpStatus+' | '+$e->getErrorType()
]);
} catch (QueryException $ex) {
Log::error('Query Exception failed with: '. $ex->getMessage());
}
} catch (\Exception $e) {
try {
DB::table('appLogs')->insert([
'processId' => $processId,
'errReason' => 'Unexpected handling exception !',
'errApiReason' => $e->getMessage(),
]);
DB::table('notifyLogs')->insert([
'processId' => $processId,
'notifyName' => 'Telegram SDK',
'notifyResult' => false,
'notifyMessage' => 'Unexpected handling exception !',
'notifyResponse' => null,
'notifyErrStatus' => null,
'notifyErrMessage' => $e->getMessage()
'notifyResponse' => $e->getMessage()
]);
} catch (QueryException $ex) {
Log::error('Query Exception failed with: '. $ex->getMessage());
Expand Down

0 comments on commit 3db106c

Please sign in to comment.