-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestAssessmentNotification.js
More file actions
25 lines (24 loc) · 975 Bytes
/
testAssessmentNotification.js
File metadata and controls
25 lines (24 loc) · 975 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
const functions = require('firebase-functions');
const config = require('../shared/config');
const { firebase, db } = require('../shared/admin.js');
const { checkArguments } = require('../shared/helpers.js');
const { testAssessmentNotification } = require('../actions/assessments')(config, firebase, db);
module.exports = functions.region('europe-west2').https.onCall(async (data, context) => {
if (!context.auth) {
throw new functions.https.HttpsError('failed-precondition', 'The function must be called while authenticated.');
}
if (!checkArguments({
assessmentId: { required: true },
notificationType: { required: true },
}, data)) {
throw new functions.https.HttpsError('invalid-argument', 'Please provide valid arguments');
}
const result = await testAssessmentNotification({
assessmentId: data.assessmentId,
notificationType: data.notificationType,
email: context.auth.token.email,
});
return {
result: result,
};
});