mirror of
https://github.com/plankanban/planka.git
synced 2025-07-18 20:59:44 +02:00
Project managers, board members, auto-update after reconnection, refactoring
This commit is contained in:
parent
7956503a46
commit
fe91b5241e
478 changed files with 21226 additions and 19495 deletions
55
server/api/helpers/attachments/delete-one.js
Normal file
55
server/api/helpers/attachments/delete-one.js
Normal file
|
@ -0,0 +1,55 @@
|
|||
const path = require('path');
|
||||
const rimraf = require('rimraf');
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
record: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
board: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
card: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
type: 'ref',
|
||||
},
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
if (inputs.record.id === inputs.card.coverAttachmentId) {
|
||||
await sails.helpers.cards.updateOne.with({
|
||||
record: inputs.card,
|
||||
values: {
|
||||
coverAttachmentId: null,
|
||||
},
|
||||
request: inputs.request,
|
||||
});
|
||||
}
|
||||
|
||||
const attachment = await Attachment.archiveOne(inputs.record.id);
|
||||
|
||||
if (attachment) {
|
||||
try {
|
||||
rimraf.sync(path.join(sails.config.custom.attachmentsPath, attachment.dirname));
|
||||
} catch (error) {
|
||||
console.warn(error.stack); // eslint-disable-line no-console
|
||||
}
|
||||
|
||||
sails.sockets.broadcast(
|
||||
`board:${inputs.board.id}`,
|
||||
'attachmentDelete',
|
||||
{
|
||||
item: attachment,
|
||||
},
|
||||
inputs.request,
|
||||
);
|
||||
}
|
||||
|
||||
return attachment;
|
||||
},
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue