{"action":"created","comment":{"url":"https://api.github.com/repos/praekelt/vumi-yowsup/pulls/comments/33452124","id":33452124,"diff_hunk":"@@ -109,29 +113,36 @@ def _kill():\n \n     def send_to_stack(self, text, to_address):\n         def send():\n-            self.echo_layer.send_to_human(text, to_address)\n-            print('in stack_client', text, to_address)\n+            self.whatsapp_interface.send_to_human(text, to_address)\n         self.stack.execDetached(send)\n \n \n-class EchoLayer(YowInterfaceLayer):\n+class WhatsAppInterface(YowInterfaceLayer):\n+\n+    def __init__(self, transport):\n+        super(WhatsAppInterface, self).__init__()\n+        self.transport = transport\n \n     def send_to_human(self, text, to_address):\n         message = TextMessageProtocolEntity(text, to=to_address)\n         self.toLower(message)\n-        # print('in echo_layer', text, to_address)\n \n     @ProtocolEntityCallback(\"message\")\n     def onMessage(self, messageProtocolEntity):\n+        from_address = messageProtocolEntity.getFrom()\n+        body = messageProtocolEntity.getBody()\n+        to_address = messageProtocolEntity.getTo()\n+\n         receipt = OutgoingReceiptProtocolEntity(\n             messageProtocolEntity.getId(),\n-            messageProtocolEntity.getFrom(), 'read',\n+            from_address, 'read',\n             messageProtocolEntity.getParticipant())\n \n         self.toLower(receipt)\n \n-        self.send_to_human(text=messageProtocolEntity.getBody(),\n-                           to_address=messageProtocolEntity.getFrom())\n+        reactor.callFromThread(self.transport.publish_message,\n+                               from_addr=from_address, content=body, to_addr=to_address,","path":"vxyowsup/whatsapp.py","position":87,"original_position":87,"commit_id":"28bfbc30c795bceb38435d7ed872c1f7adb0b31d","original_commit_id":"28bfbc30c795bceb38435d7ed872c1f7adb0b31d","user":{"login":"hodgestar","id":165551,"avatar_url":"https://avatars.githubusercontent.com/u/165551?v=3","gravatar_id":"","url":"https://api.github.com/users/hodgestar","html_url":"https://github.com/hodgestar","followers_url":"https://api.github.com/users/hodgestar/followers","following_url":"https://api.github.com/users/hodgestar/following{/other_user}","gists_url":"https://api.github.com/users/hodgestar/gists{/gist_id}","starred_url":"https://api.github.com/users/hodgestar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hodgestar/subscriptions","organizations_url":"https://api.github.com/users/hodgestar/orgs","repos_url":"https://api.github.com/users/hodgestar/repos","events_url":"https://api.github.com/users/hodgestar/events{/privacy}","received_events_url":"https://api.github.com/users/hodgestar/received_events","type":"User","site_admin":false},"body":"So here we would strip the `@s.whatsapp.net` from `from_address` before sending it out. It might be polite to also set the `to_addr_type` to `TransportUserMessage.AT_MSISDN`.","created_at":"2015-06-29T10:43:30Z","updated_at":"2015-06-29T10:43:30Z","html_url":"https://github.com/praekelt/vumi-yowsup/pull/6#discussion_r33452124","pull_request_url":"https://api.github.com/repos/praekelt/vumi-yowsup/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/praekelt/vumi-yowsup/pulls/comments/33452124"},"html":{"href":"https://github.com/praekelt/vumi-yowsup/pull/6#discussion_r33452124"},"pull_request":{"href":"https://api.github.com/repos/praekelt/vumi-yowsup/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/praekelt/vumi-yowsup/pulls/6","id":38760245,"html_url":"https://github.com/praekelt/vumi-yowsup/pull/6","diff_url":"https://github.com/praekelt/vumi-yowsup/pull/6.diff","patch_url":"https://github.com/praekelt/vumi-yowsup/pull/6.patch","issue_url":"https://api.github.com/repos/praekelt/vumi-yowsup/issues/6","number":6,"state":"open","locked":false,"title":"Add publish message functionality","user":{"login":"Hannarst","id":12196732,"avatar_url":"https://avatars.githubusercontent.com/u/12196732?v=3","gravatar_id":"","url":"https://api.github.com/users/Hannarst","html_url":"https://github.com/Hannarst","followers_url":"https://api.github.com/users/Hannarst/followers","following_url":"https://api.github.com/users/Hannarst/following{/other_user}","gists_url":"https://api.github.com/users/Hannarst/gists{/gist_id}","starred_url":"https://api.github.com/users/Hannarst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Hannarst/subscriptions","organizations_url":"https://api.github.com/users/Hannarst/orgs","repos_url":"https://api.github.com/users/Hannarst/repos","events_url":"https://api.github.com/users/Hannarst/events{/privacy}","received_events_url":"https://api.github.com/users/Hannarst/received_events","type":"User","site_admin":false},"body":"Send incoming messages (from yowsup/WhatsApp/humans) from the ```EchoLayer``` to Vumi applications using the given base ```Transport``` class ```publish_message``` method in a thread safe way.","created_at":"2015-06-29T10:28:56Z","updated_at":"2015-06-29T10:43:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bac111a2ea24b9d537935f074abafda02927f4d0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/praekelt/vumi-yowsup/pulls/6/commits","review_comments_url":"https://api.github.com/repos/praekelt/vumi-yowsup/pulls/6/comments","review_comment_url":"https://api.github.com/repos/praekelt/vumi-yowsup/pulls/comments{/number}","comments_url":"https://api.github.com/repos/praekelt/vumi-yowsup/issues/6/comments","statuses_url":"https://api.github.com/repos/praekelt/vumi-yowsup/statuses/28bfbc30c795bceb38435d7ed872c1f7adb0b31d","head":{"label":"praekelt:feature/issue-6-add-publish-functionality","ref":"feature/issue-6-add-publish-functionality","sha":"28bfbc30c795bceb38435d7ed872c1f7adb0b31d","user":{"login":"praekelt","id":81810,"avatar_url":"https://avatars.githubusercontent.com/u/81810?v=3","gravatar_id":"","url":"https://api.github.com/users/praekelt","html_url":"https://github.com/praekelt","followers_url":"https://api.github.com/users/praekelt/followers","following_url":"https://api.github.com/users/praekelt/following{/other_user}","gists_url":"https://api.github.com/users/praekelt/gists{/gist_id}","starred_url":"https://api.github.com/users/praekelt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/praekelt/subscriptions","organizations_url":"https://api.github.com/users/praekelt/orgs","repos_url":"https://api.github.com/users/praekelt/repos","events_url":"https://api.github.com/users/praekelt/events{/privacy}","received_events_url":"https://api.github.com/users/praekelt/received_events","type":"Organization","site_admin":false},"repo":{"id":37712582,"name":"vumi-yowsup","full_name":"praekelt/vumi-yowsup","owner":{"login":"praekelt","id":81810,"avatar_url":"https://avatars.githubusercontent.com/u/81810?v=3","gravatar_id":"","url":"https://api.github.com/users/praekelt","html_url":"https://github.com/praekelt","followers_url":"https://api.github.com/users/praekelt/followers","following_url":"https://api.github.com/users/praekelt/following{/other_user}","gists_url":"https://api.github.com/users/praekelt/gists{/gist_id}","starred_url":"https://api.github.com/users/praekelt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/praekelt/subscriptions","organizations_url":"https://api.github.com/users/praekelt/orgs","repos_url":"https://api.github.com/users/praekelt/repos","events_url":"https://api.github.com/users/praekelt/events{/privacy}","received_events_url":"https://api.github.com/users/praekelt/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/praekelt/vumi-yowsup","description":"A WhatsApp transport for Vumi.","fork":false,"url":"https://api.github.com/repos/praekelt/vumi-yowsup","forks_url":"https://api.github.com/repos/praekelt/vumi-yowsup/forks","keys_url":"https://api.github.com/repos/praekelt/vumi-yowsup/keys{/key_id}","collaborators_url":"https://api.github.com/repos/praekelt/vumi-yowsup/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/praekelt/vumi-yowsup/teams","hooks_url":"https://api.github.com/repos/praekelt/vumi-yowsup/hooks","issue_events_url":"https://api.github.com/repos/praekelt/vumi-yowsup/issues/events{/number}","events_url":"https://api.github.com/repos/praekelt/vumi-yowsup/events","assignees_url":"https://api.github.com/repos/praekelt/vumi-yowsup/assignees{/user}","branches_url":"https://api.github.com/repos/praekelt/vumi-yowsup/branches{/branch}","tags_url":"https://api.github.com/repos/praekelt/vumi-yowsup/tags","blobs_url":"https://api.github.com/repos/praekelt/vumi-yowsup/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/praekelt/vumi-yowsup/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/praekelt/vumi-yowsup/git/refs{/sha}","trees_url":"https://api.github.com/repos/praekelt/vumi-yowsup/git/trees{/sha}","statuses_url":"https://api.github.com/repos/praekelt/vumi-yowsup/statuses/{sha}","languages_url":"https://api.github.com/repos/praekelt/vumi-yowsup/languages","stargazers_url":"https://api.github.com/repos/praekelt/vumi-yowsup/stargazers","contributors_url":"https://api.github.com/repos/praekelt/vumi-yowsup/contributors","subscribers_url":"https://api.github.com/repos/praekelt/vumi-yowsup/subscribers","subscription_url":"https://api.github.com/repos/praekelt/vumi-yowsup/subscription","commits_url":"https://api.github.com/repos/praekelt/vumi-yowsup/commits{/sha}","git_commits_url":"https://api.github.com/repos/praekelt/vumi-yowsup/git/commits{/sha}","comments_url":"https://api.github.com/repos/praekelt/vumi-yowsup/comments{/number}","issue_comment_url":"https://api.github.com/repos/praekelt/vumi-yowsup/issues/comments{/number}","contents_url":"https://api.github.com/repos/praekelt/vumi-yowsup/contents/{+path}","compare_url":"https://api.github.com/repos/praekelt/vumi-yowsup/compare/{base}...{head}","merges_url":"https://api.github.com/repos/praekelt/vumi-yowsup/merges","archive_url":"https://api.github.com/repos/praekelt/vumi-yowsup/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/praekelt/vumi-yowsup/downloads","issues_url":"https://api.github.com/repos/praekelt/vumi-yowsup/issues{/number}","pulls_url":"https://api.github.com/repos/praekelt/vumi-yowsup/pulls{/number}","milestones_url":"https://api.github.com/repos/praekelt/vumi-yowsup/milestones{/number}","notifications_url":"https://api.github.com/repos/praekelt/vumi-yowsup/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/praekelt/vumi-yowsup/labels{/name}","releases_url":"https://api.github.com/repos/praekelt/vumi-yowsup/releases{/id}","created_at":"2015-06-19T09:08:27Z","updated_at":"2015-06-19T09:20:33Z","pushed_at":"2015-06-29T10:28:56Z","git_url":"git://github.com/praekelt/vumi-yowsup.git","ssh_url":"git@github.com:praekelt/vumi-yowsup.git","clone_url":"https://github.com/praekelt/vumi-yowsup.git","svn_url":"https://github.com/praekelt/vumi-yowsup","homepage":null,"size":172,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"develop"}},"base":{"label":"praekelt:develop","ref":"develop","sha":"036af7756b8e8de6f76fe396fddde72decc803cf","user":{"login":"praekelt","id":81810,"avatar_url":"https://avatars.githubusercontent.com/u/81810?v=3","gravatar_id":"","url":"https://api.github.com/users/praekelt","html_url":"https://github.com/praekelt","followers_url":"https://api.github.com/users/praekelt/followers","following_url":"https://api.github.com/users/praekelt/following{/other_user}","gists_url":"https://api.github.com/users/praekelt/gists{/gist_id}","starred_url":"https://api.github.com/users/praekelt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/praekelt/subscriptions","organizations_url":"https://api.github.com/users/praekelt/orgs","repos_url":"https://api.github.com/users/praekelt/repos","events_url":"https://api.github.com/users/praekelt/events{/privacy}","received_events_url":"https://api.github.com/users/praekelt/received_events","type":"Organization","site_admin":false},"repo":{"id":37712582,"name":"vumi-yowsup","full_name":"praekelt/vumi-yowsup","owner":{"login":"praekelt","id":81810,"avatar_url":"https://avatars.githubusercontent.com/u/81810?v=3","gravatar_id":"","url":"https://api.github.com/users/praekelt","html_url":"https://github.com/praekelt","followers_url":"https://api.github.com/users/praekelt/followers","following_url":"https://api.github.com/users/praekelt/following{/other_user}","gists_url":"https://api.github.com/users/praekelt/gists{/gist_id}","starred_url":"https://api.github.com/users/praekelt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/praekelt/subscriptions","organizations_url":"https://api.github.com/users/praekelt/orgs","repos_url":"https://api.github.com/users/praekelt/repos","events_url":"https://api.github.com/users/praekelt/events{/privacy}","received_events_url":"https://api.github.com/users/praekelt/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/praekelt/vumi-yowsup","description":"A WhatsApp transport for Vumi.","fork":false,"url":"https://api.github.com/repos/praekelt/vumi-yowsup","forks_url":"https://api.github.com/repos/praekelt/vumi-yowsup/forks","keys_url":"https://api.github.com/repos/praekelt/vumi-yowsup/keys{/key_id}","collaborators_url":"https://api.github.com/repos/praekelt/vumi-yowsup/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/praekelt/vumi-yowsup/teams","hooks_url":"https://api.github.com/repos/praekelt/vumi-yowsup/hooks","issue_events_url":"https://api.github.com/repos/praekelt/vumi-yowsup/issues/events{/number}","events_url":"https://api.github.com/repos/praekelt/vumi-yowsup/events","assignees_url":"https://api.github.com/repos/praekelt/vumi-yowsup/assignees{/user}","branches_url":"https://api.github.com/repos/praekelt/vumi-yowsup/branches{/branch}","tags_url":"https://api.github.com/repos/praekelt/vumi-yowsup/tags","blobs_url":"https://api.github.com/repos/praekelt/vumi-yowsup/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/praekelt/vumi-yowsup/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/praekelt/vumi-yowsup/git/refs{/sha}","trees_url":"https://api.github.com/repos/praekelt/vumi-yowsup/git/trees{/sha}","statuses_url":"https://api.github.com/repos/praekelt/vumi-yowsup/statuses/{sha}","languages_url":"https://api.github.com/repos/praekelt/vumi-yowsup/languages","stargazers_url":"https://api.github.com/repos/praekelt/vumi-yowsup/stargazers","contributors_url":"https://api.github.com/repos/praekelt/vumi-yowsup/contributors","subscribers_url":"https://api.github.com/repos/praekelt/vumi-yowsup/subscribers","subscription_url":"https://api.github.com/repos/praekelt/vumi-yowsup/subscription","commits_url":"https://api.github.com/repos/praekelt/vumi-yowsup/commits{/sha}","git_commits_url":"https://api.github.com/repos/praekelt/vumi-yowsup/git/commits{/sha}","comments_url":"https://api.github.com/repos/praekelt/vumi-yowsup/comments{/number}","issue_comment_url":"https://api.github.com/repos/praekelt/vumi-yowsup/issues/comments{/number}","contents_url":"https://api.github.com/repos/praekelt/vumi-yowsup/contents/{+path}","compare_url":"https://api.github.com/repos/praekelt/vumi-yowsup/compare/{base}...{head}","merges_url":"https://api.github.com/repos/praekelt/vumi-yowsup/merges","archive_url":"https://api.github.com/repos/praekelt/vumi-yowsup/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/praekelt/vumi-yowsup/downloads","issues_url":"https://api.github.com/repos/praekelt/vumi-yowsup/issues{/number}","pulls_url":"https://api.github.com/repos/praekelt/vumi-yowsup/pulls{/number}","milestones_url":"https://api.github.com/repos/praekelt/vumi-yowsup/milestones{/number}","notifications_url":"https://api.github.com/repos/praekelt/vumi-yowsup/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/praekelt/vumi-yowsup/labels{/name}","releases_url":"https://api.github.com/repos/praekelt/vumi-yowsup/releases{/id}","created_at":"2015-06-19T09:08:27Z","updated_at":"2015-06-19T09:20:33Z","pushed_at":"2015-06-29T10:28:56Z","git_url":"git://github.com/praekelt/vumi-yowsup.git","ssh_url":"git@github.com:praekelt/vumi-yowsup.git","clone_url":"https://github.com/praekelt/vumi-yowsup.git","svn_url":"https://github.com/praekelt/vumi-yowsup","homepage":null,"size":172,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/praekelt/vumi-yowsup/pulls/6"},"html":{"href":"https://github.com/praekelt/vumi-yowsup/pull/6"},"issue":{"href":"https://api.github.com/repos/praekelt/vumi-yowsup/issues/6"},"comments":{"href":"https://api.github.com/repos/praekelt/vumi-yowsup/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/praekelt/vumi-yowsup/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/praekelt/vumi-yowsup/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/praekelt/vumi-yowsup/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/praekelt/vumi-yowsup/statuses/28bfbc30c795bceb38435d7ed872c1f7adb0b31d"}}}}