Last active
October 18, 2017 14:35
-
-
Save felixexter/97ddb80782c42ba433b2 to your computer and use it in GitHub Desktop.
slack-delete-files.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function deleteFiles(types = 'all') { | |
let files = []; | |
function deleteFilesByTypes(types, page = 1) { | |
TS.api.call('files.list', { | |
types, | |
user: boot_data.user_id, | |
page | |
}, (a, data) => { | |
files = [...files, ...data.files]; | |
if (data.paging.page !== Math.ceil(data.paging.total / data.paging.count)) { | |
deleteFilesByTypes(types, data.paging.page + 1); | |
} else { | |
files.forEach(file => | |
TS.api.call('files.delete', { | |
file: file.id | |
}, () => | |
console.log('Файл удалён: ' + file.name) | |
) | |
); | |
} | |
}); | |
}; | |
deleteFilesByTypes(types); | |
}; | |
deleteFiles(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
В консоли браузера вставить код выше и нажать enter.
Если нужно удалить конкретные типы файлов, то в функцию
deleteFiles()
передать строку с одним типов:all
- All files (default);spaces
- Posts;snippets
- Snippets;images
- Image files;gdocs
- Google docs;zips
- Zip files;pdfs
- PDF files.