32 lines
784 B
JavaScript
32 lines
784 B
JavaScript
module.exports = Self => {
|
|
Self.remoteMethodCtx('isEditable', {
|
|
description: 'Check if a ticket is editable',
|
|
accessType: 'READ',
|
|
accepts: [{
|
|
arg: 'id',
|
|
type: 'number',
|
|
required: true,
|
|
description: 'the ticket id',
|
|
http: {source: 'path'}
|
|
}],
|
|
returns: {
|
|
type: 'boolean',
|
|
root: true
|
|
},
|
|
http: {
|
|
path: `/:id/isEditable`,
|
|
verb: 'get'
|
|
}
|
|
});
|
|
|
|
Self.isEditable = async(ctx, id, options) => {
|
|
try {
|
|
await Self.isEditableOrThrow(ctx, id, options);
|
|
} catch (e) {
|
|
if (e.name === 'ForbiddenError') return false;
|
|
throw e;
|
|
}
|
|
return true;
|
|
};
|
|
};
|