fix: add await in async functions refs #5979
This commit is contained in:
parent
dc93328bcf
commit
5c69d9c7f0
|
@ -26,7 +26,7 @@ module.exports = Self => {
|
||||||
|
|
||||||
Self.getTickets = async(ctx, id, print, options) => {
|
Self.getTickets = async(ctx, id, print, options) => {
|
||||||
const userId = ctx.req.accessToken.userId;
|
const userId = ctx.req.accessToken.userId;
|
||||||
const url = Self.app.models.Url.getUrl();
|
const url = await Self.app.models.Url.getUrl();
|
||||||
const $t = ctx.req.__;
|
const $t = ctx.req.__;
|
||||||
const myOptions = {};
|
const myOptions = {};
|
||||||
|
|
||||||
|
|
|
@ -13,12 +13,6 @@
|
||||||
"principalType": "ROLE",
|
"principalType": "ROLE",
|
||||||
"principalId": "$everyone",
|
"principalId": "$everyone",
|
||||||
"permission": "ALLOW"
|
"permission": "ALLOW"
|
||||||
},
|
|
||||||
{
|
|
||||||
"property": "getUrl",
|
|
||||||
"principalType": "ROLE",
|
|
||||||
"principalId": "$everyone",
|
|
||||||
"permission": "ALLOW"
|
|
||||||
},{
|
},{
|
||||||
"accessType": "READ",
|
"accessType": "READ",
|
||||||
"principalType": "ROLE",
|
"principalType": "ROLE",
|
||||||
|
|
|
@ -91,16 +91,16 @@ module.exports = Self => {
|
||||||
|
|
||||||
// When hasToPickUp has been changed
|
// When hasToPickUp has been changed
|
||||||
if (salesPerson && changedHasToPickUp && updatedClaim.hasToPickUp)
|
if (salesPerson && changedHasToPickUp && updatedClaim.hasToPickUp)
|
||||||
notifyPickUp(ctx, salesPerson.id, claim);
|
await notifyPickUp(ctx, salesPerson.id, claim);
|
||||||
|
|
||||||
// When claimState has been changed
|
// When claimState has been changed
|
||||||
if (args.claimStateFk) {
|
if (args.claimStateFk) {
|
||||||
const newState = await models.ClaimState.findById(args.claimStateFk, null, myOptions);
|
const newState = await models.ClaimState.findById(args.claimStateFk, null, myOptions);
|
||||||
if (newState.hasToNotify) {
|
if (newState.hasToNotify) {
|
||||||
if (newState.code == 'incomplete')
|
if (newState.code == 'incomplete')
|
||||||
notifyStateChange(ctx, salesPerson.id, claim, newState.code);
|
await notifyStateChange(ctx, salesPerson.id, claim, newState.code);
|
||||||
if (newState.code == 'canceled')
|
if (newState.code == 'canceled')
|
||||||
notifyStateChange(ctx, claim.workerFk, claim, newState.code);
|
await notifyStateChange(ctx, claim.workerFk, claim, newState.code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ module.exports = Self => {
|
||||||
|
|
||||||
async function notifyStateChange(ctx, workerId, claim, state) {
|
async function notifyStateChange(ctx, workerId, claim, state) {
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
const url = models.Url.getUrl();
|
const url = await models.Url.getUrl();
|
||||||
const $t = ctx.req.__; // $translate
|
const $t = ctx.req.__; // $translate
|
||||||
|
|
||||||
const message = $t(`Claim state has changed to ${state}`, {
|
const message = $t(`Claim state has changed to ${state}`, {
|
||||||
|
@ -128,7 +128,7 @@ module.exports = Self => {
|
||||||
|
|
||||||
async function notifyPickUp(ctx, workerId, claim) {
|
async function notifyPickUp(ctx, workerId, claim) {
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
const url = models.Url.getUrl();
|
const url = await models.Url.getUrl();
|
||||||
const $t = ctx.req.__; // $translate
|
const $t = ctx.req.__; // $translate
|
||||||
|
|
||||||
const message = $t('Claim will be picked', {
|
const message = $t('Claim will be picked', {
|
||||||
|
|
Loading…
Reference in New Issue