From d2d986b2a07530934a7da1b910af3e5c01f3abce Mon Sep 17 00:00:00 2001 From: shinhn Date: Sat, 22 Apr 2023 13:19:18 +0900 Subject: [PATCH] =?UTF-8?q?#108=20#98=20feat=20:=20Apn=20payloadBuilder=20?= =?UTF-8?q?-=20time,=20isOpen=20=EC=BB=AC=EB=9F=BC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/apns/dto/req/CreateBoardUserJoinAPNReq.java | 6 +----- .../yogit/server/apns/dto/req/CreateClipBoardAPNReq.java | 6 +----- .../yogit/server/apns/dto/req/DelBoardUserJoinAPNReq.java | 6 +----- .../com/yogit/server/apns/service/APNServiceImpl.java | 8 ++++++++ .../board/service/boarduser/BoardUserServiceImpl.java | 4 ++-- .../board/service/clipboard/ClipBoardServiceImpl.java | 2 +- 6 files changed, 14 insertions(+), 18 deletions(-) diff --git a/server/src/main/java/com/yogit/server/apns/dto/req/CreateBoardUserJoinAPNReq.java b/server/src/main/java/com/yogit/server/apns/dto/req/CreateBoardUserJoinAPNReq.java index d701d08..696f066 100644 --- a/server/src/main/java/com/yogit/server/apns/dto/req/CreateBoardUserJoinAPNReq.java +++ b/server/src/main/java/com/yogit/server/apns/dto/req/CreateBoardUserJoinAPNReq.java @@ -17,16 +17,12 @@ public class CreateBoardUserJoinAPNReq { private String joinUserName; private Long boardId; private String boardName; - private String time; - boolean isOpened; @Builder - public CreateBoardUserJoinAPNReq(String destinationDeviceToken, String joinUserName, Long boardId, String boardName, String time) { + public CreateBoardUserJoinAPNReq(String destinationDeviceToken, String joinUserName, Long boardId, String boardName) { this.destinationDeviceToken = destinationDeviceToken; this.joinUserName = joinUserName; this.boardId = boardId; this.boardName = boardName; - this.time = time; - this.isOpened = false; } } diff --git a/server/src/main/java/com/yogit/server/apns/dto/req/CreateClipBoardAPNReq.java b/server/src/main/java/com/yogit/server/apns/dto/req/CreateClipBoardAPNReq.java index 974a9cc..fc179bd 100644 --- a/server/src/main/java/com/yogit/server/apns/dto/req/CreateClipBoardAPNReq.java +++ b/server/src/main/java/com/yogit/server/apns/dto/req/CreateClipBoardAPNReq.java @@ -17,16 +17,12 @@ public class CreateClipBoardAPNReq { private String userName; private Long boardId; private String boardName; - private String time; - boolean isOpened; @Builder - public CreateClipBoardAPNReq(String destinationDeviceToken, String userName, Long boardId, String boardName, String time) { + public CreateClipBoardAPNReq(String destinationDeviceToken, String userName, Long boardId, String boardName) { this.destinationDeviceToken = destinationDeviceToken; this.userName = userName; this.boardId = boardId; this.boardName = boardName; - this.time = time; - this.isOpened = false; } } diff --git a/server/src/main/java/com/yogit/server/apns/dto/req/DelBoardUserJoinAPNReq.java b/server/src/main/java/com/yogit/server/apns/dto/req/DelBoardUserJoinAPNReq.java index 9422e88..6d7ea80 100644 --- a/server/src/main/java/com/yogit/server/apns/dto/req/DelBoardUserJoinAPNReq.java +++ b/server/src/main/java/com/yogit/server/apns/dto/req/DelBoardUserJoinAPNReq.java @@ -17,16 +17,12 @@ public class DelBoardUserJoinAPNReq { private String delUserName; private Long boardId; private String boardName; - private String time; - boolean isOpened; @Builder - public DelBoardUserJoinAPNReq(String destinationDeviceToken, String delUserName, Long boardId, String boardName, String time) { + public DelBoardUserJoinAPNReq(String destinationDeviceToken, String delUserName, Long boardId, String boardName) { this.destinationDeviceToken = destinationDeviceToken; this.delUserName = delUserName; this.boardId = boardId; this.boardName = boardName; - this.time = time; - this.isOpened = false; } } diff --git a/server/src/main/java/com/yogit/server/apns/service/APNServiceImpl.java b/server/src/main/java/com/yogit/server/apns/service/APNServiceImpl.java index 268e255..4510afe 100644 --- a/server/src/main/java/com/yogit/server/apns/service/APNServiceImpl.java +++ b/server/src/main/java/com/yogit/server/apns/service/APNServiceImpl.java @@ -17,6 +17,8 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.concurrent.ExecutionException; @Service @@ -85,6 +87,8 @@ public ApplicationResponse createBoardUserJoinAPN(CreateBoardUserJoinAPN payloadBuilder.addCustomProperty("boardId", dto.getBoardId()); payloadBuilder.addCustomProperty("pushType", PushType.JOINAPPLY.toString()); + payloadBuilder.addCustomProperty("time", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); + payloadBuilder.addCustomProperty("isOpened", false); val payload = payloadBuilder.buildWithDefaultMaximumLength(); val token = TokenUtil.sanitizeTokenString(dto.getDestinationDeviceToken()); @@ -112,6 +116,8 @@ public ApplicationResponse delBoardUserJoinAPN(DelBoardUserJoinAPNReq dt payloadBuilder.addCustomProperty("boardId", dto.getBoardId()); payloadBuilder.addCustomProperty("pushType", PushType.DELAPPLY.toString()); + payloadBuilder.addCustomProperty("time", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); + payloadBuilder.addCustomProperty("isOpened", false); val payload = payloadBuilder.buildWithDefaultMaximumLength(); val token = TokenUtil.sanitizeTokenString(dto.getDestinationDeviceToken()); @@ -139,6 +145,8 @@ public ApplicationResponse createClipBoardAPN(CreateClipBoardAPNReq dto) payloadBuilder.addCustomProperty("boardId", dto.getBoardId()); payloadBuilder.addCustomProperty("pushType", PushType.CREATE_CLIPBOARD.toString()); + payloadBuilder.addCustomProperty("time", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); + payloadBuilder.addCustomProperty("isOpened", false); val payload = payloadBuilder.buildWithDefaultMaximumLength(); val token = TokenUtil.sanitizeTokenString(dto.getDestinationDeviceToken()); diff --git a/server/src/main/java/com/yogit/server/board/service/boarduser/BoardUserServiceImpl.java b/server/src/main/java/com/yogit/server/board/service/boarduser/BoardUserServiceImpl.java index 2d99f28..24a508b 100644 --- a/server/src/main/java/com/yogit/server/board/service/boarduser/BoardUserServiceImpl.java +++ b/server/src/main/java/com/yogit/server/board/service/boarduser/BoardUserServiceImpl.java @@ -86,7 +86,7 @@ public ApplicationResponse joinBoardUser(CreateBoardUserReq dto) { // 호스트에게 멤버 참여 APN 푸쉬 알림 try { - if(user.getUserStatus().equals(UserStatus.LOGIN) && board.getHost().getDeviceToken() != null) apnService.createBoardUserJoinAPN(new CreateBoardUserJoinAPNReq(board.getHost().getDeviceToken(), user.getName(), board.getId(), board.getTitle(), LocalDateTime.now().toString())); + if(user.getUserStatus().equals(UserStatus.LOGIN) && board.getHost().getDeviceToken() != null) apnService.createBoardUserJoinAPN(new CreateBoardUserJoinAPNReq(board.getHost().getDeviceToken(), user.getName(), board.getId(), board.getTitle())); } catch (ExecutionException e) { e.printStackTrace(); } catch (InterruptedException e) { @@ -155,7 +155,7 @@ public ApplicationResponse delBoardUser(CreateBoardUserReq dto){ // 호스트에게 멤버 참여 취소 APN 푸쉬 알림 try { - if(user.getUserStatus().equals(UserStatus.LOGIN) && board.getHost().getDeviceToken() != null) apnService.delBoardUserJoinAPN(new DelBoardUserJoinAPNReq(board.getHost().getDeviceToken(), user.getName(), board.getId(), board.getTitle(), LocalDateTime.now().toString())); + if(user.getUserStatus().equals(UserStatus.LOGIN) && board.getHost().getDeviceToken() != null) apnService.delBoardUserJoinAPN(new DelBoardUserJoinAPNReq(board.getHost().getDeviceToken(), user.getName(), board.getId(), board.getTitle())); } catch (ExecutionException e) { e.printStackTrace(); } catch (InterruptedException e) { diff --git a/server/src/main/java/com/yogit/server/board/service/clipboard/ClipBoardServiceImpl.java b/server/src/main/java/com/yogit/server/board/service/clipboard/ClipBoardServiceImpl.java index 28e51c9..34bb912 100644 --- a/server/src/main/java/com/yogit/server/board/service/clipboard/ClipBoardServiceImpl.java +++ b/server/src/main/java/com/yogit/server/board/service/clipboard/ClipBoardServiceImpl.java @@ -83,7 +83,7 @@ public ApplicationResponse createClipBoard(CreateClipBoardReq dto) if(boardUsers!=null){ for(BoardUser bu: boardUsers){ try { - if(user.getUserStatus().equals(UserStatus.LOGIN) && !user.equals(bu.getUser()) && bu.getUser().getDeviceToken() != null) apnService.createClipBoardAPN(new CreateClipBoardAPNReq(bu.getUser().getDeviceToken(), user.getName(), board.getId(), board.getTitle(), LocalDateTime.now().toString())); + if(user.getUserStatus().equals(UserStatus.LOGIN) && !user.equals(bu.getUser()) && bu.getUser().getDeviceToken() != null) apnService.createClipBoardAPN(new CreateClipBoardAPNReq(bu.getUser().getDeviceToken(), user.getName(), board.getId(), board.getTitle())); } catch (ExecutionException e) { e.printStackTrace(); } catch (InterruptedException e) {