mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: local deleteUploads() method in src/user/delete.js to call User.deleteUpload()
This commit is contained in:
@@ -15,7 +15,6 @@ const groups = require('../groups');
|
||||
const messaging = require('../messaging');
|
||||
const plugins = require('../plugins');
|
||||
const batch = require('../batch');
|
||||
const file = require('../file');
|
||||
|
||||
module.exports = function (User) {
|
||||
const deletesInProgress = {};
|
||||
@@ -35,7 +34,7 @@ module.exports = function (User) {
|
||||
deletesInProgress[uid] = 'user.delete';
|
||||
await deletePosts(callerUid, uid);
|
||||
await deleteTopics(callerUid, uid);
|
||||
await deleteUploads(uid);
|
||||
await deleteUploads(callerUid, uid);
|
||||
await deleteQueued(uid);
|
||||
delete deletesInProgress[uid];
|
||||
};
|
||||
@@ -56,13 +55,9 @@ module.exports = function (User) {
|
||||
}, { alwaysStartAt: 0 });
|
||||
}
|
||||
|
||||
async function deleteUploads(uid) {
|
||||
await batch.processSortedSet(`uid:${uid}:uploads`, async (uploadNames) => {
|
||||
await async.each(uploadNames, async (uploadName) => {
|
||||
await file.delete(path.join(nconf.get('upload_path'), uploadName));
|
||||
});
|
||||
await db.sortedSetRemove(`uid:${uid}:uploads`, uploadNames);
|
||||
}, { alwaysStartAt: 0 });
|
||||
async function deleteUploads(callerUid, uid) {
|
||||
const uploads = await db.getSortedSetMembers(`uid:${uid}:uploads`);
|
||||
await User.deleteUpload(callerUid, uid, uploads);
|
||||
}
|
||||
|
||||
async function deleteQueued(uid) {
|
||||
|
||||
@@ -130,7 +130,7 @@ describe('Upload Controllers', () => {
|
||||
assert(body && body.status && body.response && body.response.images);
|
||||
assert(Array.isArray(body.response.images));
|
||||
assert(body.response.images[0].url);
|
||||
const name = body.response.images[0].url.replace(nconf.get('relative_path') + nconf.get('upload_url'), '');
|
||||
const name = body.response.images[0].url.replace(`${nconf.get('relative_path') + nconf.get('upload_url')}/`, '');
|
||||
socketUser.deleteUpload({ uid: regularUid }, { uid: regularUid, name: name }, (err) => {
|
||||
assert.ifError(err);
|
||||
db.getSortedSetRange(`uid:${regularUid}:uploads`, 0, -1, (err, uploads) => {
|
||||
|
||||
Reference in New Issue
Block a user