{"action":"created","comment":{"url":"https://api.github.com/repos/hhru/AdaptationProject/pulls/comments/174880956","pull_request_review_id":104316380,"id":174880956,"diff_hunk":"@@ -0,0 +1,72 @@\n+package ru.hh.school.services;\n+\n+import java.util.Map;\n+import java.util.Properties;\n+import java.util.concurrent.Callable;\n+import java.util.concurrent.CompletableFuture;\n+import java.util.concurrent.ExecutorService;\n+import java.util.concurrent.Executors;\n+import java.util.concurrent.Future;\n+\n+import javax.inject.Singleton;\n+import javax.mail.Message;\n+import javax.mail.MessagingException;\n+import javax.mail.Session;\n+import javax.mail.Transport;\n+import javax.mail.internet.InternetAddress;\n+import javax.mail.internet.MimeMessage;\n+\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+\n+@Singleton\n+public class MailService {\n+  private Session session;\n+  private ExecutorService threadService = Executors.newFixedThreadPool(1);\n+  private static final Logger logger = LoggerFactory.getLogger(MailService.class);\n+\n+  public MailService(){\n+    Properties properties = new Properties();\n+    properties.put(\"mail.smtp.host\", \"127.0.0.1\");\n+    properties.put(\"mail.smtp.port\", \"25\");\n+    properties.put(\"mail.smtp.auth\", \"false\");\n+    properties.put(\"mail.smtp.starttls.enable\", \"true\");\n+    \n+    session = Session.getInstance(properties);\n+  }\n+\n+  public Future<Integer> sendMail(String userEmail, String messageHtml) {\n+    return sendMail(userEmail, messageHtml, \"notificator <hhschool@pl9lar.fvds.ru>\");\n+  }\n+\n+  public Future<Integer> sendMail(String userEmail, String messageHtml, String nameFrom) {\n+    if (messageHtml == null) {return CompletableFuture.completedFuture(1);}\n+\n+    Callable<Integer> task = () -> {\n+      try {\n+        Message message = new MimeMessage(session);\n+        message.setFrom(new InternetAddress(nameFrom));\n+        message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(userEmail));\n+        message.setSubject(\"Testing HtmlParse\");\n+        message.setContent(messageHtml, \"text/html; charset=utf-8\");\n+\n+        Transport.send(message);\n+        logger.info(\"Email for {} has been send\", userEmail);\n+        return 0;","path":"backend/src/main/java/ru/hh/school/services/MailService.java","position":55,"original_position":55,"commit_id":"5a6312e949192b2f26e79a3aff29a7089be1d398","original_commit_id":"5a6312e949192b2f26e79a3aff29a7089be1d398","user":{"login":"TrympyrymHH","id":29428668,"avatar_url":"https://avatars1.githubusercontent.com/u/29428668?v=4","gravatar_id":"","url":"https://api.github.com/users/TrympyrymHH","html_url":"https://github.com/TrympyrymHH","followers_url":"https://api.github.com/users/TrympyrymHH/followers","following_url":"https://api.github.com/users/TrympyrymHH/following{/other_user}","gists_url":"https://api.github.com/users/TrympyrymHH/gists{/gist_id}","starred_url":"https://api.github.com/users/TrympyrymHH/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TrympyrymHH/subscriptions","organizations_url":"https://api.github.com/users/TrympyrymHH/orgs","repos_url":"https://api.github.com/users/TrympyrymHH/repos","events_url":"https://api.github.com/users/TrympyrymHH/events{/privacy}","received_events_url":"https://api.github.com/users/TrympyrymHH/received_events","type":"User","site_admin":false},"body":"не надо тут С-style. если что-то не так, бросай эксепшн. Если все нормально, пусть таска завершится. И, соответственно, можно сделать Runnable и не возвращать фьючеров. Результат этой фьючи особо не нужен.","created_at":"2018-03-15T18:12:37Z","updated_at":"2018-03-15T18:22:33Z","html_url":"https://github.com/hhru/AdaptationProject/pull/3#discussion_r174880956","pull_request_url":"https://api.github.com/repos/hhru/AdaptationProject/pulls/3","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/hhru/AdaptationProject/pulls/comments/174880956"},"html":{"href":"https://github.com/hhru/AdaptationProject/pull/3#discussion_r174880956"},"pull_request":{"href":"https://api.github.com/repos/hhru/AdaptationProject/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/hhru/AdaptationProject/pulls/3","id":174600889,"html_url":"https://github.com/hhru/AdaptationProject/pull/3","diff_url":"https://github.com/hhru/AdaptationProject/pull/3.diff","patch_url":"https://github.com/hhru/AdaptationProject/pull/3.patch","issue_url":"https://api.github.com/repos/hhru/AdaptationProject/issues/3","number":3,"state":"open","locked":false,"title":"Task-1 создание сервиса для отправки писем.","user":{"login":"derp300","id":6688032,"avatar_url":"https://avatars0.githubusercontent.com/u/6688032?v=4","gravatar_id":"","url":"https://api.github.com/users/derp300","html_url":"https://github.com/derp300","followers_url":"https://api.github.com/users/derp300/followers","following_url":"https://api.github.com/users/derp300/following{/other_user}","gists_url":"https://api.github.com/users/derp300/gists{/gist_id}","starred_url":"https://api.github.com/users/derp300/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/derp300/subscriptions","organizations_url":"https://api.github.com/users/derp300/orgs","repos_url":"https://api.github.com/users/derp300/repos","events_url":"https://api.github.com/users/derp300/events{/privacy}","received_events_url":"https://api.github.com/users/derp300/received_events","type":"User","site_admin":false},"body":"Добавлен почтовый сервис, работающий через постфикс на pl9lar.fvds. Пример отправки пиьсма в exampleResource.","created_at":"2018-03-13T09:31:00Z","updated_at":"2018-03-15T18:22:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4f00aa14e09bcee1dab4da61e4eb3c8297b03edd","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/hhru/AdaptationProject/pulls/3/commits","review_comments_url":"https://api.github.com/repos/hhru/AdaptationProject/pulls/3/comments","review_comment_url":"https://api.github.com/repos/hhru/AdaptationProject/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hhru/AdaptationProject/issues/3/comments","statuses_url":"https://api.github.com/repos/hhru/AdaptationProject/statuses/5a6312e949192b2f26e79a3aff29a7089be1d398","head":{"label":"hhru:TASK-1","ref":"TASK-1","sha":"5a6312e949192b2f26e79a3aff29a7089be1d398","user":{"login":"hhru","id":152753,"avatar_url":"https://avatars2.githubusercontent.com/u/152753?v=4","gravatar_id":"","url":"https://api.github.com/users/hhru","html_url":"https://github.com/hhru","followers_url":"https://api.github.com/users/hhru/followers","following_url":"https://api.github.com/users/hhru/following{/other_user}","gists_url":"https://api.github.com/users/hhru/gists{/gist_id}","starred_url":"https://api.github.com/users/hhru/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hhru/subscriptions","organizations_url":"https://api.github.com/users/hhru/orgs","repos_url":"https://api.github.com/users/hhru/repos","events_url":"https://api.github.com/users/hhru/events{/privacy}","received_events_url":"https://api.github.com/users/hhru/received_events","type":"Organization","site_admin":false},"repo":{"id":123563357,"name":"AdaptationProject","full_name":"hhru/AdaptationProject","owner":{"login":"hhru","id":152753,"avatar_url":"https://avatars2.githubusercontent.com/u/152753?v=4","gravatar_id":"","url":"https://api.github.com/users/hhru","html_url":"https://github.com/hhru","followers_url":"https://api.github.com/users/hhru/followers","following_url":"https://api.github.com/users/hhru/following{/other_user}","gists_url":"https://api.github.com/users/hhru/gists{/gist_id}","starred_url":"https://api.github.com/users/hhru/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hhru/subscriptions","organizations_url":"https://api.github.com/users/hhru/orgs","repos_url":"https://api.github.com/users/hhru/repos","events_url":"https://api.github.com/users/hhru/events{/privacy}","received_events_url":"https://api.github.com/users/hhru/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hhru/AdaptationProject","description":null,"fork":false,"url":"https://api.github.com/repos/hhru/AdaptationProject","forks_url":"https://api.github.com/repos/hhru/AdaptationProject/forks","keys_url":"https://api.github.com/repos/hhru/AdaptationProject/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hhru/AdaptationProject/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hhru/AdaptationProject/teams","hooks_url":"https://api.github.com/repos/hhru/AdaptationProject/hooks","issue_events_url":"https://api.github.com/repos/hhru/AdaptationProject/issues/events{/number}","events_url":"https://api.github.com/repos/hhru/AdaptationProject/events","assignees_url":"https://api.github.com/repos/hhru/AdaptationProject/assignees{/user}","branches_url":"https://api.github.com/repos/hhru/AdaptationProject/branches{/branch}","tags_url":"https://api.github.com/repos/hhru/AdaptationProject/tags","blobs_url":"https://api.github.com/repos/hhru/AdaptationProject/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hhru/AdaptationProject/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hhru/AdaptationProject/git/refs{/sha}","trees_url":"https://api.github.com/repos/hhru/AdaptationProject/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hhru/AdaptationProject/statuses/{sha}","languages_url":"https://api.github.com/repos/hhru/AdaptationProject/languages","stargazers_url":"https://api.github.com/repos/hhru/AdaptationProject/stargazers","contributors_url":"https://api.github.com/repos/hhru/AdaptationProject/contributors","subscribers_url":"https://api.github.com/repos/hhru/AdaptationProject/subscribers","subscription_url":"https://api.github.com/repos/hhru/AdaptationProject/subscription","commits_url":"https://api.github.com/repos/hhru/AdaptationProject/commits{/sha}","git_commits_url":"https://api.github.com/repos/hhru/AdaptationProject/git/commits{/sha}","comments_url":"https://api.github.com/repos/hhru/AdaptationProject/comments{/number}","issue_comment_url":"https://api.github.com/repos/hhru/AdaptationProject/issues/comments{/number}","contents_url":"https://api.github.com/repos/hhru/AdaptationProject/contents/{+path}","compare_url":"https://api.github.com/repos/hhru/AdaptationProject/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hhru/AdaptationProject/merges","archive_url":"https://api.github.com/repos/hhru/AdaptationProject/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hhru/AdaptationProject/downloads","issues_url":"https://api.github.com/repos/hhru/AdaptationProject/issues{/number}","pulls_url":"https://api.github.com/repos/hhru/AdaptationProject/pulls{/number}","milestones_url":"https://api.github.com/repos/hhru/AdaptationProject/milestones{/number}","notifications_url":"https://api.github.com/repos/hhru/AdaptationProject/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hhru/AdaptationProject/labels{/name}","releases_url":"https://api.github.com/repos/hhru/AdaptationProject/releases{/id}","deployments_url":"https://api.github.com/repos/hhru/AdaptationProject/deployments","created_at":"2018-03-02T10:04:27Z","updated_at":"2018-03-13T09:53:59Z","pushed_at":"2018-03-15T13:35:44Z","git_url":"git://github.com/hhru/AdaptationProject.git","ssh_url":"git@github.com:hhru/AdaptationProject.git","clone_url":"https://github.com/hhru/AdaptationProject.git","svn_url":"https://github.com/hhru/AdaptationProject","homepage":null,"size":59,"stargazers_count":0,"watchers_count":0,"language":"Java","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":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"hhru:master","ref":"master","sha":"e2c367133e018a7eb852875e88a8966a08569b32","user":{"login":"hhru","id":152753,"avatar_url":"https://avatars2.githubusercontent.com/u/152753?v=4","gravatar_id":"","url":"https://api.github.com/users/hhru","html_url":"https://github.com/hhru","followers_url":"https://api.github.com/users/hhru/followers","following_url":"https://api.github.com/users/hhru/following{/other_user}","gists_url":"https://api.github.com/users/hhru/gists{/gist_id}","starred_url":"https://api.github.com/users/hhru/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hhru/subscriptions","organizations_url":"https://api.github.com/users/hhru/orgs","repos_url":"https://api.github.com/users/hhru/repos","events_url":"https://api.github.com/users/hhru/events{/privacy}","received_events_url":"https://api.github.com/users/hhru/received_events","type":"Organization","site_admin":false},"repo":{"id":123563357,"name":"AdaptationProject","full_name":"hhru/AdaptationProject","owner":{"login":"hhru","id":152753,"avatar_url":"https://avatars2.githubusercontent.com/u/152753?v=4","gravatar_id":"","url":"https://api.github.com/users/hhru","html_url":"https://github.com/hhru","followers_url":"https://api.github.com/users/hhru/followers","following_url":"https://api.github.com/users/hhru/following{/other_user}","gists_url":"https://api.github.com/users/hhru/gists{/gist_id}","starred_url":"https://api.github.com/users/hhru/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hhru/subscriptions","organizations_url":"https://api.github.com/users/hhru/orgs","repos_url":"https://api.github.com/users/hhru/repos","events_url":"https://api.github.com/users/hhru/events{/privacy}","received_events_url":"https://api.github.com/users/hhru/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hhru/AdaptationProject","description":null,"fork":false,"url":"https://api.github.com/repos/hhru/AdaptationProject","forks_url":"https://api.github.com/repos/hhru/AdaptationProject/forks","keys_url":"https://api.github.com/repos/hhru/AdaptationProject/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hhru/AdaptationProject/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hhru/AdaptationProject/teams","hooks_url":"https://api.github.com/repos/hhru/AdaptationProject/hooks","issue_events_url":"https://api.github.com/repos/hhru/AdaptationProject/issues/events{/number}","events_url":"https://api.github.com/repos/hhru/AdaptationProject/events","assignees_url":"https://api.github.com/repos/hhru/AdaptationProject/assignees{/user}","branches_url":"https://api.github.com/repos/hhru/AdaptationProject/branches{/branch}","tags_url":"https://api.github.com/repos/hhru/AdaptationProject/tags","blobs_url":"https://api.github.com/repos/hhru/AdaptationProject/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hhru/AdaptationProject/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hhru/AdaptationProject/git/refs{/sha}","trees_url":"https://api.github.com/repos/hhru/AdaptationProject/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hhru/AdaptationProject/statuses/{sha}","languages_url":"https://api.github.com/repos/hhru/AdaptationProject/languages","stargazers_url":"https://api.github.com/repos/hhru/AdaptationProject/stargazers","contributors_url":"https://api.github.com/repos/hhru/AdaptationProject/contributors","subscribers_url":"https://api.github.com/repos/hhru/AdaptationProject/subscribers","subscription_url":"https://api.github.com/repos/hhru/AdaptationProject/subscription","commits_url":"https://api.github.com/repos/hhru/AdaptationProject/commits{/sha}","git_commits_url":"https://api.github.com/repos/hhru/AdaptationProject/git/commits{/sha}","comments_url":"https://api.github.com/repos/hhru/AdaptationProject/comments{/number}","issue_comment_url":"https://api.github.com/repos/hhru/AdaptationProject/issues/comments{/number}","contents_url":"https://api.github.com/repos/hhru/AdaptationProject/contents/{+path}","compare_url":"https://api.github.com/repos/hhru/AdaptationProject/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hhru/AdaptationProject/merges","archive_url":"https://api.github.com/repos/hhru/AdaptationProject/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hhru/AdaptationProject/downloads","issues_url":"https://api.github.com/repos/hhru/AdaptationProject/issues{/number}","pulls_url":"https://api.github.com/repos/hhru/AdaptationProject/pulls{/number}","milestones_url":"https://api.github.com/repos/hhru/AdaptationProject/milestones{/number}","notifications_url":"https://api.github.com/repos/hhru/AdaptationProject/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hhru/AdaptationProject/labels{/name}","releases_url":"https://api.github.com/repos/hhru/AdaptationProject/releases{/id}","deployments_url":"https://api.github.com/repos/hhru/AdaptationProject/deployments","created_at":"2018-03-02T10:04:27Z","updated_at":"2018-03-13T09:53:59Z","pushed_at":"2018-03-15T13:35:44Z","git_url":"git://github.com/hhru/AdaptationProject.git","ssh_url":"git@github.com:hhru/AdaptationProject.git","clone_url":"https://github.com/hhru/AdaptationProject.git","svn_url":"https://github.com/hhru/AdaptationProject","homepage":null,"size":59,"stargazers_count":0,"watchers_count":0,"language":"Java","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":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hhru/AdaptationProject/pulls/3"},"html":{"href":"https://github.com/hhru/AdaptationProject/pull/3"},"issue":{"href":"https://api.github.com/repos/hhru/AdaptationProject/issues/3"},"comments":{"href":"https://api.github.com/repos/hhru/AdaptationProject/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/hhru/AdaptationProject/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/hhru/AdaptationProject/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hhru/AdaptationProject/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/hhru/AdaptationProject/statuses/5a6312e949192b2f26e79a3aff29a7089be1d398"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"TrympyrymHH"}}