-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #181 from Team-Capple/develop
[RELEASE] 회원가입 메일 개선, 질문 생성/종료 원격 알림 이관, 기존 원격 알림 형식 변경
- Loading branch information
Showing
23 changed files
with
298 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
src/main/java/com/server/capple/domain/mail/service/MailUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
package com.server.capple.domain.mail.service; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
|
||
public interface MailUtil { | ||
public static Boolean emailAddressFormVerification(String emailAddress) { | ||
String emailRegex = "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,6}$"; | ||
return emailAddress.matches(emailRegex); | ||
} | ||
|
||
String sendMailAddressCertificationMail(String receiver, Boolean isWhiteList); | ||
CompletableFuture<String> sendMailAddressCertificationMail(String receiver, Boolean isWhiteList); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/main/java/com/server/capple/domain/notifiaction/entity/NotificationLog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.server.capple.domain.notifiaction.entity; | ||
|
||
import com.server.capple.global.common.BaseEntity; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import lombok.*; | ||
|
||
@Getter | ||
@Entity | ||
@Builder | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@AllArgsConstructor | ||
public class NotificationLog extends BaseEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
private String subtitle; | ||
private String body; | ||
private Long boardId; | ||
private Long boardCommentId; | ||
private Long questionId; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 79 additions & 12 deletions
91
src/main/java/com/server/capple/domain/notifiaction/mapper/NotificationMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,95 @@ | ||
package com.server.capple.domain.notifiaction.mapper; | ||
|
||
import com.server.capple.config.apns.dto.ApnsClientRequest; | ||
import com.server.capple.domain.board.entity.Board; | ||
import com.server.capple.domain.boardComment.entity.BoardComment; | ||
import com.server.capple.domain.notifiaction.dto.NotificationResponse.NotificationInfo; | ||
import com.server.capple.domain.notifiaction.entity.Notification; | ||
import com.server.capple.domain.notifiaction.entity.NotificationLog; | ||
import com.server.capple.domain.notifiaction.entity.NotificationType; | ||
import com.server.capple.domain.question.entity.Question; | ||
import com.server.capple.global.common.SliceResponse; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.data.domain.Slice; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Slf4j | ||
@Component | ||
public class NotificationMapper { | ||
public Notification toNotification(Long memberId, ApnsClientRequest.BoardNotificationBody boardNotificationBody) { | ||
public Notification toNotification(Long memberId, NotificationLog notificationLog, NotificationType type) { | ||
return Notification.builder() | ||
.memberId(memberId) | ||
.title(boardNotificationBody.getAps().getAlert().getTitle()) | ||
.content(boardNotificationBody.getAps().getAlert().getBody()) | ||
.boardId(boardNotificationBody.getBoardId()) | ||
.notificationLog(notificationLog) | ||
.type(type) | ||
.build(); | ||
} | ||
|
||
public Notification toNotification(Long memberId, ApnsClientRequest.BoardCommentNotificationBody boardCommentNotificationBody) { | ||
public Notification toNotification(NotificationLog notificationLog, NotificationType type) { | ||
return Notification.builder() | ||
.memberId(memberId) | ||
.title(boardCommentNotificationBody.getAps().getAlert().getTitle()) | ||
.subtitle(boardCommentNotificationBody.getAps().getAlert().getSubtitle()) | ||
.content(boardCommentNotificationBody.getAps().getAlert().getBody()) | ||
.boardId(boardCommentNotificationBody.getBoardId()) | ||
.boardCommentId(boardCommentNotificationBody.getBoardCommentId()) | ||
.notificationLog(notificationLog) | ||
.type(type) | ||
.build(); | ||
} | ||
|
||
public NotificationLog toNotificationLog(Board board) { | ||
return NotificationLog.builder() | ||
.body(board.getContent()) | ||
.boardId(board.getId()) | ||
.build(); | ||
} | ||
|
||
public NotificationLog toNotificationLog(Board board, BoardComment boardComment) { | ||
return NotificationLog.builder() | ||
.body(boardComment.getContent()) | ||
.boardId(board.getId()) | ||
.boardCommentId(boardComment.getId()) | ||
.build(); | ||
} | ||
|
||
public NotificationLog toNotificationLog(Question question) { | ||
return NotificationLog.builder() | ||
.body(question.getContent()) | ||
.questionId(question.getId()) | ||
.build(); | ||
} | ||
|
||
public SliceResponse<NotificationInfo> toNotificationInfoSlice(Slice<Notification> notification) { | ||
return SliceResponse.toSliceResponse(notification, notification.stream().map(this::toNotificationInfo).toList()); | ||
} | ||
|
||
private NotificationInfo toNotificationInfo(Notification notification) { | ||
return switch (notification.getType()) { | ||
case BOARD_HEART -> toBoardNotificationInfo(notification); | ||
case BOARD_COMMENT, BOARD_COMMENT_DUPLICATE, BOARD_COMMENT_HEART -> | ||
toBoardCommentNotificationInfo(notification); | ||
case TODAY_QUESTION_PUBLISHED, TODAY_QUESTION_CLOSED -> toQuestionNotificationInfo(notification); | ||
}; | ||
} | ||
|
||
private NotificationInfo toBoardNotificationInfo(Notification notification) { | ||
return NotificationInfo.builder() | ||
.title(notification.getType().getTitle()) | ||
.content(notification.getNotificationLog().getBody()) | ||
.boardId(notification.getNotificationLog().getBoardId().toString()) | ||
.createdAt(notification.getCreatedAt()) | ||
.build(); | ||
} | ||
|
||
private NotificationInfo toBoardCommentNotificationInfo(Notification notification) { | ||
return NotificationInfo.builder() | ||
.title(notification.getType().getTitle()) | ||
.content(notification.getNotificationLog().getBody()) | ||
.boardId(notification.getNotificationLog().getBoardId().toString()) | ||
.boardCommentId(notification.getNotificationLog().getBoardCommentId().toString()) | ||
.createdAt(notification.getCreatedAt()) | ||
.build(); | ||
} | ||
|
||
private NotificationInfo toQuestionNotificationInfo(Notification notification) { | ||
return NotificationInfo.builder() | ||
.title(notification.getType().getTitle()) | ||
.content(notification.getNotificationLog().getBody()) | ||
.questionId(notification.getNotificationLog().getQuestionId().toString()) | ||
.createdAt(notification.getCreatedAt()) | ||
.build(); | ||
} | ||
} |
Oops, something went wrong.