Added panic handling
This commit is contained in:
@@ -5,30 +5,35 @@ const db = admin.firestore();
|
||||
// // Create and Deploy Your First Cloud Functions
|
||||
// // https://firebase.google.com/docs/functions/write-firebase-functions
|
||||
//
|
||||
exports.messageTester = functions.https.onRequest((request, response) => {
|
||||
functions.logger.info("Message was requested", {structuredData: true});
|
||||
response.send("Sending message");
|
||||
exports.panic = functions.https.onRequest((request, response) => {
|
||||
functions.logger.info("Panic has been issued", {structuredData: true});
|
||||
//Code to make a panic goes here
|
||||
db.collection("panic-events").add({
|
||||
patient: request.body.patient,
|
||||
resolved: false,
|
||||
timestamp: new Date(),
|
||||
});
|
||||
response.send(`patient: ${request.body.patient}`);
|
||||
});
|
||||
|
||||
|
||||
exports.userCreated = functions.auth.user().onCreate((user) => {
|
||||
return admin.auth().setCustomUserClaims(user.uid, {
|
||||
admin: false,
|
||||
role: undefined,
|
||||
});
|
||||
});
|
||||
|
||||
exports.roleDefined = functions.https.onCall((data, context) => {
|
||||
if (data.role == "firstAider") {
|
||||
admin.auth().setCustomUserClaims(user.uid, {
|
||||
role: "firstAider",
|
||||
});
|
||||
} else {
|
||||
return db.collection("users").doc(user.uid).set({
|
||||
role: "patient",
|
||||
});
|
||||
}
|
||||
});
|
||||
// Redundant, I think
|
||||
// exports.roleDefined = functions.https.onCall((data, context) => {
|
||||
// if (data.role == "firstAider") {
|
||||
// admin.auth().setCustomUserClaims(user.uid, {
|
||||
// role: "firstAider",
|
||||
// });
|
||||
// } else {
|
||||
// return db.collection("users").doc(user.uid).set({
|
||||
// role: "patient",
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
|
||||
exports.firstAiderCreated = functions.firestore.document("first-aiders/{userId}/")
|
||||
.onCreate(async (snap, context) => {
|
||||
@@ -43,4 +48,4 @@ exports.firstAiderCreated = functions.firestore.document("patients/{userId}/")
|
||||
role: "patient",
|
||||
});
|
||||
});
|
||||
//patient firstAider
|
||||
//patient firstAider21
|
||||
Reference in New Issue
Block a user