Skip to content

Commit

Permalink
fix: #8604
Browse files Browse the repository at this point in the history
  • Loading branch information
barisusakli committed Sep 4, 2020
1 parent 1b7ba2c commit a263897
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/user/delete.js
Expand Up @@ -144,6 +144,7 @@ module.exports = function (User) {
deleteUserIps(uid),
deleteBans(uid),
deleteUserFromFollowers(uid),
deleteImages(uid),
groups.leaveAllGroups(uid),
]);
await db.deleteAll(['followers:' + uid, 'following:' + uid, 'user:' + uid]);
Expand Down Expand Up @@ -207,4 +208,13 @@ module.exports = function (User) {
updateCount(followers, 'following:', 'followingCount'),
]);
}

async function deleteImages(uid) {
const extensions = User.getAllowedProfileImageExtensions();
const folder = path.join(nconf.get('upload_path'), 'profile');
await Promise.all(extensions.map(async (ext) => {
await file.delete(path.join(folder, uid + '-profilecover.' + ext));
await file.delete(path.join(folder, uid + '-profileavatar.' + ext));
}));
}
};

0 comments on commit a263897

Please sign in to comment.