Add deletion of media to deletePost

pull/5/head
trivernis 5 years ago
parent ebeaf3f549
commit 537ec07f29

@ -171,6 +171,14 @@ export class MutationResolver extends BaseResolver {
});
const isAdmin = (await User.findOne({where: {id: request.session.userId}})).isAdmin;
if (post.rAuthor.id === request.session.userId || isAdmin) {
if (post.mediaUrl) {
try {
await this.uploadManager.deleteWebFile(post.mediaUrl);
} catch (err) {
globals.logger.error(err.message);
globals.logger.debug(err.stack);
}
}
return await dataaccess.deletePost(post.id);
} else {
throw new GraphQLError("User is not author of the post.");

Loading…
Cancel
Save