refactor(state): refs #6366 simplify if condition
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
b42aed13c4
commit
e9773b3885
|
@ -136,8 +136,6 @@ module.exports = Self => {
|
|||
code: 'DELIVERED'
|
||||
}
|
||||
}, options);
|
||||
if (!deliveryState)
|
||||
throw new UserError('The DELIVERED state does not exist');
|
||||
|
||||
await models.Ticket.state(ctx, {
|
||||
ticketFk: ticketId,
|
||||
|
|
|
@ -58,13 +58,10 @@ module.exports = Self => {
|
|||
fields: ['stateFk']
|
||||
}, myOptions);
|
||||
|
||||
const oldStateAllowed = ticketState ?
|
||||
await models.State.isEditable(ctx, ticketState.stateFk, myOptions) :
|
||||
false;
|
||||
|
||||
const oldStateAllowed = ticketState && await models.State.isEditable(ctx, ticketState.stateFk, myOptions);
|
||||
const newStateAllowed = await models.State.isEditable(ctx, params.stateFk, myOptions);
|
||||
|
||||
if (!((!ticketState || oldStateAllowed == true) && newStateAllowed == true))
|
||||
if ((ticketState && !oldStateAllowed) || !newStateAllowed)
|
||||
throw new UserError(`You don't have enough privileges`, 'ACCESS_DENIED');
|
||||
|
||||
await Self.rawSql(`CALL vn.ticket_setState(?, ?)`, [params.ticketFk, params.code], myOptions);
|
||||
|
|
Loading…
Reference in New Issue