Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 커피챗 메일 발송 가능하도록 수정 #570

Merged
merged 1 commit into from
Dec 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.sopt.makers.internal.external;

import lombok.RequiredArgsConstructor;

import org.sopt.makers.internal.external.email.EmailChatSender;
import org.sopt.makers.internal.external.gabia.SmsChatSender;
import org.sopt.makers.internal.member.domain.coffeechat.ChatCategory;
import org.springframework.stereotype.Service;

@Service
Expand All @@ -13,10 +13,13 @@ public class MessageSenderFactory {
private final SmsChatSender smsChatSender;
private final EmailChatSender emailChatSender;

public MessageSender getSender(ChatCategory category) {
return switch (category) {
case COFFEE_CHAT -> smsChatSender;
case FRIENDSHIP, APPJAM_TEAM_BUILD, PROJECT_PROPOSAL, OTHER -> emailChatSender;
};
public MessageSender getSender(String senderEmail, String senderPhone) {
if (senderEmail != null) {
return emailChatSender;
}
if (senderPhone != null) {
return smsChatSender;
}
return null;
Comment on lines +16 to +23
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

들여쓰기가 8칸 같은데 4칸으로 맞춰주시면 좋을 것 같습니다!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1탭 = 4칸으로 설정되어 있습니다!

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;

import org.sopt.makers.internal.exception.ClientBadRequestException;
import org.sopt.makers.internal.member.domain.coffeechat.ChatCategory;

import javax.validation.constraints.NotBlank;
Expand All @@ -28,4 +30,13 @@ public record CoffeeChatRequest(
@NotBlank(message = "수신 본문은 필수 입력 값입니다.")
@Size(max = 500, message = "본문은 500자를 초과할 수 없습니다.")
String content
) {}
) {
public CoffeeChatRequest {
if (senderEmail == null && senderPhone == null) {
throw new ClientBadRequestException("발신자 이메일 또는 전화번호 중 하나는 필수 입력 값입니다.");
}
if (senderEmail != null && senderPhone != null) {
throw new ClientBadRequestException("발신자 이메일과 전화번호는 모두 요청이 불가능합니다.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void sendCoffeeChatRequest (CoffeeChatRequest request, Long senderId) {

String replyInfo = getReplyInfo(request, sender);

MessageSender senderStrategy = messageSenderFactory.getSender(request.category());
MessageSender senderStrategy = messageSenderFactory.getSender(request.senderEmail(), request.senderPhone());
senderStrategy.sendMessage(sender, receiver, request.content(), replyInfo, request.category());

createHistoryByCategory(request, sender, receiver);
Expand Down
Loading