1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-19 13:19:44 +02:00

support project background + user avatar

This commit is contained in:
Nguyễn Hải Quang 2024-11-10 00:26:49 +07:00
parent 84b0f91b44
commit e84a2837ab
13 changed files with 223 additions and 46 deletions

View file

@ -53,19 +53,26 @@ module.exports = {
try {
const type = attachment.type || 'local';
if (type === 's3') {
const client = await sails.helpers.attachments.getSimpleStorageServiceClient();
const client = await sails.helpers.utils.getSimpleStorageServiceClient();
if (client) {
const file1 = `${attachment.dirname}/${attachment.filename}`;
const file2 = `${attachment.dirname}/thumbnails/cover-256.png`;
await client.delete({ Key: file1 });
await client.delete({ Key: file2 });
if (attachment.url) {
const parsedUrl = new URL(attachment.url);
await client.delete({ Key: parsedUrl.pathname.replace(/^\/+/, '') });
}
if (attachment.thumb) {
const parsedUrl = new URL(attachment.thumb);
await client.delete({ Key: parsedUrl.pathname.replace(/^\/+/, '') });
}
}
} else {
rimraf.sync(path.join(sails.config.custom.attachmentsPath, attachment.dirname));
}
} catch (error) {
console.warn(error.stack); // eslint-disable-line no-console
}
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}`,