|
|
@ -171,6 +171,14 @@ export class MutationResolver extends BaseResolver {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
const isAdmin = (await User.findOne({where: {id: request.session.userId}})).isAdmin;
|
|
|
|
const isAdmin = (await User.findOne({where: {id: request.session.userId}})).isAdmin;
|
|
|
|
if (post.rAuthor.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);
|
|
|
|
return await dataaccess.deletePost(post.id);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
throw new GraphQLError("User is not author of the post.");
|
|
|
|
throw new GraphQLError("User is not author of the post.");
|
|
|
|