fix: add await in async functions refs #5979

This commit is contained in:
Pablo Natek 2023-10-20 12:53:54 +02:00
parent dc93328bcf
commit 5c69d9c7f0
3 changed files with 6 additions and 12 deletions

View File

@ -26,7 +26,7 @@ module.exports = Self => {
Self.getTickets = async(ctx, id, print, options) => {
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 myOptions = {};

View File

@ -13,12 +13,6 @@
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
},
{
"property": "getUrl",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
},{
"accessType": "READ",
"principalType": "ROLE",

View File

@ -91,16 +91,16 @@ module.exports = Self => {
// When hasToPickUp has been changed
if (salesPerson && changedHasToPickUp && updatedClaim.hasToPickUp)
notifyPickUp(ctx, salesPerson.id, claim);
await notifyPickUp(ctx, salesPerson.id, claim);
// When claimState has been changed
if (args.claimStateFk) {
const newState = await models.ClaimState.findById(args.claimStateFk, null, myOptions);
if (newState.hasToNotify) {
if (newState.code == 'incomplete')
notifyStateChange(ctx, salesPerson.id, claim, newState.code);
await notifyStateChange(ctx, salesPerson.id, claim, newState.code);
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) {
const models = Self.app.models;
const url = models.Url.getUrl();
const url = await models.Url.getUrl();
const $t = ctx.req.__; // $translate
const message = $t(`Claim state has changed to ${state}`, {
@ -128,7 +128,7 @@ module.exports = Self => {
async function notifyPickUp(ctx, workerId, claim) {
const models = Self.app.models;
const url = models.Url.getUrl();
const url = await models.Url.getUrl();
const $t = ctx.req.__; // $translate
const message = $t('Claim will be picked', {