-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
18 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,11 +42,10 @@ var dotenv = require("dotenv"); | |
var wrapped_html_1 = require("./wrapped-html"); | ||
firebase_admin_1["default"].initializeApp({ | ||
credential: firebase_admin_1["default"].credential.applicationDefault(), | ||
databaseURL: 'https://qmi-test.firebaseio.com' | ||
databaseURL: 'https://queue-me-in-prod.firebaseio.com' | ||
}); | ||
dotenv.config(); | ||
var resend = new resend_1.Resend(process.env.RESEND_API_KEY); | ||
// DO NOT SEND TO ACTUAL PROD YET YOU HAVENT CHANGED SUBJECT LINE | ||
/** Returns an array of email objects to send - should be at most 100 per day. | ||
- totalEmails is a list of all the user emails to send to. | ||
- batchSize should be 49 or less to maintain free emailing. | ||
|
@@ -60,18 +59,19 @@ var createBatches = function (totalEmails, batchSize) { | |
while (i < totalEmails.length && emailObjs.length <= 100) { | ||
emailObjs.push({ | ||
from: '[email protected]', | ||
// make below the dti address or something cause recievers can see | ||
// but dti will not see recievers | ||
to: ['[email protected]'], | ||
// This is the dti address because recievers can see, but dti will not see recievers. | ||
to: ['[email protected]'], | ||
bcc: totalEmails.slice(i, Math.min(i + batchSize, totalEmails.length)), | ||
subject: 'Check Out Your QMI Wrapped! : batch ' + i, | ||
subject: 'Check Out Your QMI Wrapped!', | ||
html: wrapped_html_1.HTML | ||
}); | ||
// eslint-disable-next-line no-console | ||
// console.log("bcc list: " + totalEmails.slice(i, Math.min(i+batchSize, totalEmails.length))); | ||
i += batchSize; | ||
} | ||
if (emailObjs.length === 100) { | ||
// eslint-disable-next-line no-console | ||
console.log("Reached email limit of 100 emails per day."); | ||
console.log("Reached email limit of 100 emails per day, stopped at i=" + i + ", user " + totalEmails[i] + ". \n Continue from this user the next day."); | ||
} | ||
return emailObjs; | ||
}; | ||
|
@@ -101,16 +101,9 @@ var createBatches = function (totalEmails, batchSize) { | |
_a.label = 3; | ||
case 3: | ||
_a.trys.push([3, 5, , 6]); | ||
return [4 /*yield*/, resend.batch.send(createBatches(["[email protected]"], 49))]; | ||
return [4 /*yield*/, resend.batch.send(createBatches(userEmails, 49))]; | ||
case 4: | ||
data = _a.sent(); | ||
// const data = await resend.emails.send({ | ||
// from: '[email protected]', | ||
// to: ['[email protected]'], | ||
// bcc: ['[email protected]'], | ||
// subject: 'Check Out Your QMI Wrapped!', | ||
// html: HTML | ||
// }); | ||
// eslint-disable-next-line no-console | ||
console.log("Emails have been sent!"); | ||
// eslint-disable-next-line no-console | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,15 +5,13 @@ import { HTML } from "./wrapped-html"; | |
|
||
admin.initializeApp({ | ||
credential: admin.credential.applicationDefault(), | ||
databaseURL: 'https://qmi-test.firebaseio.com' | ||
databaseURL: 'https://queue-me-in-prod.firebaseio.com' | ||
|
||
}); | ||
|
||
dotenv.config(); | ||
const resend = new Resend(process.env.RESEND_API_KEY); | ||
|
||
// DO NOT SEND TO ACTUAL PROD YET YOU HAVENT CHANGED SUBJECT LINE | ||
|
||
/** Returns an array of email objects to send - should be at most 100 per day. | ||
- totalEmails is a list of all the user emails to send to. | ||
- batchSize should be 49 or less to maintain free emailing. | ||
|
@@ -29,19 +27,21 @@ const createBatches = (totalEmails: string[], batchSize: number) => { | |
emailObjs.push( | ||
{ | ||
from: '[email protected]', | ||
// make below the dti address or something cause recievers can see | ||
// but dti will not see recievers | ||
to: ['[email protected]'], | ||
// This is the dti address because recievers can see, but dti will not see recievers. | ||
to: ['[email protected]'], | ||
bcc: totalEmails.slice(i, Math.min(i+batchSize, totalEmails.length)), | ||
subject: 'Check Out Your QMI Wrapped! : batch ' + i, | ||
subject: 'Check Out Your QMI Wrapped!', | ||
html: HTML | ||
} | ||
) | ||
// eslint-disable-next-line no-console | ||
// console.log("bcc list: " + totalEmails.slice(i, Math.min(i+batchSize, totalEmails.length))); | ||
i+= batchSize; | ||
} | ||
if (emailObjs.length === 100) { | ||
// eslint-disable-next-line no-console | ||
console.log("Reached email limit of 100 emails per day.") | ||
console.log(`Reached email limit of 100 emails per day, stopped at i=${i}, user ${totalEmails[i]}. | ||
Continue from this user the next day.`) | ||
} | ||
return emailObjs; | ||
|
||
|
@@ -69,15 +69,8 @@ const createBatches = (totalEmails: string[], batchSize: number) => { | |
try { | ||
// ALT: | ||
const data = await resend.batch.send( | ||
createBatches(["[email protected]"], 49)); | ||
|
||
// const data = await resend.emails.send({ | ||
// from: '[email protected]', | ||
// to: ['[email protected]'], | ||
// bcc: ['[email protected]'], | ||
// subject: 'Check Out Your QMI Wrapped!', | ||
// html: HTML | ||
// }); | ||
createBatches(userEmails, 49) | ||
); | ||
// eslint-disable-next-line no-console | ||
console.log("Emails have been sent!"); | ||
// eslint-disable-next-line no-console | ||
|