diff --git a/back/methods/message/send.js b/back/methods/message/send.js index 5968964b1..f7b7ad76e 100644 --- a/back/methods/message/send.js +++ b/back/methods/message/send.js @@ -25,24 +25,24 @@ module.exports = Self => { } }); - Self.send = async(ctx, data, transaction) => { + Self.send = async(ctx, data, options) => { const accessToken = ctx.options && ctx.options.accessToken || ctx.req && ctx.req.accessToken; const userId = accessToken.userId; const models = Self.app.models; - const sender = await models.Account.findById(userId, transaction); - const recipient = await models.Account.findById(data.recipientFk, transaction); + const sender = await models.Account.findById(userId, options); + const recipient = await models.Account.findById(data.recipientFk, options); await Self.create({ sender: sender.name, recipient: recipient.name, message: data.message - }, transaction); + }, options); return await models.MessageInbox.create({ sender: sender.name, recipient: recipient.name, finalRecipient: recipient.name, message: data.message - }, transaction); + }, options); }; }; diff --git a/modules/claim/back/methods/claim/regularizeClaim.js b/modules/claim/back/methods/claim/regularizeClaim.js index 5c54a7a2f..a2896174e 100644 --- a/modules/claim/back/methods/claim/regularizeClaim.js +++ b/modules/claim/back/methods/claim/regularizeClaim.js @@ -22,18 +22,18 @@ module.exports = Self => { const models = Self.app.models; const resolvedState = 3; - const claimEnds = await models.ClaimEnd.find({ - include: { - relation: 'claimDestination', - fields: ['addressFk'] - }, - where: {claimFk: params.claimFk} - }); - let tx = await Self.beginTransaction({}); try { let options = {transaction: tx}; + const claimEnds = await models.ClaimEnd.find({ + include: { + relation: 'claimDestination', + fields: ['addressFk'] + }, + where: {claimFk: params.claimFk} + }, options); + for (let i = 0; i < claimEnds.length; i++) { const claimEnd = claimEnds[i]; const destination = claimEnd.claimDestination(); @@ -42,7 +42,7 @@ module.exports = Self => { if (!addressFk) continue; - let sale = await getSale(claimEnd.saleFk); + let sale = await getSale(claimEnd.saleFk, options); let ticketFk = await getTicketId({ addressFk: addressFk, companyFk: sale.ticket().companyFk, @@ -51,7 +51,7 @@ module.exports = Self => { let address = await models.Address.findOne({ where: {id: addressFk} - }); + }, options); if (!ticketFk) { ticketFk = await createTicket(ctx, { @@ -84,7 +84,7 @@ module.exports = Self => { } } - let claim = await Self.findById(params.claimFk); + let claim = await Self.findById(params.claimFk, null, options); claim = await claim.updateAttributes({ claimStateFk: resolvedState }, options); @@ -98,7 +98,7 @@ module.exports = Self => { } }; - async function getSale(saleFk) { + async function getSale(saleFk, options) { return await Self.app.models.Sale.findOne({ include: [ { @@ -116,7 +116,7 @@ module.exports = Self => { } }], where: {id: saleFk} - }); + }, options); } async function getTicketId(params, options) {