feat(v1:notifications:proposals): Sent a generic notification on proposal create/acceptance
This commit is contained in:
@@ -23,7 +23,7 @@ async function onPostEvent( id , newProposalData ){
|
||||
const notification = new notificationsModel({
|
||||
"owner": user.id,
|
||||
"title": "New proposal",
|
||||
"description": `Your load ${load.shipment_code} has a new proposal!`,
|
||||
"description": `${load.shipment_code}`,
|
||||
"tag":"new_proposal",
|
||||
"deleted":false
|
||||
});
|
||||
@@ -41,6 +41,7 @@ async function onPostEvent( id , newProposalData ){
|
||||
async function onPatchEvent( id , newProposalData ){
|
||||
const proposal = await proposalsModel.findById( id );
|
||||
if( !newProposalData.is_accepted ){
|
||||
const load = await loadsModel.findById( proposal.load );
|
||||
/// Update Proposal:
|
||||
/// Remove shipper
|
||||
await proposalsModel.findByIdAndUpdate( id , {
|
||||
@@ -54,6 +55,14 @@ async function onPatchEvent( id , newProposalData ){
|
||||
driver : null,
|
||||
vehicle : null,
|
||||
} );
|
||||
|
||||
const notification = new notificationsModel({
|
||||
"owner": user.id,
|
||||
"title": `Your proposal has been accepted!`,
|
||||
"description": `${load.shipment_code}`,
|
||||
"tag":"accepted_proposal",
|
||||
"deleted":false
|
||||
});
|
||||
}else{
|
||||
const shipper_user = await usersModel.findById( proposal.accepted_by );
|
||||
const shipper = await companiesModel.findById( shipper_user.company );
|
||||
|
||||
Reference in New Issue
Block a user