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({
|
const notification = new notificationsModel({
|
||||||
"owner": user.id,
|
"owner": user.id,
|
||||||
"title": "New proposal",
|
"title": "New proposal",
|
||||||
"description": `Your load ${load.shipment_code} has a new proposal!`,
|
"description": `${load.shipment_code}`,
|
||||||
"tag":"new_proposal",
|
"tag":"new_proposal",
|
||||||
"deleted":false
|
"deleted":false
|
||||||
});
|
});
|
||||||
@@ -41,6 +41,7 @@ async function onPostEvent( id , newProposalData ){
|
|||||||
async function onPatchEvent( id , newProposalData ){
|
async function onPatchEvent( id , newProposalData ){
|
||||||
const proposal = await proposalsModel.findById( id );
|
const proposal = await proposalsModel.findById( id );
|
||||||
if( !newProposalData.is_accepted ){
|
if( !newProposalData.is_accepted ){
|
||||||
|
const load = await loadsModel.findById( proposal.load );
|
||||||
/// Update Proposal:
|
/// Update Proposal:
|
||||||
/// Remove shipper
|
/// Remove shipper
|
||||||
await proposalsModel.findByIdAndUpdate( id , {
|
await proposalsModel.findByIdAndUpdate( id , {
|
||||||
@@ -54,6 +55,14 @@ async function onPatchEvent( id , newProposalData ){
|
|||||||
driver : null,
|
driver : null,
|
||||||
vehicle : 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{
|
}else{
|
||||||
const shipper_user = await usersModel.findById( proposal.accepted_by );
|
const shipper_user = await usersModel.findById( proposal.accepted_by );
|
||||||
const shipper = await companiesModel.findById( shipper_user.company );
|
const shipper = await companiesModel.findById( shipper_user.company );
|
||||||
|
|||||||
Reference in New Issue
Block a user