From 1c9fc20e5f077e8a7e203fed1f7aec79392c9871 Mon Sep 17 00:00:00 2001 From: varun Date: Fri, 24 Mar 2023 06:49:38 -0400 Subject: [PATCH] made changes for sending otp to supplier --- src/controllers/tankersController.js | 22 +++++++++++++++++++++- src/routes/supplierOrdersRoutes.js | 2 +- src/routes/tankersRoute.js | 28 ++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/src/controllers/tankersController.js b/src/controllers/tankersController.js index 3023aa07..623a8cdb 100644 --- a/src/controllers/tankersController.js +++ b/src/controllers/tankersController.js @@ -551,4 +551,24 @@ exports.connectionStatus = async (req, reply) => { console.error(err); reply.status(500).send({ error: 'Internal server error' }); } -} \ No newline at end of file +} + + + + + +exports.connectstatus = async (req, reply) => { + try { + const customerId = req.params.customerId; + const supplierId = req.query.supplierId; + const receiverId = mongoose.Types.ObjectId(supplierId); + const data = await FriendRequest.findOne({ sender: customerId, receiver: receiverId }); + let connection_status = "not requested"; + if (data) { + connection_status = data.status; + } + reply.send({ status_code: 200, customerId: customerId, supplierId: supplierId, status: connection_status }); + } catch (err) { + throw boom.boomify(err); + } +}; diff --git a/src/routes/supplierOrdersRoutes.js b/src/routes/supplierOrdersRoutes.js index 2bc076b5..3b787d73 100644 --- a/src/routes/supplierOrdersRoutes.js +++ b/src/routes/supplierOrdersRoutes.js @@ -105,7 +105,7 @@ module.exports = function (fastify, opts, next) { fastify.get("/api/getActiveDeliveryboys/:supplierId", { schema: { - tags: ["Supplier"], + tags: ["Supplier-Data"], description: "This is for Get avtive delivery boys Data", summary: "This is for to Get avtive delivery boys Data", params: { diff --git a/src/routes/tankersRoute.js b/src/routes/tankersRoute.js index aea3b9f2..fb7c823e 100644 --- a/src/routes/tankersRoute.js +++ b/src/routes/tankersRoute.js @@ -610,6 +610,34 @@ module.exports = function (fastify, opts, next) { handler: tankersController.connectionStatus }); + fastify.get("/api/getConnectStatus/:customerId", { + schema: { + tags: ["Supplier"], + description: "This is to get connect status", + summary: "This is to get connect status", + params: { + required: ["customerId"], + type: "object", + properties: { + customerId: { + type: "string", + description: "customerId", + }, + }, + }, + querystring: { + supplierId: {type: 'string'} + }, + security: [ + { + basicAuth: [], + }, + ], + }, + preHandler: fastify.auth([fastify.authenticate]), + handler: tankersController.connectstatus, + }); + next(); }