-
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
34 additions
and
5 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 |
---|---|---|
|
@@ -44,10 +44,31 @@ firebase_admin_1["default"].initializeApp({ | |
databaseURL: 'https://qmi-test.firebaseio.com' | ||
}); | ||
dotenv.config(); | ||
// eslint-disable-next-line no-console | ||
console.log(process.env.RESEND_API_KEY); | ||
var resend = new resend_1.Resend(process.env.RESEND_API_KEY); | ||
/* Returns an array of email objects to send - should be at most 100 per day. | ||
totalEmails is | ||
batchSize should be 49 or less to maintain free emailing */ | ||
var createBatches = function (totalEmails, batchSize) { | ||
var i = 0; | ||
var emailObjs = []; | ||
if (batchSize > 49) { | ||
console.log("Batch size is too large. Must be no more than 49"); | ||
} | ||
while (i < totalEmails.length && emailObjs.length <= 100) { | ||
emailObjs.push({ | ||
from: '[email protected]', | ||
to: ['[email protected]'], | ||
bcc: totalEmails.slice(i, Math.min(i + batchSize, totalEmails.length)), | ||
subject: 'QMI testing batch ' + i + '!', | ||
html: '<strong>It works!</strong>' | ||
}); | ||
i += batchSize; | ||
} | ||
if (emailObjs.length == 100) { | ||
// eslint-disable-next-line no-console | ||
console.log("Reached email limit of 100 emails per day."); | ||
} | ||
return emailObjs; | ||
}; | ||
(function () { return __awaiter(void 0, void 0, void 0, function () { | ||
var usersRef, usersSnapshot, userEmails, data, error_1; | ||
|
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