Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Commit

Permalink
fix(submit): current year error
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinKanera committed Apr 14, 2021
1 parent ad5d0ea commit 07b646f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
3 changes: 2 additions & 1 deletion firebase.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"predeploy": ["node firebase/rules.js"]
},
"functions": {
"predeploy": ["npm --prefix \"$RESOURCE_DIR\" run build"]
"predeploy": ["npm --prefix \"$RESOURCE_DIR\" run build"],
"runtime": "nodejs10"
}
}
3 changes: 0 additions & 3 deletions functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": {
"node": "12"
},
"main": "lib/index.js",
"dependencies": {
"firebase-admin": "9.4.1",
Expand Down
2 changes: 2 additions & 0 deletions functions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ exports.usersHooks = functions.firestore.document('users/{userId}').onWrite(asyn
// proposals
exports.proposalsHooks = functions.firestore.document('proposals/{proposalId}').onWrite(async (snap, context) => {
if ((!snap.before.data() && snap.after.data()) || (snap.before.data() && snap.after.data())) {
if (snap.after.data()?.studentId === '') return;

await db.runTransaction(async (transaction) => {
transaction.set(db.collection('notifications').doc(), {
userId: snap.after.data()?.teacherId,
Expand Down
2 changes: 1 addition & 1 deletion server/api/project/submit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default async (req: Request, res: Response) => {

const system = await transaction.get(systemRef.doc('schoolYear'));

if ((projectData?.currentYear as admin.firestore.Timestamp).isEqual(system.data()?.projectDeadline)) throw new Error('409/2');
if (!(projectData?.currentYear as admin.firestore.Timestamp).isEqual(system.data()?.currentYear)) throw new Error('409/2');

if (sfDoc.data()?.deadlineDate != null) {
if (admin.firestore.Timestamp.now() > sfDoc.data()?.deadlineDate) throw new Error('423');
Expand Down

0 comments on commit 07b646f

Please sign in to comment.