-
Hola! ${data.userName} has invited you to the session ${data.name}. ${data.desc.length > 0 ? 'The description of the session is "' + data.desc + '"' : ''}
+ ${data.registered === true
+ ? `
Hola! ${data.userName} has invited you to the session ${data.name}. ${data.desc.length > 0 ? 'The description of the session is "' + data.desc + '"' : ''}
`
+ : `
Hola! Werk is a productivity app. Your friend ${data.userName} has invited to the session
${data.name} in the app. ${data.desc.length > 0 ? 'The description of the session is ' + data.desc + '.' : ''}`}
You can join the session by entering the access code: ${data.code} in the Werk App. You can also join the session by scanning the given QRCode in the Werk app.
From 7025825c02fb93ce7bb4c4d90bb191a201c7d2e7 Mon Sep 17 00:00:00 2001
From: vishal-1408
Date: Sun, 8 Aug 2021 13:48:44 +0530
Subject: [PATCH 10/10] fix: bugs due to previous new feature addition
---
api/controllers/session.js | 81 ++++++++++++++++++++++++++++++++++++++
api/middlewares/auth.js | 2 +-
2 files changed, 82 insertions(+), 1 deletion(-)
diff --git a/api/controllers/session.js b/api/controllers/session.js
index d7a8c88..fb51232 100644
--- a/api/controllers/session.js
+++ b/api/controllers/session.js
@@ -217,3 +217,84 @@ exports.getParticipants = async (req, res) => {
})
}
}
+
+// exports.addParticipants = async (req, res) => {
+// try {
+// // start and end time are in epoch format
+// const { participants } = req.body
+// const sid = req.params.id
+// if (!participants.length) throw new BadRequest('All required fields are not provided')
+
+// const session = await Session.findByPk(sid)
+
+// if (!session) throw new BadRequest('Session doesn\'t exist')
+
+// const participantsFiltered = participants.filter(p => p !== req.user.email)
+
+// if (!participantsFiltered.length) throw new BadRequest('Don\'t give your own email while creation of session')
+
+// const result = await User.findAll({
+// attributes: ['userId', 'email', 'registered'],
+// where: {
+// email: participantsFiltered
+// }
+// })
+// const newParticipants = []
+// let check
+// for (const x of participantsFiltered) {
+// check = 0
+// for (const y of result) {
+// if (x === y.email) check = 1
+// }
+// if (!check) {
+// newParticipants.push({
+// name: 'Guest@' + crypto.randomBytes(2).toString('hex'),
+// email: x,
+// registered: false
+// })
+// }
+// }
+
+// result.push(...await User.bulkCreate(newParticipants))
+// console.log(result)
+
+// const data = await generateQRCode(session.accessCode)
+
+// // const session = await Session.create({
+// // sessionName: name,
+// // sessionDescription: description,
+// // startTime,
+// // endTime,
+// // createdBy: req.user.userId,
+// // taskCreationUniv: taskCreationByAll,
+// // taskAssignUniv: taskAssignByAll,
+// // accessCode,
+// // qrCode: data.Location
+// // })
+
+// result.splice(0, 0, req.user)
+// const participantsArray = []
+// result.forEach(async (p, i) => {
+// participantsArray.push({
+// sId: session.sessionId,
+// userId: p.userId,
+// joined: i === 0
+// })
+// })
+
+// await Participant.bulkCreate(participantsArray)
+
+// result.forEach(async (p, i) => {
+// if (i !== 0) await sendAccessCode(accessCode, p.email, req.user.name, data.Location, name, description, p.registered)
+// })
+
+// res.status(200).json({
+// session: { ...session.dataValues }
+// })
+// } catch (e) {
+// console.log(e)
+// res.status(e.status || 500).json({
+// error: e.status ? e.message : e.toString()
+// })
+// }
+// }
diff --git a/api/middlewares/auth.js b/api/middlewares/auth.js
index 0cc97a5..482f792 100644
--- a/api/middlewares/auth.js
+++ b/api/middlewares/auth.js
@@ -17,7 +17,7 @@ const authMiddleware = async (req, res, next) => {
}
})
if (!searchedUser.length) throw new Unauthorized('User is not registered!')
- if (!searchedUser[0].emailVerified) throw new Unauthorized('EMail is not verified!')
+ if (!searchedUser[0].emailVerified) throw new Unauthorized('Email is not verified!')
req.user = searchedUser[0]
next()