{"action":"created","comment":{"url":"https://api.github.com/repos/netguru/bob-the-bot/pulls/comments/232723968","pull_request_review_id":173978335,"id":232723968,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzMjcyMzk2OA==","diff_hunk":"@@ -0,0 +1,44 @@\n+const { map } = require('asyncro');\n+\n+class MqttHandler {\n+  constructor(mqtt, eventsDAO, roomsService, resourcesService) {\n+    this.mqtt = mqtt;\n+    this.eventsDAO = eventsDAO;\n+    this.roomsService = roomsService;\n+    this.resourcesService = resourcesService;\n+  }\n+\n+  async prepareAndPublish(events) {\n+    const eventKeys = Object.keys(events);\n+\n+    await map(eventKeys, async (eventKey) => {\n+      const event = events[eventKey];\n+      const rooms = await this.getEventRoomAttendees(event);\n+\n+      await map(rooms, async (room) => {\n+        const id = await this.saveForLater(event, room);\n+\n+        this.mqtt.sendMessage(room.id, { id });","path":"src/book/services/mqttHandler.js","position":21,"original_position":21,"commit_id":"e3f844e58b559842ae7ccb9814df86dc0c3dc0ce","original_commit_id":"e3f844e58b559842ae7ccb9814df86dc0c3dc0ce","user":{"login":"Getriax","id":30323562,"node_id":"MDQ6VXNlcjMwMzIzNTYy","avatar_url":"https://avatars0.githubusercontent.com/u/30323562?v=4","gravatar_id":"","url":"https://api.github.com/users/Getriax","html_url":"https://github.com/Getriax","followers_url":"https://api.github.com/users/Getriax/followers","following_url":"https://api.github.com/users/Getriax/following{/other_user}","gists_url":"https://api.github.com/users/Getriax/gists{/gist_id}","starred_url":"https://api.github.com/users/Getriax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Getriax/subscriptions","organizations_url":"https://api.github.com/users/Getriax/orgs","repos_url":"https://api.github.com/users/Getriax/repos","events_url":"https://api.github.com/users/Getriax/events{/privacy}","received_events_url":"https://api.github.com/users/Getriax/received_events","type":"User","site_admin":false},"body":"`room` does not have the property `id`, check https://developers.google.com/apis-explorer/#search/calendar/calendar/v3/calendar.events.get and see how `attendees` looks like.","created_at":"2018-11-12T16:24:29Z","updated_at":"2018-11-12T16:30:25Z","html_url":"https://github.com/netguru/bob-the-bot/pull/101#discussion_r232723968","pull_request_url":"https://api.github.com/repos/netguru/bob-the-bot/pulls/101","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/netguru/bob-the-bot/pulls/comments/232723968"},"html":{"href":"https://github.com/netguru/bob-the-bot/pull/101#discussion_r232723968"},"pull_request":{"href":"https://api.github.com/repos/netguru/bob-the-bot/pulls/101"}}},"pull_request":{"url":"https://api.github.com/repos/netguru/bob-the-bot/pulls/101","id":230102228,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMwMTAyMjI4","html_url":"https://github.com/netguru/bob-the-bot/pull/101","diff_url":"https://github.com/netguru/bob-the-bot/pull/101.diff","patch_url":"https://github.com/netguru/bob-the-bot/pull/101.patch","issue_url":"https://api.github.com/repos/netguru/bob-the-bot/issues/101","number":101,"state":"open","locked":false,"title":"Book 21,28","user":{"login":"kozikkam","id":36657834,"node_id":"MDQ6VXNlcjM2NjU3ODM0","avatar_url":"https://avatars3.githubusercontent.com/u/36657834?v=4","gravatar_id":"","url":"https://api.github.com/users/kozikkam","html_url":"https://github.com/kozikkam","followers_url":"https://api.github.com/users/kozikkam/followers","following_url":"https://api.github.com/users/kozikkam/following{/other_user}","gists_url":"https://api.github.com/users/kozikkam/gists{/gist_id}","starred_url":"https://api.github.com/users/kozikkam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kozikkam/subscriptions","organizations_url":"https://api.github.com/users/kozikkam/orgs","repos_url":"https://api.github.com/users/kozikkam/repos","events_url":"https://api.github.com/users/kozikkam/events{/privacy}","received_events_url":"https://api.github.com/users/kozikkam/received_events","type":"User","site_admin":false},"body":"Implemented mqtt handling with use of BOOK-20 mqtt protocol.\r\n\r\nBot now does two things. He listens for emitted events on `rooms-general`. And uses `resourcesManager.handleResponse(response)` to handle that event.\r\nHe also emits events to each room channel with following data structure:\r\n```\r\n{\r\n  uuid: 'someUniqueId'\r\n}\r\n```\r\nWhere uuid is an id which references to redis entry, storing listened event data. That data is then retrieved when response comes.\r\n\r\nIt is now required to set `CONFIRMED_EXPIRE_SECONDS` in .env. That's the value of how many seconds listened event data is going to be stored in redis database. It has to be above timeout set on device.\r\n\r\n**Usage example**\r\n\r\nListening to events\r\n```\r\n  mqtt.onAction('rooms-general', 'get-status', (data) => {\r\n    this.bookService.manageMqttResponse(data);\r\n  });\r\n```\r\n\r\nPublishing events\r\n```\r\nawait this.mqttHandler.prepareAndPublish(toPublishEventsFilter);\r\n```\r\n\r\n**Jira**\r\nBOOK-21 and BOOK-28","created_at":"2018-11-12T11:27:47Z","updated_at":"2018-11-12T16:30:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4960b33b3a529e450b02bf96396bb6b6b606e1e8","assignee":null,"assignees":[],"requested_reviewers":[{"login":"krzyurb","id":11517908,"node_id":"MDQ6VXNlcjExNTE3OTA4","avatar_url":"https://avatars3.githubusercontent.com/u/11517908?v=4","gravatar_id":"","url":"https://api.github.com/users/krzyurb","html_url":"https://github.com/krzyurb","followers_url":"https://api.github.com/users/krzyurb/followers","following_url":"https://api.github.com/users/krzyurb/following{/other_user}","gists_url":"https://api.github.com/users/krzyurb/gists{/gist_id}","starred_url":"https://api.github.com/users/krzyurb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krzyurb/subscriptions","organizations_url":"https://api.github.com/users/krzyurb/orgs","repos_url":"https://api.github.com/users/krzyurb/repos","events_url":"https://api.github.com/users/krzyurb/events{/privacy}","received_events_url":"https://api.github.com/users/krzyurb/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/netguru/bob-the-bot/pulls/101/commits","review_comments_url":"https://api.github.com/repos/netguru/bob-the-bot/pulls/101/comments","review_comment_url":"https://api.github.com/repos/netguru/bob-the-bot/pulls/comments{/number}","comments_url":"https://api.github.com/repos/netguru/bob-the-bot/issues/101/comments","statuses_url":"https://api.github.com/repos/netguru/bob-the-bot/statuses/e3f844e58b559842ae7ccb9814df86dc0c3dc0ce","head":{"label":"netguru:BOOK-21,28","ref":"BOOK-21,28","sha":"e3f844e58b559842ae7ccb9814df86dc0c3dc0ce","user":{"login":"netguru","id":1146,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExNDY=","avatar_url":"https://avatars1.githubusercontent.com/u/1146?v=4","gravatar_id":"","url":"https://api.github.com/users/netguru","html_url":"https://github.com/netguru","followers_url":"https://api.github.com/users/netguru/followers","following_url":"https://api.github.com/users/netguru/following{/other_user}","gists_url":"https://api.github.com/users/netguru/gists{/gist_id}","starred_url":"https://api.github.com/users/netguru/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/netguru/subscriptions","organizations_url":"https://api.github.com/users/netguru/orgs","repos_url":"https://api.github.com/users/netguru/repos","events_url":"https://api.github.com/users/netguru/events{/privacy}","received_events_url":"https://api.github.com/users/netguru/received_events","type":"Organization","site_admin":false},"repo":{"id":141249965,"node_id":"MDEwOlJlcG9zaXRvcnkxNDEyNDk5NjU=","name":"bob-the-bot","full_name":"netguru/bob-the-bot","private":false,"owner":{"login":"netguru","id":1146,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExNDY=","avatar_url":"https://avatars1.githubusercontent.com/u/1146?v=4","gravatar_id":"","url":"https://api.github.com/users/netguru","html_url":"https://github.com/netguru","followers_url":"https://api.github.com/users/netguru/followers","following_url":"https://api.github.com/users/netguru/following{/other_user}","gists_url":"https://api.github.com/users/netguru/gists{/gist_id}","starred_url":"https://api.github.com/users/netguru/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/netguru/subscriptions","organizations_url":"https://api.github.com/users/netguru/orgs","repos_url":"https://api.github.com/users/netguru/repos","events_url":"https://api.github.com/users/netguru/events{/privacy}","received_events_url":"https://api.github.com/users/netguru/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/netguru/bob-the-bot","description":null,"fork":false,"url":"https://api.github.com/repos/netguru/bob-the-bot","forks_url":"https://api.github.com/repos/netguru/bob-the-bot/forks","keys_url":"https://api.github.com/repos/netguru/bob-the-bot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/netguru/bob-the-bot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/netguru/bob-the-bot/teams","hooks_url":"https://api.github.com/repos/netguru/bob-the-bot/hooks","issue_events_url":"https://api.github.com/repos/netguru/bob-the-bot/issues/events{/number}","events_url":"https://api.github.com/repos/netguru/bob-the-bot/events","assignees_url":"https://api.github.com/repos/netguru/bob-the-bot/assignees{/user}","branches_url":"https://api.github.com/repos/netguru/bob-the-bot/branches{/branch}","tags_url":"https://api.github.com/repos/netguru/bob-the-bot/tags","blobs_url":"https://api.github.com/repos/netguru/bob-the-bot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/netguru/bob-the-bot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/netguru/bob-the-bot/git/refs{/sha}","trees_url":"https://api.github.com/repos/netguru/bob-the-bot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/netguru/bob-the-bot/statuses/{sha}","languages_url":"https://api.github.com/repos/netguru/bob-the-bot/languages","stargazers_url":"https://api.github.com/repos/netguru/bob-the-bot/stargazers","contributors_url":"https://api.github.com/repos/netguru/bob-the-bot/contributors","subscribers_url":"https://api.github.com/repos/netguru/bob-the-bot/subscribers","subscription_url":"https://api.github.com/repos/netguru/bob-the-bot/subscription","commits_url":"https://api.github.com/repos/netguru/bob-the-bot/commits{/sha}","git_commits_url":"https://api.github.com/repos/netguru/bob-the-bot/git/commits{/sha}","comments_url":"https://api.github.com/repos/netguru/bob-the-bot/comments{/number}","issue_comment_url":"https://api.github.com/repos/netguru/bob-the-bot/issues/comments{/number}","contents_url":"https://api.github.com/repos/netguru/bob-the-bot/contents/{+path}","compare_url":"https://api.github.com/repos/netguru/bob-the-bot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/netguru/bob-the-bot/merges","archive_url":"https://api.github.com/repos/netguru/bob-the-bot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/netguru/bob-the-bot/downloads","issues_url":"https://api.github.com/repos/netguru/bob-the-bot/issues{/number}","pulls_url":"https://api.github.com/repos/netguru/bob-the-bot/pulls{/number}","milestones_url":"https://api.github.com/repos/netguru/bob-the-bot/milestones{/number}","notifications_url":"https://api.github.com/repos/netguru/bob-the-bot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/netguru/bob-the-bot/labels{/name}","releases_url":"https://api.github.com/repos/netguru/bob-the-bot/releases{/id}","deployments_url":"https://api.github.com/repos/netguru/bob-the-bot/deployments","created_at":"2018-07-17T07:35:10Z","updated_at":"2018-11-07T13:53:45Z","pushed_at":"2018-11-12T16:00:17Z","git_url":"git://github.com/netguru/bob-the-bot.git","ssh_url":"git@github.com:netguru/bob-the-bot.git","clone_url":"https://github.com/netguru/bob-the-bot.git","svn_url":"https://github.com/netguru/bob-the-bot","homepage":null,"size":714,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":5,"license":null,"forks":0,"open_issues":5,"watchers":1,"default_branch":"master"}},"base":{"label":"netguru:project/book","ref":"project/book","sha":"a4f170a29618cf64ed7213663b7f884ab0f54fed","user":{"login":"netguru","id":1146,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExNDY=","avatar_url":"https://avatars1.githubusercontent.com/u/1146?v=4","gravatar_id":"","url":"https://api.github.com/users/netguru","html_url":"https://github.com/netguru","followers_url":"https://api.github.com/users/netguru/followers","following_url":"https://api.github.com/users/netguru/following{/other_user}","gists_url":"https://api.github.com/users/netguru/gists{/gist_id}","starred_url":"https://api.github.com/users/netguru/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/netguru/subscriptions","organizations_url":"https://api.github.com/users/netguru/orgs","repos_url":"https://api.github.com/users/netguru/repos","events_url":"https://api.github.com/users/netguru/events{/privacy}","received_events_url":"https://api.github.com/users/netguru/received_events","type":"Organization","site_admin":false},"repo":{"id":141249965,"node_id":"MDEwOlJlcG9zaXRvcnkxNDEyNDk5NjU=","name":"bob-the-bot","full_name":"netguru/bob-the-bot","private":false,"owner":{"login":"netguru","id":1146,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExNDY=","avatar_url":"https://avatars1.githubusercontent.com/u/1146?v=4","gravatar_id":"","url":"https://api.github.com/users/netguru","html_url":"https://github.com/netguru","followers_url":"https://api.github.com/users/netguru/followers","following_url":"https://api.github.com/users/netguru/following{/other_user}","gists_url":"https://api.github.com/users/netguru/gists{/gist_id}","starred_url":"https://api.github.com/users/netguru/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/netguru/subscriptions","organizations_url":"https://api.github.com/users/netguru/orgs","repos_url":"https://api.github.com/users/netguru/repos","events_url":"https://api.github.com/users/netguru/events{/privacy}","received_events_url":"https://api.github.com/users/netguru/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/netguru/bob-the-bot","description":null,"fork":false,"url":"https://api.github.com/repos/netguru/bob-the-bot","forks_url":"https://api.github.com/repos/netguru/bob-the-bot/forks","keys_url":"https://api.github.com/repos/netguru/bob-the-bot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/netguru/bob-the-bot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/netguru/bob-the-bot/teams","hooks_url":"https://api.github.com/repos/netguru/bob-the-bot/hooks","issue_events_url":"https://api.github.com/repos/netguru/bob-the-bot/issues/events{/number}","events_url":"https://api.github.com/repos/netguru/bob-the-bot/events","assignees_url":"https://api.github.com/repos/netguru/bob-the-bot/assignees{/user}","branches_url":"https://api.github.com/repos/netguru/bob-the-bot/branches{/branch}","tags_url":"https://api.github.com/repos/netguru/bob-the-bot/tags","blobs_url":"https://api.github.com/repos/netguru/bob-the-bot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/netguru/bob-the-bot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/netguru/bob-the-bot/git/refs{/sha}","trees_url":"https://api.github.com/repos/netguru/bob-the-bot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/netguru/bob-the-bot/statuses/{sha}","languages_url":"https://api.github.com/repos/netguru/bob-the-bot/languages","stargazers_url":"https://api.github.com/repos/netguru/bob-the-bot/stargazers","contributors_url":"https://api.github.com/repos/netguru/bob-the-bot/contributors","subscribers_url":"https://api.github.com/repos/netguru/bob-the-bot/subscribers","subscription_url":"https://api.github.com/repos/netguru/bob-the-bot/subscription","commits_url":"https://api.github.com/repos/netguru/bob-the-bot/commits{/sha}","git_commits_url":"https://api.github.com/repos/netguru/bob-the-bot/git/commits{/sha}","comments_url":"https://api.github.com/repos/netguru/bob-the-bot/comments{/number}","issue_comment_url":"https://api.github.com/repos/netguru/bob-the-bot/issues/comments{/number}","contents_url":"https://api.github.com/repos/netguru/bob-the-bot/contents/{+path}","compare_url":"https://api.github.com/repos/netguru/bob-the-bot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/netguru/bob-the-bot/merges","archive_url":"https://api.github.com/repos/netguru/bob-the-bot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/netguru/bob-the-bot/downloads","issues_url":"https://api.github.com/repos/netguru/bob-the-bot/issues{/number}","pulls_url":"https://api.github.com/repos/netguru/bob-the-bot/pulls{/number}","milestones_url":"https://api.github.com/repos/netguru/bob-the-bot/milestones{/number}","notifications_url":"https://api.github.com/repos/netguru/bob-the-bot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/netguru/bob-the-bot/labels{/name}","releases_url":"https://api.github.com/repos/netguru/bob-the-bot/releases{/id}","deployments_url":"https://api.github.com/repos/netguru/bob-the-bot/deployments","created_at":"2018-07-17T07:35:10Z","updated_at":"2018-11-07T13:53:45Z","pushed_at":"2018-11-12T16:00:17Z","git_url":"git://github.com/netguru/bob-the-bot.git","ssh_url":"git@github.com:netguru/bob-the-bot.git","clone_url":"https://github.com/netguru/bob-the-bot.git","svn_url":"https://github.com/netguru/bob-the-bot","homepage":null,"size":714,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":5,"license":null,"forks":0,"open_issues":5,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/netguru/bob-the-bot/pulls/101"},"html":{"href":"https://github.com/netguru/bob-the-bot/pull/101"},"issue":{"href":"https://api.github.com/repos/netguru/bob-the-bot/issues/101"},"comments":{"href":"https://api.github.com/repos/netguru/bob-the-bot/issues/101/comments"},"review_comments":{"href":"https://api.github.com/repos/netguru/bob-the-bot/pulls/101/comments"},"review_comment":{"href":"https://api.github.com/repos/netguru/bob-the-bot/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/netguru/bob-the-bot/pulls/101/commits"},"statuses":{"href":"https://api.github.com/repos/netguru/bob-the-bot/statuses/e3f844e58b559842ae7ccb9814df86dc0c3dc0ce"}},"author_association":"NONE"}}
{"actor":{"display_login":"Getriax"}}