Bhaskara Kishore 3 years ago
commit a3c123ca59

@ -551,4 +551,24 @@ exports.connectionStatus = async (req, reply) => {
console.error(err);
reply.status(500).send({ error: 'Internal server error' });
}
}
}
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);
}
};

@ -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: {

@ -611,6 +611,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();
}

Loading…
Cancel
Save