mirror of
https://github.com/wasp-lang/open-saas.git
synced 2025-06-05 12:39:11 +02:00
remove newsletter stuff (#383)
* remove newsletter stuff * Update guided-tour.md * Update deletions
This commit is contained in:
parent
d088cff84b
commit
f98d17b2ad
@ -15,4 +15,4 @@
|
|||||||
+ stripeId String? @unique
|
+ stripeId String? @unique
|
||||||
subscriptionStatus String? // 'active', 'cancel_at_period_end', 'past_due', 'deleted'
|
subscriptionStatus String? // 'active', 'cancel_at_period_end', 'past_due', 'deleted'
|
||||||
subscriptionPlan String? // 'hobby', 'pro'
|
subscriptionPlan String? // 'hobby', 'pro'
|
||||||
sendNewsletter Boolean @default(false)
|
datePaid DateTime?
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
--- template/app/src/server/scripts/dbSeeds.ts
|
--- template/app/src/server/scripts/dbSeeds.ts
|
||||||
+++ opensaas-sh/app/src/server/scripts/dbSeeds.ts
|
+++ opensaas-sh/app/src/server/scripts/dbSeeds.ts
|
||||||
@@ -38,9 +38,11 @@
|
@@ -36,9 +36,11 @@
|
||||||
sendNewsletter: false,
|
isAdmin: false,
|
||||||
credits,
|
credits,
|
||||||
subscriptionStatus,
|
subscriptionStatus,
|
||||||
- lemonSqueezyCustomerPortalUrl: null,
|
- lemonSqueezyCustomerPortalUrl: null,
|
||||||
|
@ -70,7 +70,6 @@ If you are using an older version of the OpenSaaS template with Wasp `v0.13.x` o
|
|||||||
│ ├── file-upload/ # Logic for uploading files to S3.
|
│ ├── file-upload/ # Logic for uploading files to S3.
|
||||||
│ ├── landing-page # Landing page related code
|
│ ├── landing-page # Landing page related code
|
||||||
│ ├── messages # Logic for app user messages.
|
│ ├── messages # Logic for app user messages.
|
||||||
│ ├── newsletter/ # Logic for scheduled recurring newsletter sending.
|
|
||||||
│ ├── payment/ # Logic for handling payments and webhooks.
|
│ ├── payment/ # Logic for handling payments and webhooks.
|
||||||
│ ├── server/ # Scripts, shared server utils, and other server-specific code (NodeJS).
|
│ ├── server/ # Scripts, shared server utils, and other server-specific code (NodeJS).
|
||||||
│ ├── shared/ # Shared constants and util functions.
|
│ ├── shared/ # Shared constants and util functions.
|
||||||
|
@ -326,16 +326,3 @@ page AdminMessagesPage {
|
|||||||
component: import AdminMessages from "@src/messages/MessagesPage"
|
component: import AdminMessages from "@src/messages/MessagesPage"
|
||||||
}
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
//#region Newsletter
|
|
||||||
job sendNewsletter {
|
|
||||||
executor: PgBoss,
|
|
||||||
perform: {
|
|
||||||
fn: import { checkAndQueueNewsletterEmails } from "@src/newsletter/sendNewsletter"
|
|
||||||
},
|
|
||||||
schedule: {
|
|
||||||
cron: "0 7 * * 1" // at 7:00 am every Monday
|
|
||||||
},
|
|
||||||
entities: [User]
|
|
||||||
}
|
|
||||||
//#endregion
|
|
@ -19,7 +19,6 @@ model User {
|
|||||||
lemonSqueezyCustomerPortalUrl String? // You can delete this if you're not using Lemon Squeezy as your payments processor.
|
lemonSqueezyCustomerPortalUrl String? // You can delete this if you're not using Lemon Squeezy as your payments processor.
|
||||||
subscriptionStatus String? // 'active', 'cancel_at_period_end', 'past_due', 'deleted'
|
subscriptionStatus String? // 'active', 'cancel_at_period_end', 'past_due', 'deleted'
|
||||||
subscriptionPlan String? // 'hobby', 'pro'
|
subscriptionPlan String? // 'hobby', 'pro'
|
||||||
sendNewsletter Boolean @default(false)
|
|
||||||
datePaid DateTime?
|
datePaid DateTime?
|
||||||
credits Int @default(3)
|
credits Int @default(3)
|
||||||
|
|
||||||
|
@ -1,54 +0,0 @@
|
|||||||
import { type SendNewsletter } from 'wasp/server/jobs';
|
|
||||||
|
|
||||||
import { type User } from 'wasp/entities';
|
|
||||||
import { emailSender } from 'wasp/server/email';
|
|
||||||
import { type Email } from 'wasp/server/email/core/types'; // TODO fix after it gets fixed in wasp :)
|
|
||||||
|
|
||||||
const emailToSend: Email = {
|
|
||||||
to: '',
|
|
||||||
subject: 'The SaaS App Newsletter',
|
|
||||||
text: 'Hey There! \n\nThis is just a newsletter that sends automatically via cron jobs',
|
|
||||||
html: `<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<title>SaaS App Newsletter</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<p>Hey There!</p>
|
|
||||||
|
|
||||||
<p>This is just a newsletter that sends automatically via cron jobs</p>
|
|
||||||
</body>
|
|
||||||
</html>`,
|
|
||||||
};
|
|
||||||
|
|
||||||
// you could use this function to send newsletters, expiration notices, etc.
|
|
||||||
export const checkAndQueueNewsletterEmails: SendNewsletter<never, void> = async (_args, context) => {
|
|
||||||
// e.g. you could send an offer email 2 weeks before their subscription expires
|
|
||||||
const currentDate = new Date();
|
|
||||||
const twoWeeksFromNow = new Date(currentDate.getTime() + 14 * 24 * 60 * 60 * 1000);
|
|
||||||
|
|
||||||
const users = (await context.entities.User.findMany({
|
|
||||||
where: {
|
|
||||||
datePaid: {
|
|
||||||
equals: twoWeeksFromNow,
|
|
||||||
},
|
|
||||||
sendNewsletter: true,
|
|
||||||
},
|
|
||||||
})) as User[];
|
|
||||||
|
|
||||||
if (users.length === 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await Promise.allSettled(
|
|
||||||
users.map(async (user) => {
|
|
||||||
if (user.email) {
|
|
||||||
try {
|
|
||||||
emailToSend.to = user.email;
|
|
||||||
await emailSender.send(emailToSend);
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error sending notice to user: ', user.id, error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
);
|
|
||||||
};
|
|
@ -35,7 +35,6 @@ function generateMockUserData(): MockUserData {
|
|||||||
username: faker.internet.userName({ firstName, lastName }),
|
username: faker.internet.userName({ firstName, lastName }),
|
||||||
createdAt,
|
createdAt,
|
||||||
isAdmin: false,
|
isAdmin: false,
|
||||||
sendNewsletter: false,
|
|
||||||
credits,
|
credits,
|
||||||
subscriptionStatus,
|
subscriptionStatus,
|
||||||
lemonSqueezyCustomerPortalUrl: null,
|
lemonSqueezyCustomerPortalUrl: null,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user