Skip to content

Commit

Permalink
fix: 메일 제목 형식 설정 #3
Browse files Browse the repository at this point in the history
  • Loading branch information
623nana committed Aug 24, 2021
1 parent 25eb148 commit 354ee1b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/main/java/com/nexters/covid/base/Constant.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
public class Constant {

public static final Long COMMON_SEND_OPTION_ID = 6L;
public static final String LETTER_TITLE_FORMAT = "안녕 나야\uD83D\uDC4B, yyyy년 MM월 dd일에 내가 보낸 편지 한번 읽어 볼래?";
}
13 changes: 11 additions & 2 deletions src/main/java/com/nexters/covid/letter/service/MailService.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package com.nexters.covid.letter.service;

import com.nexters.covid.base.Constant;
import com.nexters.covid.letter.domain.Letter;
import com.nexters.covid.letter.domain.LetterRepository;
import com.nexters.covid.letter.domain.State;
import java.io.UnsupportedEncodingException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
Expand Down Expand Up @@ -39,13 +42,19 @@ public void sendLetters(Long sendOptionId) throws MessagingException, Unsupporte
sb.append(letter.decodeContents());
sb.append("</div></span></body></html>");

msgHelper.setFrom(letter.getEmail(), "nana");
msgHelper.setFrom(letter.getEmail(), "안녕, 나야");
msgHelper.setTo(letter.getLetterTo());
msgHelper.setSubject(letter.getTitle());
msgHelper.setSubject(generateLetterTitle(letter.getCreatedDate()));
msgHelper.setText(sb.toString(), true);

javaMailSender.send(msg);
letterRepository.updateLetterState(letter.getEncryptedId());
}
}

private String generateLetterTitle(LocalDateTime createdDate) {
String letterTitle = createdDate.format(DateTimeFormatter.ofPattern(
Constant.LETTER_TITLE_FORMAT));
return letterTitle;
}
}

0 comments on commit 354ee1b

Please sign in to comment.