{"action":"created","comment":{"url":"https://api.github.com/repos/monetas/bmclient/pulls/comments/34768263","id":34768263,"diff_hunk":"@@ -0,0 +1,108 @@\n+// Copyright (c) 2015 Monetas.\n+// Use of this source code is governed by an ISC\n+// license that can be found in the LICENSE file.\n+\n+package message\n+\n+import (\n+\t\"errors\"\n+\t\"fmt\"\n+\t\"regexp\"\n+\t\"time\"\n+\n+\t\"github.com/mailhog/data\"\n+\t\"github.com/monetas/bmclient/message/email\"\n+\t\"github.com/monetas/bmutil/pow\"\n+)\n+\n+const bmAddrPattern = \"BM-[123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ]+\"\n+\n+var bmAddrRegex, _ = regexp.Compile(bmAddrPattern)\n+var emailRegex, _ = regexp.Compile(fmt.Sprintf(\"%s@bm\\\\.addr\", bmAddrRegex))\n+\n+// TODO any other headers that should be addressed?\n+func toBitmessage(smtp *data.Content) (Bitmessage, error) {\n+\theader := smtp.Headers\n+\n+\t// Check that To and From are set.\n+\tvar to, from string\n+\tif toList, ok := header[\"To\"]; !ok {\n+\t\treturn nil, errors.New(\"Invalid headers: To field is required\")\n+\t} else {\n+\t\tif len(toList) != 1 {\n+\t\t\treturn nil, errors.New(\"Invalid headers: only one To field is allowed.\")\n+\t\t}\n+\t\tto = toList[0]","path":"message/bitmessage.go","position":35,"original_position":35,"commit_id":"e6999e52ccb6bf3f7acc3bd6f3e4b8f0f42f265b","original_commit_id":"e6999e52ccb6bf3f7acc3bd6f3e4b8f0f42f265b","user":{"login":"ishbir","id":43928,"avatar_url":"https://avatars.githubusercontent.com/u/43928?v=3","gravatar_id":"","url":"https://api.github.com/users/ishbir","html_url":"https://github.com/ishbir","followers_url":"https://api.github.com/users/ishbir/followers","following_url":"https://api.github.com/users/ishbir/following{/other_user}","gists_url":"https://api.github.com/users/ishbir/gists{/gist_id}","starred_url":"https://api.github.com/users/ishbir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ishbir/subscriptions","organizations_url":"https://api.github.com/users/ishbir/orgs","repos_url":"https://api.github.com/users/ishbir/repos","events_url":"https://api.github.com/users/ishbir/events{/privacy}","received_events_url":"https://api.github.com/users/ishbir/received_events","type":"User","site_admin":false},"body":"Why should we have this restriction of just one To field? It's perfectly reasonable to send a message to multiple people.","created_at":"2015-07-16T09:05:36Z","updated_at":"2015-07-16T09:05:36Z","html_url":"https://github.com/monetas/bmclient/pull/2#discussion_r34768263","pull_request_url":"https://api.github.com/repos/monetas/bmclient/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/monetas/bmclient/pulls/comments/34768263"},"html":{"href":"https://github.com/monetas/bmclient/pull/2#discussion_r34768263"},"pull_request":{"href":"https://api.github.com/repos/monetas/bmclient/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/monetas/bmclient/pulls/2","id":39138397,"html_url":"https://github.com/monetas/bmclient/pull/2","diff_url":"https://github.com/monetas/bmclient/pull/2.diff","patch_url":"https://github.com/monetas/bmclient/pull/2.patch","issue_url":"https://api.github.com/repos/monetas/bmclient/issues/2","number":2,"state":"open","locked":false,"title":"[WIP] email server","user":{"login":"DanielKrawisz","id":4990891,"avatar_url":"https://avatars.githubusercontent.com/u/4990891?v=3","gravatar_id":"","url":"https://api.github.com/users/DanielKrawisz","html_url":"https://github.com/DanielKrawisz","followers_url":"https://api.github.com/users/DanielKrawisz/followers","following_url":"https://api.github.com/users/DanielKrawisz/following{/other_user}","gists_url":"https://api.github.com/users/DanielKrawisz/gists{/gist_id}","starred_url":"https://api.github.com/users/DanielKrawisz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DanielKrawisz/subscriptions","organizations_url":"https://api.github.com/users/DanielKrawisz/orgs","repos_url":"https://api.github.com/users/DanielKrawisz/repos","events_url":"https://api.github.com/users/DanielKrawisz/events{/privacy}","received_events_url":"https://api.github.com/users/DanielKrawisz/received_events","type":"User","site_admin":false},"body":"This wip pr will contain all the functionality required to make bmclient a SMTP and IMAP server that translates between email and bitmessage formats. \r\n\r\nHere is what is there so far. \r\n* SMTP server with no authentication or recognition of different users (yet). \r\n* Data structures required for compatibility with imap and an imap server, but I don't know if it works yet. \r\n* Objects representing a bitmessage message store that works by analogy with IMAP email. ","created_at":"2015-07-03T00:47:25Z","updated_at":"2015-07-16T09:05:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5f8c1efb7da7f0678b714876e835ea54a9da7b63","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/monetas/bmclient/pulls/2/commits","review_comments_url":"https://api.github.com/repos/monetas/bmclient/pulls/2/comments","review_comment_url":"https://api.github.com/repos/monetas/bmclient/pulls/comments{/number}","comments_url":"https://api.github.com/repos/monetas/bmclient/issues/2/comments","statuses_url":"https://api.github.com/repos/monetas/bmclient/statuses/e6999e52ccb6bf3f7acc3bd6f3e4b8f0f42f265b","head":{"label":"DanielKrawisz:email","ref":"email","sha":"e6999e52ccb6bf3f7acc3bd6f3e4b8f0f42f265b","user":{"login":"DanielKrawisz","id":4990891,"avatar_url":"https://avatars.githubusercontent.com/u/4990891?v=3","gravatar_id":"","url":"https://api.github.com/users/DanielKrawisz","html_url":"https://github.com/DanielKrawisz","followers_url":"https://api.github.com/users/DanielKrawisz/followers","following_url":"https://api.github.com/users/DanielKrawisz/following{/other_user}","gists_url":"https://api.github.com/users/DanielKrawisz/gists{/gist_id}","starred_url":"https://api.github.com/users/DanielKrawisz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DanielKrawisz/subscriptions","organizations_url":"https://api.github.com/users/DanielKrawisz/orgs","repos_url":"https://api.github.com/users/DanielKrawisz/repos","events_url":"https://api.github.com/users/DanielKrawisz/events{/privacy}","received_events_url":"https://api.github.com/users/DanielKrawisz/received_events","type":"User","site_admin":false},"repo":{"id":38185872,"name":"bmclient","full_name":"DanielKrawisz/bmclient","owner":{"login":"DanielKrawisz","id":4990891,"avatar_url":"https://avatars.githubusercontent.com/u/4990891?v=3","gravatar_id":"","url":"https://api.github.com/users/DanielKrawisz","html_url":"https://github.com/DanielKrawisz","followers_url":"https://api.github.com/users/DanielKrawisz/followers","following_url":"https://api.github.com/users/DanielKrawisz/following{/other_user}","gists_url":"https://api.github.com/users/DanielKrawisz/gists{/gist_id}","starred_url":"https://api.github.com/users/DanielKrawisz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DanielKrawisz/subscriptions","organizations_url":"https://api.github.com/users/DanielKrawisz/orgs","repos_url":"https://api.github.com/users/DanielKrawisz/repos","events_url":"https://api.github.com/users/DanielKrawisz/events{/privacy}","received_events_url":"https://api.github.com/users/DanielKrawisz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/DanielKrawisz/bmclient","description":"Client for bmd, functions as IMAP/SMTP server -- Alpha/Experimental Code","fork":true,"url":"https://api.github.com/repos/DanielKrawisz/bmclient","forks_url":"https://api.github.com/repos/DanielKrawisz/bmclient/forks","keys_url":"https://api.github.com/repos/DanielKrawisz/bmclient/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DanielKrawisz/bmclient/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DanielKrawisz/bmclient/teams","hooks_url":"https://api.github.com/repos/DanielKrawisz/bmclient/hooks","issue_events_url":"https://api.github.com/repos/DanielKrawisz/bmclient/issues/events{/number}","events_url":"https://api.github.com/repos/DanielKrawisz/bmclient/events","assignees_url":"https://api.github.com/repos/DanielKrawisz/bmclient/assignees{/user}","branches_url":"https://api.github.com/repos/DanielKrawisz/bmclient/branches{/branch}","tags_url":"https://api.github.com/repos/DanielKrawisz/bmclient/tags","blobs_url":"https://api.github.com/repos/DanielKrawisz/bmclient/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DanielKrawisz/bmclient/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DanielKrawisz/bmclient/git/refs{/sha}","trees_url":"https://api.github.com/repos/DanielKrawisz/bmclient/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DanielKrawisz/bmclient/statuses/{sha}","languages_url":"https://api.github.com/repos/DanielKrawisz/bmclient/languages","stargazers_url":"https://api.github.com/repos/DanielKrawisz/bmclient/stargazers","contributors_url":"https://api.github.com/repos/DanielKrawisz/bmclient/contributors","subscribers_url":"https://api.github.com/repos/DanielKrawisz/bmclient/subscribers","subscription_url":"https://api.github.com/repos/DanielKrawisz/bmclient/subscription","commits_url":"https://api.github.com/repos/DanielKrawisz/bmclient/commits{/sha}","git_commits_url":"https://api.github.com/repos/DanielKrawisz/bmclient/git/commits{/sha}","comments_url":"https://api.github.com/repos/DanielKrawisz/bmclient/comments{/number}","issue_comment_url":"https://api.github.com/repos/DanielKrawisz/bmclient/issues/comments{/number}","contents_url":"https://api.github.com/repos/DanielKrawisz/bmclient/contents/{+path}","compare_url":"https://api.github.com/repos/DanielKrawisz/bmclient/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DanielKrawisz/bmclient/merges","archive_url":"https://api.github.com/repos/DanielKrawisz/bmclient/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DanielKrawisz/bmclient/downloads","issues_url":"https://api.github.com/repos/DanielKrawisz/bmclient/issues{/number}","pulls_url":"https://api.github.com/repos/DanielKrawisz/bmclient/pulls{/number}","milestones_url":"https://api.github.com/repos/DanielKrawisz/bmclient/milestones{/number}","notifications_url":"https://api.github.com/repos/DanielKrawisz/bmclient/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DanielKrawisz/bmclient/labels{/name}","releases_url":"https://api.github.com/repos/DanielKrawisz/bmclient/releases{/id}","created_at":"2015-06-28T04:09:58Z","updated_at":"2015-06-28T04:09:58Z","pushed_at":"2015-07-16T01:45:03Z","git_url":"git://github.com/DanielKrawisz/bmclient.git","ssh_url":"git@github.com:DanielKrawisz/bmclient.git","clone_url":"https://github.com/DanielKrawisz/bmclient.git","svn_url":"https://github.com/DanielKrawisz/bmclient","homepage":"","size":127,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"monetas:master","ref":"master","sha":"86843a8657ac4866874d7cbe029d2b7b9b73de6d","user":{"login":"monetas","id":4219418,"avatar_url":"https://avatars.githubusercontent.com/u/4219418?v=3","gravatar_id":"","url":"https://api.github.com/users/monetas","html_url":"https://github.com/monetas","followers_url":"https://api.github.com/users/monetas/followers","following_url":"https://api.github.com/users/monetas/following{/other_user}","gists_url":"https://api.github.com/users/monetas/gists{/gist_id}","starred_url":"https://api.github.com/users/monetas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monetas/subscriptions","organizations_url":"https://api.github.com/users/monetas/orgs","repos_url":"https://api.github.com/users/monetas/repos","events_url":"https://api.github.com/users/monetas/events{/privacy}","received_events_url":"https://api.github.com/users/monetas/received_events","type":"Organization","site_admin":false},"repo":{"id":32594770,"name":"bmclient","full_name":"monetas/bmclient","owner":{"login":"monetas","id":4219418,"avatar_url":"https://avatars.githubusercontent.com/u/4219418?v=3","gravatar_id":"","url":"https://api.github.com/users/monetas","html_url":"https://github.com/monetas","followers_url":"https://api.github.com/users/monetas/followers","following_url":"https://api.github.com/users/monetas/following{/other_user}","gists_url":"https://api.github.com/users/monetas/gists{/gist_id}","starred_url":"https://api.github.com/users/monetas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monetas/subscriptions","organizations_url":"https://api.github.com/users/monetas/orgs","repos_url":"https://api.github.com/users/monetas/repos","events_url":"https://api.github.com/users/monetas/events{/privacy}","received_events_url":"https://api.github.com/users/monetas/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/monetas/bmclient","description":"Client for bmd, functions as IMAP/SMTP server -- Alpha/Experimental Code","fork":false,"url":"https://api.github.com/repos/monetas/bmclient","forks_url":"https://api.github.com/repos/monetas/bmclient/forks","keys_url":"https://api.github.com/repos/monetas/bmclient/keys{/key_id}","collaborators_url":"https://api.github.com/repos/monetas/bmclient/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/monetas/bmclient/teams","hooks_url":"https://api.github.com/repos/monetas/bmclient/hooks","issue_events_url":"https://api.github.com/repos/monetas/bmclient/issues/events{/number}","events_url":"https://api.github.com/repos/monetas/bmclient/events","assignees_url":"https://api.github.com/repos/monetas/bmclient/assignees{/user}","branches_url":"https://api.github.com/repos/monetas/bmclient/branches{/branch}","tags_url":"https://api.github.com/repos/monetas/bmclient/tags","blobs_url":"https://api.github.com/repos/monetas/bmclient/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/monetas/bmclient/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/monetas/bmclient/git/refs{/sha}","trees_url":"https://api.github.com/repos/monetas/bmclient/git/trees{/sha}","statuses_url":"https://api.github.com/repos/monetas/bmclient/statuses/{sha}","languages_url":"https://api.github.com/repos/monetas/bmclient/languages","stargazers_url":"https://api.github.com/repos/monetas/bmclient/stargazers","contributors_url":"https://api.github.com/repos/monetas/bmclient/contributors","subscribers_url":"https://api.github.com/repos/monetas/bmclient/subscribers","subscription_url":"https://api.github.com/repos/monetas/bmclient/subscription","commits_url":"https://api.github.com/repos/monetas/bmclient/commits{/sha}","git_commits_url":"https://api.github.com/repos/monetas/bmclient/git/commits{/sha}","comments_url":"https://api.github.com/repos/monetas/bmclient/comments{/number}","issue_comment_url":"https://api.github.com/repos/monetas/bmclient/issues/comments{/number}","contents_url":"https://api.github.com/repos/monetas/bmclient/contents/{+path}","compare_url":"https://api.github.com/repos/monetas/bmclient/compare/{base}...{head}","merges_url":"https://api.github.com/repos/monetas/bmclient/merges","archive_url":"https://api.github.com/repos/monetas/bmclient/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/monetas/bmclient/downloads","issues_url":"https://api.github.com/repos/monetas/bmclient/issues{/number}","pulls_url":"https://api.github.com/repos/monetas/bmclient/pulls{/number}","milestones_url":"https://api.github.com/repos/monetas/bmclient/milestones{/number}","notifications_url":"https://api.github.com/repos/monetas/bmclient/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/monetas/bmclient/labels{/name}","releases_url":"https://api.github.com/repos/monetas/bmclient/releases{/id}","created_at":"2015-03-20T16:30:36Z","updated_at":"2015-07-03T11:54:55Z","pushed_at":"2015-07-16T01:45:03Z","git_url":"git://github.com/monetas/bmclient.git","ssh_url":"git@github.com:monetas/bmclient.git","clone_url":"https://github.com/monetas/bmclient.git","svn_url":"https://github.com/monetas/bmclient","homepage":"","size":477,"stargazers_count":1,"watchers_count":1,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":2,"forks":2,"open_issues":2,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/monetas/bmclient/pulls/2"},"html":{"href":"https://github.com/monetas/bmclient/pull/2"},"issue":{"href":"https://api.github.com/repos/monetas/bmclient/issues/2"},"comments":{"href":"https://api.github.com/repos/monetas/bmclient/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/monetas/bmclient/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/monetas/bmclient/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/monetas/bmclient/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/monetas/bmclient/statuses/e6999e52ccb6bf3f7acc3bd6f3e4b8f0f42f265b"}}}}