adding stuff for stuff

This commit is contained in:
Arjun Patel
2022-01-27 21:46:13 -08:00
parent fd19b0f1bf
commit 133d5f02d0
4 changed files with 49 additions and 12 deletions
+2 -1
View File
@@ -30,5 +30,6 @@ module.exports = {
rules: { rules: {
quotes: ["error", "double"], quotes: ["error", "double"],
// "import/no-unresolved": 0, // "import/no-unresolved": 0,
// "no-unused-vars": "disabled",
}, },
}; }
+2 -1
View File
@@ -8,7 +8,8 @@
"start": "npm run shell", "start": "npm run shell",
"deploy": "firebase deploy --only functions", "deploy": "firebase deploy --only functions",
"logs": "firebase functions:log", "logs": "firebase functions:log",
"hotReload": "tsc --watch" "hotReload": "tsc --watch",
"copyModels": "cp -r ../../web/models /models"
}, },
"engines": { "engines": {
"node": "16" "node": "16"
+4 -1
View File
@@ -9,7 +9,10 @@ admin.initializeApp();
export const helloWorld = functions.https.onRequest((request, response) => { export const helloWorld = functions.https.onRequest((request, response) => {
functions.logger.info("Hello no!", { structuredData: true }); functions.logger.info("Hello no!", { structuredData: true });
response.send("Hello from woahhhhhh!"); response.send("Hello from woahhhhhh!");
}); })
import { agoraToken } from "./agora"; import { agoraToken } from "./agora";
exports.agoraToken = agoraToken; exports.agoraToken = agoraToken;
// import { inviteUserToTeam } from "./notifications";
// exports.inviteUserToTeam = inviteUserToTeam;
+41 -9
View File
@@ -1,17 +1,49 @@
// import * as functions from "firebase-functions"; /* eslint-disable no-unused-vars */
import * as functions from "firebase-functions";
import * as sgMail from "@sendgrid/mail"; import * as sgMail from "@sendgrid/mail";
import { TeamMember, TeamMemberStatus } from "../../../web/models/teamMember";
sgMail.setApiKey( sgMail.setApiKey(
"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" "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"
); );
// exports.inviteUserToTeam = functions.firestore enum SendgridTemplateId {
// .document('teamMembers/{userId}') inviteTeamMember = "d-4953372ac7b94d3fa9419bad4073840f",
// .onCreate(async (snap, context) => { }
// const newTeamMember = snap.data() as TeamMember;
// // access a particular field as you would any JS property class SendGridEmailMessage {
// const name = newValue.name; to: string;
from: string;
templateId: SendgridTemplateId;
dynamic_template_data: {};
// // perform desired operations ... constructor(
// }); _to: string,
_from: string,
_templateId: SendgridTemplateId,
_templateData: {}
) {
this.to = _to;
this.from = _from;
this.templateId = _templateId;
this.dynamic_template_data = _templateData;
}
}
export const inviteUserToTeam = functions.firestore
.document("teamMembers/{teamMemberId}")
.onCreate(async (snap, context) => {
const newTeamMember: TeamMember = snap.data() as TeamMember;
if (newTeamMember.status == TeamMemberStatus.invited) {
functions.logger.info(
"New team member invited...sending email" +
newTeamMember.inviteEmailAddress,
{ structuredData: true }
);
// send email to people
return;
}
})