From cf73f1f764c0b5e63c555511860dc292e877fac3 Mon Sep 17 00:00:00 2001 From: Sokhuong Uon Date: Wed, 13 Nov 2024 09:47:22 +0700 Subject: [PATCH 1/5] fix(signin): fix broken link to password reset docs --- apps/dokploy/pages/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/dokploy/pages/index.tsx b/apps/dokploy/pages/index.tsx index b5c049e17..ac196ff56 100644 --- a/apps/dokploy/pages/index.tsx +++ b/apps/dokploy/pages/index.tsx @@ -199,7 +199,7 @@ export default function Home({ IS_CLOUD }: Props) { ) : ( Lost your password? From 59bb59ee24c859482c7e439b428d23960b8226ba Mon Sep 17 00:00:00 2001 From: limichange Date: Wed, 13 Nov 2024 16:30:11 +0800 Subject: [PATCH 2/5] Update docker-compose.yml --- apps/dokploy/templates/plausible/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/dokploy/templates/plausible/docker-compose.yml b/apps/dokploy/templates/plausible/docker-compose.yml index 62ce5ece4..bb267f65c 100644 --- a/apps/dokploy/templates/plausible/docker-compose.yml +++ b/apps/dokploy/templates/plausible/docker-compose.yml @@ -26,7 +26,7 @@ services: hard: 262144 plausible: - image: ghcr.io/plausible/community-edition:v2.1.0 + image: ghcr.io/plausible/community-edition:v2.1.4 restart: always command: sh -c "sleep 10 && /entrypoint.sh db createdb && /entrypoint.sh db migrate && /entrypoint.sh run" depends_on: From 46f7d43595a7dbe4d377fbf9aee875f1988e63a2 Mon Sep 17 00:00:00 2001 From: limichange Date: Thu, 14 Nov 2024 09:37:20 +0800 Subject: [PATCH 3/5] Update templates.ts --- apps/dokploy/templates/templates.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/dokploy/templates/templates.ts b/apps/dokploy/templates/templates.ts index 28af7c56e..e328ab0ba 100644 --- a/apps/dokploy/templates/templates.ts +++ b/apps/dokploy/templates/templates.ts @@ -34,7 +34,7 @@ export const templates: TemplateData[] = [ { id: "plausible", name: "Plausible", - version: "v2.1.0", + version: "v2.1.4", description: "Plausible is a open source, self-hosted web analytics platform that lets you track website traffic and user behavior.", logo: "plausible.svg", From 17e9a1a49722acb127ad300d4df36b102804c658 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Wed, 13 Nov 2024 23:29:24 -0600 Subject: [PATCH 4/5] fix(stripe): attempt to fix the servers assignation when the user pay --- apps/dokploy/pages/api/stripe/webhook.ts | 66 +++++++++++++++++------- 1 file changed, 46 insertions(+), 20 deletions(-) diff --git a/apps/dokploy/pages/api/stripe/webhook.ts b/apps/dokploy/pages/api/stripe/webhook.ts index c6364d945..d4599f784 100644 --- a/apps/dokploy/pages/api/stripe/webhook.ts +++ b/apps/dokploy/pages/api/stripe/webhook.ts @@ -88,7 +88,6 @@ export default async function handler( .update(admins) .set({ stripeSubscriptionId: newSubscription.id, - serversQuantity: 0, stripeCustomerId: newSubscription.customer as string, }) .where(eq(admins.stripeCustomerId, newSubscription.customer as string)) @@ -121,12 +120,6 @@ export default async function handler( } case "customer.subscription.updated": { const newSubscription = event.data.object as Stripe.Subscription; - await db - .update(admins) - .set({ - serversQuantity: newSubscription?.items?.data?.[0]?.quantity ?? 0, - }) - .where(eq(admins.stripeCustomerId, newSubscription.customer as string)); const admin = await findAdminByStripeCustomerId( newSubscription.customer as string, @@ -136,8 +129,27 @@ export default async function handler( return res.status(400).send("Webhook Error: Admin not found"); } - const newServersQuantity = admin.serversQuantity; - await updateServersBasedOnQuantity(admin.adminId, newServersQuantity); + if (newSubscription.status === "active") { + await db + .update(admins) + .set({ + serversQuantity: newSubscription?.items?.data?.[0]?.quantity ?? 0, + }) + .where( + eq(admins.stripeCustomerId, newSubscription.customer as string), + ); + + const newServersQuantity = admin.serversQuantity; + await updateServersBasedOnQuantity(admin.adminId, newServersQuantity); + } else { + await disableServers(admin.adminId); + await db + .update(admins) + .set({ serversQuantity: 0 }) + .where( + eq(admins.stripeCustomerId, newSubscription.customer as string), + ); + } break; } @@ -148,6 +160,13 @@ export default async function handler( newInvoice.subscription as string, ); + if (suscription.status !== "active") { + console.log( + `Skipping invoice.payment_succeeded for subscription ${suscription.id} with status ${suscription.status}`, + ); + break; + } + await db .update(admins) .set({ @@ -168,22 +187,29 @@ export default async function handler( } case "invoice.payment_failed": { const newInvoice = event.data.object as Stripe.Invoice; - await db - .update(admins) - .set({ - serversQuantity: 0, - }) - .where(eq(admins.stripeCustomerId, newInvoice.customer as string)); - const admin = await findAdminByStripeCustomerId( - newInvoice.customer as string, + const subscription = await stripe.subscriptions.retrieve( + newInvoice.subscription as string, ); - if (!admin) { - return res.status(400).send("Webhook Error: Admin not found"); + if (subscription.status !== "active") { + const admin = await findAdminByStripeCustomerId( + newInvoice.customer as string, + ); + + if (!admin) { + return res.status(400).send("Webhook Error: Admin not found"); + } + await db + .update(admins) + .set({ + serversQuantity: 0, + }) + .where(eq(admins.stripeCustomerId, newInvoice.customer as string)); + + await disableServers(admin.adminId); } - await disableServers(admin.adminId); break; } From b6ab653ef3b85f0ac1c05400b5efeb79acd3782c Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Wed, 13 Nov 2024 23:30:33 -0600 Subject: [PATCH 5/5] chore(version): bump version --- apps/dokploy/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/dokploy/package.json b/apps/dokploy/package.json index ebee5cac0..61db1ff98 100644 --- a/apps/dokploy/package.json +++ b/apps/dokploy/package.json @@ -1,6 +1,6 @@ { "name": "dokploy", - "version": "v0.11.1", + "version": "v0.11.2", "private": true, "license": "Apache-2.0", "type": "module",