Skip to content

Commit

Permalink
fix: display actual error message when email test fails
Browse files Browse the repository at this point in the history
fix: add missing {{days_until}} variable to string version of the webhook
  • Loading branch information
ellite authored Oct 25, 2024
1 parent 4ae414a commit ebc7b83
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
1 change: 1 addition & 0 deletions endpoints/cronjobs/sendnotifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,7 @@
foreach ($perUser as $k => $subscription) {
// Ensure the payload is reset for each subscription
$payload = $webhook['payload'];
$payload = str_replace("{{days_until}}", $days, $payload);
$payload = str_replace("{{subscription_name}}", $subscription['name'], $payload);
$payload = str_replace("{{subscription_price}}", $subscription['price'], $payload);
$payload = str_replace("{{subscription_currency}}", $subscription['currency'], $payload);
Expand Down
25 changes: 16 additions & 9 deletions endpoints/notifications/testemailnotifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,26 @@
$mail->Subject = translate('wallos_notification', $i18n);
$mail->Body = translate('test_notification', $i18n);

if ($mail->send()) {
$response = [
"success" => true,
"message" => translate('notification_sent_successfuly', $i18n)
];
die(json_encode($response));
} else {
try {
if ($mail->send()) {
$response = [
"success" => true,
"message" => translate('notification_sent_successfuly', $i18n)
];
} else {
$response = [
"success" => false,
"message" => translate('email_error', $i18n) . $mail->ErrorInfo
];
}
} catch (Exception $e) {
$response = [
"success" => false,
"message" => translate('email_error', $i18n) . $mail->ErrorInfo
"message" => translate('email_error', $i18n) . $e->getMessage()
];
die(json_encode($response));
}

die(json_encode($response));

}
}
Expand Down
2 changes: 1 addition & 1 deletion includes/version.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php
$version = "v2.31.0";
$version = "v2.31.1";
?>

0 comments on commit ebc7b83

Please sign in to comment.