{"action":"created","issue":{"url":"https://api.github.com/repos/DemocracyOS/core/issues/47","repository_url":"https://api.github.com/repos/DemocracyOS/core","labels_url":"https://api.github.com/repos/DemocracyOS/core/issues/47/labels{/name}","comments_url":"https://api.github.com/repos/DemocracyOS/core/issues/47/comments","events_url":"https://api.github.com/repos/DemocracyOS/core/issues/47/events","html_url":"https://github.com/DemocracyOS/core/issues/47","id":368027051,"node_id":"MDU6SXNzdWUzNjgwMjcwNTE=","number":47,"title":"Add Likes Model, DB-Api and API","user":{"login":"guillecro","id":8771166,"node_id":"MDQ6VXNlcjg3NzExNjY=","avatar_url":"https://avatars1.githubusercontent.com/u/8771166?v=4","gravatar_id":"","url":"https://api.github.com/users/guillecro","html_url":"https://github.com/guillecro","followers_url":"https://api.github.com/users/guillecro/followers","following_url":"https://api.github.com/users/guillecro/following{/other_user}","gists_url":"https://api.github.com/users/guillecro/gists{/gist_id}","starred_url":"https://api.github.com/users/guillecro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guillecro/subscriptions","organizations_url":"https://api.github.com/users/guillecro/orgs","repos_url":"https://api.github.com/users/guillecro/repos","events_url":"https://api.github.com/users/guillecro/events{/privacy}","received_events_url":"https://api.github.com/users/guillecro/received_events","type":"User","site_admin":false},"labels":[{"id":945441183,"node_id":"MDU6TGFiZWw5NDU0NDExODM=","url":"https://api.github.com/repos/DemocracyOS/core/labels/good%20first%20issue","name":"good first issue","color":"7057ff","default":true}],"state":"open","locked":false,"assignee":{"login":"guillecro","id":8771166,"node_id":"MDQ6VXNlcjg3NzExNjY=","avatar_url":"https://avatars1.githubusercontent.com/u/8771166?v=4","gravatar_id":"","url":"https://api.github.com/users/guillecro","html_url":"https://github.com/guillecro","followers_url":"https://api.github.com/users/guillecro/followers","following_url":"https://api.github.com/users/guillecro/following{/other_user}","gists_url":"https://api.github.com/users/guillecro/gists{/gist_id}","starred_url":"https://api.github.com/users/guillecro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guillecro/subscriptions","organizations_url":"https://api.github.com/users/guillecro/orgs","repos_url":"https://api.github.com/users/guillecro/repos","events_url":"https://api.github.com/users/guillecro/events{/privacy}","received_events_url":"https://api.github.com/users/guillecro/received_events","type":"User","site_admin":false},"assignees":[{"login":"guillecro","id":8771166,"node_id":"MDQ6VXNlcjg3NzExNjY=","avatar_url":"https://avatars1.githubusercontent.com/u/8771166?v=4","gravatar_id":"","url":"https://api.github.com/users/guillecro","html_url":"https://github.com/guillecro","followers_url":"https://api.github.com/users/guillecro/followers","following_url":"https://api.github.com/users/guillecro/following{/other_user}","gists_url":"https://api.github.com/users/guillecro/gists{/gist_id}","starred_url":"https://api.github.com/users/guillecro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guillecro/subscriptions","organizations_url":"https://api.github.com/users/guillecro/orgs","repos_url":"https://api.github.com/users/guillecro/repos","events_url":"https://api.github.com/users/guillecro/events{/privacy}","received_events_url":"https://api.github.com/users/guillecro/received_events","type":"User","site_admin":false}],"milestone":null,"comments":1,"created_at":"2018-10-09T03:28:27Z","updated_at":"2018-10-09T19:46:56Z","closed_at":null,"author_association":"COLLABORATOR","body":"We need to track the likes!\r\nBasically, a User can react to a Comment with a \"Like\" button.\r\n\r\nHere are the requeriments:\r\n### Create a Model \"Like\"\r\n\r\n| field | type | description | other |\r\n| --- | --- | --- | --- |\r\n| `user` | ObjectId | The Id of the user who liked it | - |\r\n| `comment` | ObjectId | The id of the related comment | - |\r\n\r\nAlso, add a timestamp, check other models, its an option that goes like `timestamp: true` :)\r\n\r\n### Add the following API endpoint\r\nInside \"api/document.js\" add a new route called:\r\n`/:id/comment/:idComment/like`\r\n\r\nThis endpoint should work as a \"Toggle\".\r\nThere are some cases and some validations\r\n\r\nNOTE: **YOU DONT NEED TO CHECK IF THERE IS THE REQUEST COMES FROM A LOGGED IN USER,** I will make the integration with the keycloak service that provide us the logged in user. So probably you wont have the \"req.session.user._id\" if you need it, in that case, write something random and i will change it later.\r\n\r\n- First check if there is already a `Like` for that user (`req.session.user._id`) and  that comment (`req.params.idComment`). (The query should have those two fields)\r\n- If there is a Like, delete it.\r\n- If not, create a new one.\r\n- In any case, return a `status.OK`, without a body!\r\n\r\n### Add the following API endpoint\r\nCreate a \"db-api/like.js\" and create the function you could need for the API.\r\nIts up to you to solve it as you prefer.\r\nMaybe you can do something like `Like.get(query), Like.create(likeData), Like.delete(likeId)`\r\nOr maybe you can think of anything different\r\n\r\nIf you can, you can try to make a suite of test just testing the db-api and/or the api, i could give you a hand there too!"},"comment":{"url":"https://api.github.com/repos/DemocracyOS/core/issues/comments/428326067","html_url":"https://github.com/DemocracyOS/core/issues/47#issuecomment-428326067","issue_url":"https://api.github.com/repos/DemocracyOS/core/issues/47","id":428326067,"node_id":"MDEyOklzc3VlQ29tbWVudDQyODMyNjA2Nw==","user":{"login":"guillecro","id":8771166,"node_id":"MDQ6VXNlcjg3NzExNjY=","avatar_url":"https://avatars1.githubusercontent.com/u/8771166?v=4","gravatar_id":"","url":"https://api.github.com/users/guillecro","html_url":"https://github.com/guillecro","followers_url":"https://api.github.com/users/guillecro/followers","following_url":"https://api.github.com/users/guillecro/following{/other_user}","gists_url":"https://api.github.com/users/guillecro/gists{/gist_id}","starred_url":"https://api.github.com/users/guillecro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guillecro/subscriptions","organizations_url":"https://api.github.com/users/guillecro/orgs","repos_url":"https://api.github.com/users/guillecro/repos","events_url":"https://api.github.com/users/guillecro/events{/privacy}","received_events_url":"https://api.github.com/users/guillecro/received_events","type":"User","site_admin":false},"created_at":"2018-10-09T19:46:56Z","updated_at":"2018-10-09T19:46:56Z","author_association":"COLLABORATOR","body":"The `.env` might be this:\r\n\r\n```\r\n# App vars\r\nPORT=3000\r\nSESSION_SECRET=faQ0hgRgLyahbQVsCrHkgg5ahJgoawdRKIPWB9H9\r\n\r\n# Database vars\r\nMONGO_URL=mongodb://localhost/core\r\n\r\n# Keycloak \r\nAUTH_REALM=congreso\r\nAUTH_SERVER_URL=https://keycloak.democraciaenred.org/auth\r\nAUTH_CLIENT=app\r\n```\r\n\r\nKeycloak is working, we can use login to test :+1: \r\nAnd if you need mongo, here is docker-compose:\r\n\r\n```\r\nversion: '3'\r\n\r\nservices:\r\n  mongo:\r\n    image: mongo:3.6\r\n    ports:\r\n      - 27017:27017\r\n    # Optionally mount external data directory\r\n    # volumes:\r\n    #   - ~/data3.2:/data/db\r\n```"}}
{"actor":{"display_login":"guillecro"}}