{"action":"created","comment":{"url":"https://api.github.com/repos/mantas-kemesius/RubyApp/pulls/comments/234411772","pull_request_review_id":176057280,"id":234411772,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzNDQxMTc3Mg==","diff_hunk":"@@ -43,101 +49,143 @@ def emails_menu\n   puts '[1] Compose an email'\n   puts '[2] Inbox'\n   puts '[3] Sent'\n+  puts '[0] Exit'\n end\n \n-def send_email\n-  file = FilesHandler.new(@email_dir_name)\n-  data = file.load_data\n+def compose_email(emails)\n   print 'To: '\n   email_to = gets.chomp\n-  if email_used?(email_to)\n+\n+  users = UserWindow.new(@user_dir_name)\n+  users.load_users\n+  if users.email_used?(email_to)\n     print 'Title: '\n     title = gets.chomp\n     print 'Text: '\n     text = gets.chomp\n-    data[data.length] = {\n-        email_from: @active_user.email,\n-        email_to: email_to,\n-        title: title,\n-        text: text\n-    }\n-    file.save_data(data)\n+    emails.add_email_by_hash(\n+        {\n+          'date' => Date.today.to_s,\n+          'email_to' => email_to,\n+          'email_from' => @active_user.email,\n+          'title' => title,\n+          'text' => text\n+        })\n+\n+    emails.save_emails\n     puts 'Email was sent successfully'\n   else\n     puts 'Email ' + email_to + ' not found'\n   end\n-  #   file = FilesHandler.new('../fakeDatabase/Emails.json')\n-  #   data = file.load_data\n-  #   print 'FROM: '\n-  #   email_from = gets.chomp\n-  #   print 'To: '\n-  #   email_to = gets.chomp\n-  #   print 'Title: '\n-  #   title = gets.chomp\n-  #   print 'Text: '\n-  #   text = gets.chomp\n-  #   data[data.length] = {\n-  #     email_from: email_from,\n-  #     email_to: email_to,\n-  #     title: title,\n-  #     text: text\n-  #   }\n-  #   file.save_data(data)\n-  #   puts 'Email was sent successfully'\n end\n \n-def email_used?(email)\n-  file = FilesHandler.new(@user_dir_name)\n-  data = file.load_data\n-  data.each do |item|\n-    return true if email == item.fetch('email')\n-  end\n-  false\n-end\n-\n-def print_received_emails\n+def print_inbox(emails)\n   clear\n-  file = FilesHandler.new(@email_dir_name)\n-  data = file.load_data\n-  data.each do |item|\n-    next unless @active_user.email == item.fetch('email_to')\n-    puts\n-    puts '------------------'\n-    puts\n-    puts \"FROM: #{item.fetch('email_from')}\"\n-    puts \"TO: #{item.fetch('email_to')}\"\n-    puts \"TITLE: #{item.fetch('title')}\"\n-    puts \"TEXT: #{item.fetch('text')}\"\n-  end\n-  puts\n-  puts '------------------'\n-  puts\n+  emails.print_received_by(@active_user.email)\n   pause\n end\n \n-def print_sent_emails\n+def print_sent(emails)\n   clear\n-  file = FilesHandler.new(@email_dir_name)\n-  data = file.load_data\n-  data.each do |item|\n-    next unless @active_user.email == item.fetch('email_from')\n-    puts\n-    puts '------------------'\n-    puts\n-    puts \"FROM: #{item.fetch('email_from')}\"\n-    puts \"TO: #{item.fetch('email_to')}\"\n-    puts \"TITLE: #{item.fetch('title')}\"\n-    puts \"TEXT: #{item.fetch('text')}\"\n-  end\n-  puts\n-  puts '------------------'\n-  puts\n+  emails.print_sent_by(@active_user.email)\n   pause\n end\n \n+\n+\n+# def send_email\n+#   file = FilesHandler.new(@email_dir_name)\n+#   data = file.load_data\n+#   print 'To: '","path":"ConsoleApp/lib/email_main.rb","position":156,"original_position":156,"commit_id":"5210a3c8e49a150101a66a1eb4cba8c87bd2ab48","original_commit_id":"5210a3c8e49a150101a66a1eb4cba8c87bd2ab48","user":{"login":"TomasMacikas","id":43248775,"node_id":"MDQ6VXNlcjQzMjQ4Nzc1","avatar_url":"https://avatars0.githubusercontent.com/u/43248775?v=4","gravatar_id":"","url":"https://api.github.com/users/TomasMacikas","html_url":"https://github.com/TomasMacikas","followers_url":"https://api.github.com/users/TomasMacikas/followers","following_url":"https://api.github.com/users/TomasMacikas/following{/other_user}","gists_url":"https://api.github.com/users/TomasMacikas/gists{/gist_id}","starred_url":"https://api.github.com/users/TomasMacikas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TomasMacikas/subscriptions","organizations_url":"https://api.github.com/users/TomasMacikas/orgs","repos_url":"https://api.github.com/users/TomasMacikas/repos","events_url":"https://api.github.com/users/TomasMacikas/events{/privacy}","received_events_url":"https://api.github.com/users/TomasMacikas/received_events","type":"User","site_admin":false},"body":"jei perrasei viska, tai istrink kas nereikalinga","created_at":"2018-11-17T15:32:22Z","updated_at":"2018-11-17T15:32:23Z","html_url":"https://github.com/mantas-kemesius/RubyApp/pull/42#discussion_r234411772","pull_request_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/pulls/42","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/mantas-kemesius/RubyApp/pulls/comments/234411772"},"html":{"href":"https://github.com/mantas-kemesius/RubyApp/pull/42#discussion_r234411772"},"pull_request":{"href":"https://api.github.com/repos/mantas-kemesius/RubyApp/pulls/42"}}},"pull_request":{"url":"https://api.github.com/repos/mantas-kemesius/RubyApp/pulls/42","id":231732617,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMxNzMyNjE3","html_url":"https://github.com/mantas-kemesius/RubyApp/pull/42","diff_url":"https://github.com/mantas-kemesius/RubyApp/pull/42.diff","patch_url":"https://github.com/mantas-kemesius/RubyApp/pull/42.patch","issue_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/issues/42","number":42,"state":"open","locked":false,"title":"Ar email user login","user":{"login":"TomasMacikas","id":43248775,"node_id":"MDQ6VXNlcjQzMjQ4Nzc1","avatar_url":"https://avatars0.githubusercontent.com/u/43248775?v=4","gravatar_id":"","url":"https://api.github.com/users/TomasMacikas","html_url":"https://github.com/TomasMacikas","followers_url":"https://api.github.com/users/TomasMacikas/followers","following_url":"https://api.github.com/users/TomasMacikas/following{/other_user}","gists_url":"https://api.github.com/users/TomasMacikas/gists{/gist_id}","starred_url":"https://api.github.com/users/TomasMacikas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TomasMacikas/subscriptions","organizations_url":"https://api.github.com/users/TomasMacikas/orgs","repos_url":"https://api.github.com/users/TomasMacikas/repos","events_url":"https://api.github.com/users/TomasMacikas/events{/privacy}","received_events_url":"https://api.github.com/users/TomasMacikas/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-11-17T15:05:40Z","updated_at":"2018-11-17T15:32:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7282d056240460afdd868561f56efdcb5a8c441c","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/pulls/42/commits","review_comments_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/pulls/42/comments","review_comment_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/issues/42/comments","statuses_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/statuses/5210a3c8e49a150101a66a1eb4cba8c87bd2ab48","head":{"label":"mantas-kemesius:AR-email_user_login","ref":"AR-email_user_login","sha":"5210a3c8e49a150101a66a1eb4cba8c87bd2ab48","user":{"login":"mantas-kemesius","id":22642187,"node_id":"MDQ6VXNlcjIyNjQyMTg3","avatar_url":"https://avatars1.githubusercontent.com/u/22642187?v=4","gravatar_id":"","url":"https://api.github.com/users/mantas-kemesius","html_url":"https://github.com/mantas-kemesius","followers_url":"https://api.github.com/users/mantas-kemesius/followers","following_url":"https://api.github.com/users/mantas-kemesius/following{/other_user}","gists_url":"https://api.github.com/users/mantas-kemesius/gists{/gist_id}","starred_url":"https://api.github.com/users/mantas-kemesius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mantas-kemesius/subscriptions","organizations_url":"https://api.github.com/users/mantas-kemesius/orgs","repos_url":"https://api.github.com/users/mantas-kemesius/repos","events_url":"https://api.github.com/users/mantas-kemesius/events{/privacy}","received_events_url":"https://api.github.com/users/mantas-kemesius/received_events","type":"User","site_admin":false},"repo":{"id":149487289,"node_id":"MDEwOlJlcG9zaXRvcnkxNDk0ODcyODk=","name":"RubyApp","full_name":"mantas-kemesius/RubyApp","private":false,"owner":{"login":"mantas-kemesius","id":22642187,"node_id":"MDQ6VXNlcjIyNjQyMTg3","avatar_url":"https://avatars1.githubusercontent.com/u/22642187?v=4","gravatar_id":"","url":"https://api.github.com/users/mantas-kemesius","html_url":"https://github.com/mantas-kemesius","followers_url":"https://api.github.com/users/mantas-kemesius/followers","following_url":"https://api.github.com/users/mantas-kemesius/following{/other_user}","gists_url":"https://api.github.com/users/mantas-kemesius/gists{/gist_id}","starred_url":"https://api.github.com/users/mantas-kemesius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mantas-kemesius/subscriptions","organizations_url":"https://api.github.com/users/mantas-kemesius/orgs","repos_url":"https://api.github.com/users/mantas-kemesius/repos","events_url":"https://api.github.com/users/mantas-kemesius/events{/privacy}","received_events_url":"https://api.github.com/users/mantas-kemesius/received_events","type":"User","site_admin":false},"html_url":"https://github.com/mantas-kemesius/RubyApp","description":null,"fork":false,"url":"https://api.github.com/repos/mantas-kemesius/RubyApp","forks_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/forks","keys_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/teams","hooks_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/hooks","issue_events_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/issues/events{/number}","events_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/events","assignees_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/assignees{/user}","branches_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/branches{/branch}","tags_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/tags","blobs_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/git/refs{/sha}","trees_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/statuses/{sha}","languages_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/languages","stargazers_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/stargazers","contributors_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/contributors","subscribers_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/subscribers","subscription_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/subscription","commits_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/commits{/sha}","git_commits_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/git/commits{/sha}","comments_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/comments{/number}","issue_comment_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/issues/comments{/number}","contents_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/contents/{+path}","compare_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/merges","archive_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/downloads","issues_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/issues{/number}","pulls_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/pulls{/number}","milestones_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/milestones{/number}","notifications_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/labels{/name}","releases_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/releases{/id}","deployments_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/deployments","created_at":"2018-09-19T17:26:36Z","updated_at":"2018-11-13T15:43:44Z","pushed_at":"2018-11-17T15:20:31Z","git_url":"git://github.com/mantas-kemesius/RubyApp.git","ssh_url":"git@github.com:mantas-kemesius/RubyApp.git","clone_url":"https://github.com/mantas-kemesius/RubyApp.git","svn_url":"https://github.com/mantas-kemesius/RubyApp","homepage":null,"size":562,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":3,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"mantas-kemesius:master","ref":"master","sha":"8291e37d766099863cf7c681d0b8046511bae22b","user":{"login":"mantas-kemesius","id":22642187,"node_id":"MDQ6VXNlcjIyNjQyMTg3","avatar_url":"https://avatars1.githubusercontent.com/u/22642187?v=4","gravatar_id":"","url":"https://api.github.com/users/mantas-kemesius","html_url":"https://github.com/mantas-kemesius","followers_url":"https://api.github.com/users/mantas-kemesius/followers","following_url":"https://api.github.com/users/mantas-kemesius/following{/other_user}","gists_url":"https://api.github.com/users/mantas-kemesius/gists{/gist_id}","starred_url":"https://api.github.com/users/mantas-kemesius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mantas-kemesius/subscriptions","organizations_url":"https://api.github.com/users/mantas-kemesius/orgs","repos_url":"https://api.github.com/users/mantas-kemesius/repos","events_url":"https://api.github.com/users/mantas-kemesius/events{/privacy}","received_events_url":"https://api.github.com/users/mantas-kemesius/received_events","type":"User","site_admin":false},"repo":{"id":149487289,"node_id":"MDEwOlJlcG9zaXRvcnkxNDk0ODcyODk=","name":"RubyApp","full_name":"mantas-kemesius/RubyApp","private":false,"owner":{"login":"mantas-kemesius","id":22642187,"node_id":"MDQ6VXNlcjIyNjQyMTg3","avatar_url":"https://avatars1.githubusercontent.com/u/22642187?v=4","gravatar_id":"","url":"https://api.github.com/users/mantas-kemesius","html_url":"https://github.com/mantas-kemesius","followers_url":"https://api.github.com/users/mantas-kemesius/followers","following_url":"https://api.github.com/users/mantas-kemesius/following{/other_user}","gists_url":"https://api.github.com/users/mantas-kemesius/gists{/gist_id}","starred_url":"https://api.github.com/users/mantas-kemesius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mantas-kemesius/subscriptions","organizations_url":"https://api.github.com/users/mantas-kemesius/orgs","repos_url":"https://api.github.com/users/mantas-kemesius/repos","events_url":"https://api.github.com/users/mantas-kemesius/events{/privacy}","received_events_url":"https://api.github.com/users/mantas-kemesius/received_events","type":"User","site_admin":false},"html_url":"https://github.com/mantas-kemesius/RubyApp","description":null,"fork":false,"url":"https://api.github.com/repos/mantas-kemesius/RubyApp","forks_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/forks","keys_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/teams","hooks_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/hooks","issue_events_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/issues/events{/number}","events_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/events","assignees_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/assignees{/user}","branches_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/branches{/branch}","tags_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/tags","blobs_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/git/refs{/sha}","trees_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/statuses/{sha}","languages_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/languages","stargazers_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/stargazers","contributors_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/contributors","subscribers_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/subscribers","subscription_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/subscription","commits_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/commits{/sha}","git_commits_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/git/commits{/sha}","comments_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/comments{/number}","issue_comment_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/issues/comments{/number}","contents_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/contents/{+path}","compare_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/merges","archive_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/downloads","issues_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/issues{/number}","pulls_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/pulls{/number}","milestones_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/milestones{/number}","notifications_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/labels{/name}","releases_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/releases{/id}","deployments_url":"https://api.github.com/repos/mantas-kemesius/RubyApp/deployments","created_at":"2018-09-19T17:26:36Z","updated_at":"2018-11-13T15:43:44Z","pushed_at":"2018-11-17T15:20:31Z","git_url":"git://github.com/mantas-kemesius/RubyApp.git","ssh_url":"git@github.com:mantas-kemesius/RubyApp.git","clone_url":"https://github.com/mantas-kemesius/RubyApp.git","svn_url":"https://github.com/mantas-kemesius/RubyApp","homepage":null,"size":562,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":3,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mantas-kemesius/RubyApp/pulls/42"},"html":{"href":"https://github.com/mantas-kemesius/RubyApp/pull/42"},"issue":{"href":"https://api.github.com/repos/mantas-kemesius/RubyApp/issues/42"},"comments":{"href":"https://api.github.com/repos/mantas-kemesius/RubyApp/issues/42/comments"},"review_comments":{"href":"https://api.github.com/repos/mantas-kemesius/RubyApp/pulls/42/comments"},"review_comment":{"href":"https://api.github.com/repos/mantas-kemesius/RubyApp/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mantas-kemesius/RubyApp/pulls/42/commits"},"statuses":{"href":"https://api.github.com/repos/mantas-kemesius/RubyApp/statuses/5210a3c8e49a150101a66a1eb4cba8c87bd2ab48"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"TomasMacikas"}}