diff --git a/main-server/src/main/java/com/sickgyun/server/mail/MailService.java b/main-server/src/main/java/com/sickgyun/server/mail/MailService.java index 6fe921a..7acd6a7 100644 --- a/main-server/src/main/java/com/sickgyun/server/mail/MailService.java +++ b/main-server/src/main/java/com/sickgyun/server/mail/MailService.java @@ -28,11 +28,9 @@ public void sendMail(CoffeeChat coffeeChat) { MimeMessage message = mailSender.createMimeMessage(); try { - message.addRecipients(TO, coffeeChat.getToUser().getEmail()); - message.setSubject("안녕하세요. 식견입니다."); + setRecipientsAndFrom(coffeeChat, message); + message.setSubject(setSubjectWithCoffeeChat(coffeeChat)); message.setText(setContext(coffeeChat), "utf-8", "html"); - - message.setFrom(coffeeChat.getFromUser().getEmail()); } catch (MessagingException e) { throw new EmailNotExistException(); } @@ -40,6 +38,28 @@ public void sendMail(CoffeeChat coffeeChat) { mailSender.send(message); } + private void setRecipientsAndFrom(CoffeeChat coffeeChat, MimeMessage message) throws MessagingException { + if (coffeeChat.getState().equals(State.PENDING)) { + message.addRecipients(TO, coffeeChat.getToUser().getEmail()); + message.setFrom(coffeeChat.getFromUser().getEmail()); + } else { + message.addRecipients(TO, coffeeChat.getFromUser().getEmail()); + message.setFrom(coffeeChat.getToUser().getEmail()); + } + } + + private String setSubjectWithCoffeeChat(CoffeeChat coffeeChat) { + String fromUserName = coffeeChat.getFromUser().getName(); + String toUserName = coffeeChat.getToUser().getName(); + + if (coffeeChat.getState().equals(State.ACCEPT)) { + return toUserName + "님께서 " + fromUserName + "님의 커피챗 요청을 수락하셨어요."; + } else if (coffeeChat.getState().equals(State.REJECT)) { + return toUserName + "님께서 " + fromUserName + "님의 커피챗 요청을 거절하셨어요...ㅠ"; + } + return fromUserName + "님으로부터 커피챗 요청이 왔어요."; + } + private String setContext(CoffeeChat coffeeChat) { Context context = new Context(); context.setVariable("fromuser", coffeeChat.getFromUser().getName()); diff --git a/main-server/src/main/resources/templates/accept-mail.html b/main-server/src/main/resources/templates/accept-mail.html index f44d448..58e077b 100644 --- a/main-server/src/main/resources/templates/accept-mail.html +++ b/main-server/src/main/resources/templates/accept-mail.html @@ -5,30 +5,33 @@ Send Mail -
-
+
+
-

- 님께서
- 커피챗 요청을 수락하셨습니다. + style="display: block; width: 141px; height: 48px; margin: 0 auto;" alt="Logo"> +

+ 님이 커피챗 요청을 수락했어요.

-
- -
+
- 식견 바로가기 -
-
+ 식견에서 확인하기 +
+ +
\ No newline at end of file diff --git a/main-server/src/main/resources/templates/application-mail.html b/main-server/src/main/resources/templates/application-mail.html index 81ec3db..cea882c 100644 --- a/main-server/src/main/resources/templates/application-mail.html +++ b/main-server/src/main/resources/templates/application-mail.html @@ -5,30 +5,36 @@ Send Mail -
-
+
+
-

- 님으로부터
- 커피챗 요청이 왔습니다. + style="display: block; width: 141px; height: 48px; margin: 0 auto;" alt="Logo"> +

+ 님이 커피챗 요청을 보냈어요.

+
+
+
-
- -
+
- 식견 바로가기 -
-
+ 식견에서 확인하기 +
+ +
\ No newline at end of file diff --git a/main-server/src/main/resources/templates/cancelled-mail.html b/main-server/src/main/resources/templates/cancelled-mail.html deleted file mode 100644 index bc77241..0000000 --- a/main-server/src/main/resources/templates/cancelled-mail.html +++ /dev/null @@ -1,34 +0,0 @@ - - - - - Send Mail - - -
-
- -

- 님께서
- 커피챗 요청을 취소하였습니다. -

-
-
- -
- 식견 바로가기 -
-
- - \ No newline at end of file diff --git a/main-server/src/main/resources/templates/reject-mail.html b/main-server/src/main/resources/templates/reject-mail.html index 9835210..c0a778f 100644 --- a/main-server/src/main/resources/templates/reject-mail.html +++ b/main-server/src/main/resources/templates/reject-mail.html @@ -5,31 +5,36 @@ Send Mail -
-
+
+
-

- 님께서
- ""
- 다음의 이유로 커피챗 요청을 거절하였습니다. + style="display: block; width: 141px; height: 48px; margin: 0 auto;" alt="Logo"> +

+ 님이 커피챗 요청을 거절했어요.

+
+
+
-
- -
+
- 식견 바로가기 -
-
+ 식견에서 확인하기 +
+ +
\ No newline at end of file