friendrequest accept and reject particual customer

master
Bhaskara Kishore 3 years ago
parent 7eb2d40b86
commit 2b8d6902b7

@ -60,10 +60,10 @@ exports.friendRequest = async (request, reply) => {
exports.friendRequestAccept = async (request, reply) => { exports.friendRequestAccept = async (request, reply) => {
try { try {
//const {friendRequestId} = request.body; //const {friendRequestId} = request.body;
const {supplierId} = request.body; const {supplierId,customerId} = request.body;
// Update the friend request status to 'accepted' // Update the friend request status to 'accepted'
// const friendRequest = await FriendRequest.findByIdAndUpdate(friendRequestId, { status: 'accepted' }); // const friendRequest = await FriendRequest.findByIdAndUpdate(friendRequestId, { status: 'accepted' });
const friendRequest = await FriendRequest.findOneAndUpdate({supplierId}, { status: 'accepted' }); const friendRequest = await FriendRequest.findOneAndUpdate({supplierId,customerId }, { status: 'accepted' });
console.log("friendRequest....---", friendRequest) console.log("friendRequest....---", friendRequest)
@ -82,10 +82,10 @@ exports.friendRequestAccept = async (request, reply) => {
exports.friendRequestReject = async (request, reply) => { exports.friendRequestReject = async (request, reply) => {
try { try {
//const {friendRequestId} = request.body; //const {friendRequestId} = request.body;
const {supplierId} = request.body; const {supplierId, customerId} = request.body;
// Update the friend request status to 'rejected' // Update the friend request status to 'rejected'
// const friendRequest = await FriendRequest.findByIdAndUpdate(friendRequestId, { status: 'rejected' }); // const friendRequest = await FriendRequest.findByIdAndUpdate(friendRequestId, { status: 'rejected' });
const friendRequest = await FriendRequest.findOneAndUpdate({supplierId}, { status: 'rejected' }); const friendRequest = await FriendRequest.findOneAndUpdate({supplierId, customerId}, { status: 'rejected' });
console.log("friendRequest....---", friendRequest) console.log("friendRequest....---", friendRequest)

@ -32,7 +32,7 @@ module.exports = function (fastify, opts, next) {
fastify.route({ fastify.route({
method: "PUT", method: "PUT",
url: "/api/friend-request/:id/accept", url: "/api/friend-request/:supplierId/accept",
schema: { schema: {
tags: ["Friend-Request"], tags: ["Friend-Request"],
description: "This is for supplier accept the friend request", description: "This is for supplier accept the friend request",
@ -40,7 +40,8 @@ module.exports = function (fastify, opts, next) {
body: { body: {
type: "object", type: "object",
properties: { properties: {
supplierId: { type: "string" } supplierId: { type: "string" },
customerId: { type: "string" }
}, },
}, },
@ -54,7 +55,7 @@ module.exports = function (fastify, opts, next) {
}); });
fastify.route({ fastify.route({
method: "PUT", method: "PUT",
url: "/api/friend-request/:id/reject", url: "/api/friend-request/:supplierId/reject",
schema: { schema: {
tags: ["Friend-Request"], tags: ["Friend-Request"],
description: "This is for supplier reject the friend request", description: "This is for supplier reject the friend request",
@ -64,7 +65,7 @@ module.exports = function (fastify, opts, next) {
type: "object", type: "object",
properties: { properties: {
supplierId: { type: "string" }, supplierId: { type: "string" },
customerId: { type: "string" }
}, },
}, },
security: [ security: [

Loading…
Cancel
Save