Fixed bug "deletePost doesn't work"

pull/5/head
Trivernis 5 years ago
parent bddcc84fba
commit e8499079d9

@ -241,7 +241,10 @@ export function resolver(req: any, res: any): any {
},
async deletePost({postId}: { postId: number }) {
if (postId) {
const post = await models.Post.findByPk(postId, {include: [models.User]});
const post = await models.Post.findByPk(postId, {include: [{
as: "rAuthor",
model: models.User,
}]});
if (post.rAuthor.id === req.session.userId) {
return await dataaccess.deletePost(post.id);
} else {

Loading…
Cancel
Save