Skip to content

Commit bca3a10

Browse files
authored
Merge pull request #182 from ksraj123/feature-ticketing
Feature Ticketing System
2 parents a0b1bf3 + b4eca5c commit bca3a10

File tree

9 files changed

+994
-3
lines changed

9 files changed

+994
-3
lines changed

app.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const notificationRouter = require('./app/routes/notification')
2828
const proposalRouter = require('./app/routes/proposal')
2929
const analyticsRouter = require('./app/routes/analytics')
3030
const activityRouter = require('./app/routes/activity')
31+
const ticketRouter = require('./app/routes/ticket')
3132

3233
const app = express()
3334
const server = require('http').Server(app)
@@ -107,6 +108,7 @@ app.use('/project', projectRouter)
107108
app.use('/proposal', proposalRouter)
108109
app.use('/analytics', analyticsRouter)
109110
app.use('/activity', activityRouter)
111+
app.use('/ticket', ticketRouter)
110112

111113
// catch 404 and forward to error handler
112114
app.use(function (req, res, next) {

app/controllers/notification.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,26 @@ module.exports = {
5050
} catch (error) {
5151
HANDLER.handleError(res, error)
5252
}
53+
},
54+
55+
// GET LOGGED IN USER TICKET NOTIFICATIONS
56+
getTicketNotifications: async (req, res, next) => {
57+
const userId = req.user._id
58+
try {
59+
const user = await User.findById(userId)
60+
if (!user) {
61+
return res
62+
.status(HttpStatus.BAD_REQUEST)
63+
.json({ msg: 'No such user exists!' })
64+
}
65+
// get ticket notifications of existing user
66+
const notifications = user.ticketNotifications
67+
if (notifications.length === 0) {
68+
return res.status(HttpStatus.OK).json({ msg: 'No ticket notifications!' })
69+
}
70+
return res.status(HttpStatus.OK).json({ notifications })
71+
} catch (error) {
72+
HANDLER.handleError(res, error)
73+
}
5374
}
5475
}

0 commit comments

Comments
 (0)