commit
7349068b95
@ -2,12 +2,14 @@
|
|||||||
|
|
||||||
namespace App\Console\Commands;
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Jobs\SendConfirmationForWaitlistJob;
|
||||||
use App\Models\Application;
|
use App\Models\Application;
|
||||||
use App\Models\ApplicationPreview;
|
use App\Models\ApplicationPreview;
|
||||||
use App\Models\ScheduledDatabaseBackup;
|
use App\Models\ScheduledDatabaseBackup;
|
||||||
use App\Models\StandalonePostgresql;
|
use App\Models\StandalonePostgresql;
|
||||||
use App\Models\TeamInvitation;
|
use App\Models\TeamInvitation;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
use App\Models\Waitlist;
|
||||||
use App\Notifications\Application\DeploymentFailed;
|
use App\Notifications\Application\DeploymentFailed;
|
||||||
use App\Notifications\Application\DeploymentSuccess;
|
use App\Notifications\Application\DeploymentSuccess;
|
||||||
use App\Notifications\Application\StatusChanged;
|
use App\Notifications\Application\StatusChanged;
|
||||||
@ -19,6 +21,7 @@ use Exception;
|
|||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Illuminate\Mail\Message;
|
use Illuminate\Mail\Message;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
|
use Illuminate\Support\Facades\Process;
|
||||||
use Mail;
|
use Mail;
|
||||||
use Str;
|
use Str;
|
||||||
|
|
||||||
@ -148,23 +151,20 @@ class TestEmail extends Command
|
|||||||
case 'waitlist-invitation-link':
|
case 'waitlist-invitation-link':
|
||||||
$this->mail = new MailMessage();
|
$this->mail = new MailMessage();
|
||||||
$this->mail->view('emails.waitlist-invitation', [
|
$this->mail->view('emails.waitlist-invitation', [
|
||||||
'email' => 'test2@example.com',
|
'loginLink' => 'https://coolify.io',
|
||||||
'password' => "supersecretpassword",
|
|
||||||
]);
|
]);
|
||||||
$this->mail->subject('Congratulations! You are invited to join Coolify Cloud.');
|
$this->mail->subject('Congratulations! You are invited to join Coolify Cloud.');
|
||||||
$this->sendEmail();
|
$this->sendEmail();
|
||||||
break;
|
break;
|
||||||
case 'waitlist-confirmation':
|
case 'waitlist-confirmation':
|
||||||
$this->mail = new MailMessage();
|
$found = Waitlist::where('email', $this->email)->first();
|
||||||
$this->mail->view(
|
if ($found) {
|
||||||
'emails.waitlist-confirmation',
|
SendConfirmationForWaitlistJob::dispatch($this->email, $found->uuid);
|
||||||
[
|
|
||||||
'confirmation_url' => 'http://example.com',
|
} else {
|
||||||
'cancel_url' => 'http://example.com',
|
throw new Exception('Waitlist not found');
|
||||||
]
|
}
|
||||||
);
|
|
||||||
$this->mail->subject('You are on the waitlist!');
|
|
||||||
$this->sendEmail();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,8 +91,6 @@ class WaitlistInvite extends Command
|
|||||||
$loginLink = route('auth.link', ['token' => $token]);
|
$loginLink = route('auth.link', ['token' => $token]);
|
||||||
$mail = new MailMessage();
|
$mail = new MailMessage();
|
||||||
$mail->view('emails.waitlist-invitation', [
|
$mail->view('emails.waitlist-invitation', [
|
||||||
'email' => $this->next_patient->email,
|
|
||||||
'password' => $this->password,
|
|
||||||
'loginLink' => $loginLink,
|
'loginLink' => $loginLink,
|
||||||
]);
|
]);
|
||||||
$mail->subject('Congratulations! You are invited to join Coolify Cloud.');
|
$mail->subject('Congratulations! You are invited to join Coolify Cloud.');
|
||||||
|
@ -27,7 +27,7 @@ class CleanupInstanceStuffsJob implements ShouldQueue, ShouldBeUnique
|
|||||||
public function handle(): void
|
public function handle(): void
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$this->cleanup_waitlist();
|
// $this->cleanup_waitlist();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
send_internal_notification('CleanupInstanceStuffsJob failed with error: ' . $e->getMessage());
|
send_internal_notification('CleanupInstanceStuffsJob failed with error: ' . $e->getMessage());
|
||||||
ray($e->getMessage());
|
ray($e->getMessage());
|
||||||
|
@ -25,10 +25,8 @@ class SendConfirmationForWaitlistJob implements ShouldQueue
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$mail = new MailMessage();
|
$mail = new MailMessage();
|
||||||
|
|
||||||
$confirmation_url = base_url() . '/webhooks/waitlist/confirm?email=' . $this->email . '&confirmation_code=' . $this->uuid;
|
$confirmation_url = base_url() . '/webhooks/waitlist/confirm?email=' . $this->email . '&confirmation_code=' . $this->uuid;
|
||||||
$cancel_url = base_url() . '/webhooks/waitlist/cancel?email=' . $this->email . '&confirmation_code=' . $this->uuid;
|
$cancel_url = base_url() . '/webhooks/waitlist/cancel?email=' . $this->email . '&confirmation_code=' . $this->uuid;
|
||||||
|
|
||||||
$mail->view('emails.waitlist-confirmation',
|
$mail->view('emails.waitlist-confirmation',
|
||||||
[
|
[
|
||||||
'confirmation_url' => $confirmation_url,
|
'confirmation_url' => $confirmation_url,
|
||||||
@ -37,7 +35,7 @@ class SendConfirmationForWaitlistJob implements ShouldQueue
|
|||||||
$mail->subject('You are on the waitlist!');
|
$mail->subject('You are on the waitlist!');
|
||||||
send_user_an_email($mail, $this->email);
|
send_user_an_email($mail, $this->email);
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
send_internal_notification("SendConfirmationForWaitlistJob failed for {$mail} with error: " . $th->getMessage());
|
send_internal_notification("SendConfirmationForWaitlistJob failed for {$this->email} with error: " . $th->getMessage());
|
||||||
ray($th->getMessage());
|
ray($th->getMessage());
|
||||||
throw $th;
|
throw $th;
|
||||||
}
|
}
|
||||||
|
@ -181,14 +181,24 @@ Route::get('/waitlist/confirm', function () {
|
|||||||
ray($email, $confirmation_code);
|
ray($email, $confirmation_code);
|
||||||
try {
|
try {
|
||||||
$found = Waitlist::where('uuid', $confirmation_code)->where('email', $email)->first();
|
$found = Waitlist::where('uuid', $confirmation_code)->where('email', $email)->first();
|
||||||
if ($found && !$found->verified && $found->created_at > now()->subMinutes(config('constants.waitlist.expiration'))) {
|
if ($found) {
|
||||||
$found->verified = true;
|
if (!$found->verified) {
|
||||||
$found->save();
|
if ($found->created_at > now()->subMinutes(config('constants.waitlist.expiration'))) {
|
||||||
send_internal_notification('Waitlist confirmed: ' . $email);
|
$found->verified = true;
|
||||||
return 'Thank you for confirming your email address. We will notify you when you are next in line.';
|
$found->save();
|
||||||
|
send_internal_notification('Waitlist confirmed: ' . $email);
|
||||||
|
return 'Thank you for confirming your email address. We will notify you when you are next in line.';
|
||||||
|
} else {
|
||||||
|
$found->delete();
|
||||||
|
send_internal_notification('Waitlist expired: ' . $email);
|
||||||
|
return 'Your confirmation code has expired. Please sign up again.';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return redirect()->route('dashboard');
|
return redirect()->route('dashboard');
|
||||||
} catch (error) {
|
} catch (Exception $e) {
|
||||||
|
send_internal_notification('Waitlist confirmation failed: ' . $e->getMessage());
|
||||||
|
ray($e->getMessage());
|
||||||
return redirect()->route('dashboard');
|
return redirect()->route('dashboard');
|
||||||
}
|
}
|
||||||
})->name('webhooks.waitlist.confirm');
|
})->name('webhooks.waitlist.confirm');
|
||||||
@ -203,7 +213,9 @@ Route::get('/waitlist/cancel', function () {
|
|||||||
return 'Your email address has been removed from the waitlist.';
|
return 'Your email address has been removed from the waitlist.';
|
||||||
}
|
}
|
||||||
return redirect()->route('dashboard');
|
return redirect()->route('dashboard');
|
||||||
} catch (error) {
|
} catch (Exception $e) {
|
||||||
|
send_internal_notification('Waitlist cancellation failed: ' . $e->getMessage());
|
||||||
|
ray($e->getMessage());
|
||||||
return redirect()->route('dashboard');
|
return redirect()->route('dashboard');
|
||||||
}
|
}
|
||||||
})->name('webhooks.waitlist.cancel');
|
})->name('webhooks.waitlist.cancel');
|
||||||
@ -225,7 +237,7 @@ Route::post('/payments/stripe/events', function () {
|
|||||||
]);
|
]);
|
||||||
$type = data_get($event, 'type');
|
$type = data_get($event, 'type');
|
||||||
$data = data_get($event, 'data.object');
|
$data = data_get($event, 'data.object');
|
||||||
ray('Event: '. $type);
|
ray('Event: ' . $type);
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'checkout.session.completed':
|
case 'checkout.session.completed':
|
||||||
$clientReferenceId = data_get($data, 'client_reference_id');
|
$clientReferenceId = data_get($data, 'client_reference_id');
|
||||||
@ -263,13 +275,13 @@ Route::post('/payments/stripe/events', function () {
|
|||||||
'stripe_invoice_paid' => true,
|
'stripe_invoice_paid' => true,
|
||||||
]);
|
]);
|
||||||
break;
|
break;
|
||||||
// case 'invoice.payment_failed':
|
// case 'invoice.payment_failed':
|
||||||
// $customerId = data_get($data, 'customer');
|
// $customerId = data_get($data, 'customer');
|
||||||
// $subscription = Subscription::where('stripe_customer_id', $customerId)->first();
|
// $subscription = Subscription::where('stripe_customer_id', $customerId)->first();
|
||||||
// if ($subscription) {
|
// if ($subscription) {
|
||||||
// SubscriptionInvoiceFailedJob::dispatch($subscription->team);
|
// SubscriptionInvoiceFailedJob::dispatch($subscription->team);
|
||||||
// }
|
// }
|
||||||
// break;
|
// break;
|
||||||
case 'customer.subscription.updated':
|
case 'customer.subscription.updated':
|
||||||
$customerId = data_get($data, 'customer');
|
$customerId = data_get($data, 'customer');
|
||||||
$subscription = Subscription::where('stripe_customer_id', $customerId)->firstOrFail();
|
$subscription = Subscription::where('stripe_customer_id', $customerId)->firstOrFail();
|
||||||
@ -287,9 +299,9 @@ Route::post('/payments/stripe/events', function () {
|
|||||||
]);
|
]);
|
||||||
ray($feedback, $comment, $alreadyCancelAtPeriodEnd, $cancelAtPeriodEnd);
|
ray($feedback, $comment, $alreadyCancelAtPeriodEnd, $cancelAtPeriodEnd);
|
||||||
if ($feedback) {
|
if ($feedback) {
|
||||||
$reason = "Cancellation feedback for {$subscription->team->id}: '" . $feedback ."'";
|
$reason = "Cancellation feedback for {$subscription->team->id}: '" . $feedback . "'";
|
||||||
if ($comment) {
|
if ($comment) {
|
||||||
$reason .= ' with comment: \'' . $comment ."'";
|
$reason .= ' with comment: \'' . $comment . "'";
|
||||||
}
|
}
|
||||||
send_internal_notification($reason);
|
send_internal_notification($reason);
|
||||||
}
|
}
|
||||||
@ -307,7 +319,7 @@ Route::post('/payments/stripe/events', function () {
|
|||||||
$subscription = Subscription::where('stripe_customer_id', $customerId)->firstOrFail();
|
$subscription = Subscription::where('stripe_customer_id', $customerId)->firstOrFail();
|
||||||
$subscription->update([
|
$subscription->update([
|
||||||
'stripe_subscription_id' => null,
|
'stripe_subscription_id' => null,
|
||||||
'stripe_plan_id'=> null,
|
'stripe_plan_id' => null,
|
||||||
'stripe_cancel_at_period_end' => false,
|
'stripe_cancel_at_period_end' => false,
|
||||||
'stripe_invoice_paid' => false,
|
'stripe_invoice_paid' => false,
|
||||||
]);
|
]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user