-
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.
[FT] - Remove need for special notes dependency
- Loading branch information
1 parent
fd4d5d4
commit 7bb16b3
Showing
12 changed files
with
503 additions
and
46 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -11,6 +11,21 @@ const { onRequest } = require("firebase-functions/v2/https"); | |
const logger = require("firebase-functions/logger"); | ||
const { beforeUserCreated, HttpsError } = require("firebase-functions/v2/identity") | ||
|
||
// The Cloud Functions for Firebase SDK to set up triggers and logging. | ||
const { onSchedule } = require("firebase-functions/v2/scheduler"); | ||
const nodemailer = require('nodemailer'); | ||
|
||
// The Firebase Admin SDK to delete inactive users. | ||
const admin = require("firebase-admin"); | ||
admin.initializeApp(); | ||
|
||
// The es6-promise-pool to limit the concurrency of promises. | ||
const PromisePool = require("es6-promise-pool").default; | ||
// Maximum concurrent account deletions. | ||
const MAX_CONCURRENT = 3; | ||
|
||
|
||
|
||
// Create and deploy your first functions | ||
// https://firebase.google.com/docs/functions/get-started | ||
|
||
|
@@ -21,9 +36,59 @@ const { beforeUserCreated, HttpsError } = require("firebase-functions/v2/identit | |
// }); | ||
|
||
|
||
var transporter = nodemailer.createTransport({ | ||
service: 'gmail', | ||
auth: { | ||
user: '[email protected]', | ||
pass: '*ADragonWorksHappy28!*' | ||
} | ||
}); | ||
|
||
var mailOptions = { | ||
from: '[email protected]', | ||
to: '[email protected]', | ||
subject: 'Sending Email using Node.js', | ||
text: 'That was easy!' | ||
}; | ||
|
||
|
||
|
||
exports.restrictunAuthUsers = beforeUserCreated(event => { | ||
let user = event.data; | ||
if (!user.email?.includes('@revox.io')) { | ||
if (!user.email?.includes('@revox.io') || !user.email?.includes('@rundownstudios.com')) { | ||
throw new HttpsError('invalid-argument', 'Unauhorized email'); | ||
} | ||
}); | ||
|
||
|
||
// exports.birthdayReminder = onSchedule("every day 00:00", async (event) => { | ||
// // // Fetch all user details. | ||
// // const inactiveUsers = await getInactiveUsers(); | ||
|
||
// // // Use a pool so that we delete maximum `MAX_CONCURRENT` users in parallel. | ||
// // const promisePool = new PromisePool( | ||
// // () => deleteInactiveUser(inactiveUsers), | ||
// // MAX_CONCURRENT, | ||
// // ); | ||
// // await promisePool.start(); | ||
|
||
// transporter.sendMail(mailOptions, function (error, info) { | ||
// if (error) { | ||
// console.log(error); | ||
// } else { | ||
// console.log('Email sent: ' + info.response); | ||
// } | ||
// }); | ||
|
||
// logger.log("User cleanup finished"); | ||
// }); | ||
|
||
exports.scheduledFunctionCrontab = onSchedule("*/30 * * * *", async (event) => { | ||
transporter.sendMail(mailOptions, function (error, info) { | ||
if (error) { | ||
console.log(error); | ||
} else { | ||
console.log('Email sent: ' + info.response); | ||
} | ||
}); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
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
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
Oops, something went wrong.