-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
166840939 like specific comment #38
Conversation
@@ -0,0 +1,17 @@ | |||
import express from 'express'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
src/middleware/like.middleware.js
Outdated
@@ -0,0 +1,44 @@ | |||
import checkProp from '../helpers/utils'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
@@ -0,0 +1,27 @@ | |||
import responseGenerator from './responseGenerator'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
src/database/models/commentlikes.js
Outdated
return CommentLikes; | ||
}; | ||
|
||
export default commentLikes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
return Comments; | ||
}; | ||
|
||
export default comments; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
@@ -0,0 +1,46 @@ | |||
module.exports = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'module' is not defined no-undef
@@ -0,0 +1,46 @@ | |||
module.exports = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'module' is not defined no-undef
@@ -0,0 +1,25 @@ | |||
import models from '../database/models/index'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good Job @olorunwalawrence, Please document your endpoints and use the Joi validation middleware instead of the check props
as we discussed
src/helpers/utils.js
Outdated
* @param {String} type The list of properties to be searched for | ||
* @returns {object} An object that contains a valid (bool) and invalidMessages (array) property | ||
*/ | ||
checkProps(obj, params, type) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use Joi validation middleware for this.
02ebecb
to
b6aaa09
Compare
@@ -0,0 +1,46 @@ | |||
module.exports = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'module' is not defined no-undef
@@ -0,0 +1,46 @@ | |||
module.exports = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'module' is not defined no-undef
@@ -0,0 +1,73 @@ | |||
/* eslint-disable require-jsdoc */ | |||
import models from '../database/models'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
return CommentLike; | ||
}; | ||
|
||
export default commentLike; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
8d66e74
to
4e6a12c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job @olorunwalawrence. Please kindly resolve the conflicts on this PR and also squash your commits. Thank you
8144530
to
9d46659
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job so far @olorunwalawrence , Please check my comments and make the necessary changes. I would also love to know your opinion on the possibility of the author of a comment liking their own comment
} | ||
|
||
// This block creates the toggle effect of liking and unliking | ||
return model.update({ liked: !liked }, { where: likeData }).then(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, this should be implemented as remove
since we would not be having a dislike feature on the project.
The first request to this api adds the like for such comment while the second removes the likes
@@ -0,0 +1,46 @@ | |||
module.exports = { | |||
up: (queryInterface, Sequelize) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seems to be two create-comment migration files here. could you remove one?
module.exports = { | ||
up: (queryInterface, Sequelize) => | ||
queryInterface.createTable( | ||
'CommentLike', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a migration file, so the tableName
should be plural. Sequelize should normally do this by default. Please make the changes here
as: 'userId' | ||
} | ||
}, | ||
liked: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A user should only be able to like a comment and NOT unlike. Hence if the user has liked the comment before, they should be able to remove such like on the comment. I think there is no need or this column in that case.
This table should only reflect list of people that have liked a specific article and when someone removes there like? then the row should be removed from this table
@@ -0,0 +1,49 @@ | |||
const comments = (sequelize, DataTypes) => { | |||
const Comments = sequelize.define( | |||
'Comments', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Model should have singular name to maintain consistency within the project, please check here https://github.com/andela/ah-kifaru-backend/blob/develop/src/database/models/follower.js
Hence, when creating a comment table use: =>cmd to create table
comment<=
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been solved on the comment branch
); | ||
}); | ||
|
||
it('sshould unlike a comment for an article', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should
expect(res.body.data).to.be.equal('Comment liked'); | ||
}); | ||
|
||
it('should throw error if article id is invalid', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test should not depend on the previous, please create a separate user or this test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kindly check below to see the user creating the like
); | ||
}); | ||
|
||
it('sshould unlike a comment for an article', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current project does not support features like unlike
, users should only be able to remove there previous likes. Please amend this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but this branch support feature that makes an authenticated user to like or unlike a specific comment. the PT board story says "Users should be able to like a specific comment".
if I have liked a specific comment and then later I am not interested in such comment anymore I should unlike it.
const userId = req.currentUser.id; | ||
|
||
const likeData = { commentId, userId }; | ||
return liker(CommentLike, res, likeData, 'Comment'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job @olorunwalawrence , is there a reason why you abstracted the liker method?
const { liker } = commentHelpers; | ||
|
||
const likeController = async (req, res) => { | ||
const { commentId: id } = req.params; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seems to be no check for the aspiring liker
being the author of the comment. This means the author of a comment can like their own comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is cool, there is no need to check for any aspiring liker because we are not stating any statistics base on the number of users that like specific comment, any user can like any comment
@@ -0,0 +1,46 @@ | |||
module.exports = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'module' is not defined no-undef
0a7c5d4
to
15d3797
Compare
src/database/models/Report.js
Outdated
@@ -0,0 +1,44 @@ | |||
export default (sequelize, DataTypes) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
@@ -0,0 +1,59 @@ | |||
module.exports = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'module' is not defined no-undef
- create like functionality - create middleware for like - create route for like [Delivers #166840939]
15d3797
to
b6ff3d9
Compare
What does this PR do?
Like a specific comment
Description of the task to be completed
How to manually test this PR
166840939-like-specific-comment
What is the story identity?
#166840919