From ef7bddc8cdd9a8a80ea051a5337b14925a2af04a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A7=84=EC=A3=BC=EC=9B=90?= <84346055+jinjoo-lab@users.noreply.github.com> Date: Sat, 23 Dec 2023 16:46:29 +0900 Subject: [PATCH] [FEAT] FcmService Logic --- .../backend/domain/group/service/GroupService.java | 10 +++++++++- .../domain/notification/service/FcmService.java | 10 +++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/backend/src/main/java/com/twtw/backend/domain/group/service/GroupService.java b/backend/src/main/java/com/twtw/backend/domain/group/service/GroupService.java index c96f7bcd..50262da6 100644 --- a/backend/src/main/java/com/twtw/backend/domain/group/service/GroupService.java +++ b/backend/src/main/java/com/twtw/backend/domain/group/service/GroupService.java @@ -16,6 +16,7 @@ import com.twtw.backend.domain.member.entity.Member; import com.twtw.backend.domain.member.service.AuthService; import com.twtw.backend.domain.member.service.MemberService; +import com.twtw.backend.domain.notification.service.FcmService; import com.twtw.backend.global.exception.EntityNotFoundException; import org.springframework.stereotype.Service; @@ -34,17 +35,22 @@ public class GroupService { private final MemberService memberService; private final GroupMapper groupMapper; + private final FcmService fcmService; + + public GroupService( GroupRepository groupRepository, GroupMemberRepository groupMemberRepository, AuthService authService, MemberService memberService, - GroupMapper groupMapper) { + GroupMapper groupMapper, + FcmService fcmService) { this.groupRepository = groupRepository; this.groupMemberRepository = groupMemberRepository; this.authService = authService; this.memberService = memberService; this.groupMapper = groupMapper; + this.fcmService = fcmService; } public GroupInfoResponse getGroupById(UUID groupId) { @@ -116,6 +122,8 @@ public GroupInfoResponse inviteGroup(InviteGroupRequest inviteGroupRequest) { memberService.getMembersByIds(inviteGroupRequest.getFriendMemberIds()); group.inviteAll(friends); + // invite push Alert + return groupMapper.toGroupInfo(group); } diff --git a/backend/src/main/java/com/twtw/backend/domain/notification/service/FcmService.java b/backend/src/main/java/com/twtw/backend/domain/notification/service/FcmService.java index 5cfccae5..6a5d6e52 100644 --- a/backend/src/main/java/com/twtw/backend/domain/notification/service/FcmService.java +++ b/backend/src/main/java/com/twtw/backend/domain/notification/service/FcmService.java @@ -4,17 +4,17 @@ import com.google.firebase.messaging.FirebaseMessagingException; import com.google.firebase.messaging.Message; import com.twtw.backend.domain.notification.dto.NotificationRequest; -import lombok.RequiredArgsConstructor; -import org.springframework.beans.factory.annotation.Autowired; + import org.springframework.stereotype.Service; @Service -@RequiredArgsConstructor public class FcmService { - - @Autowired private final FirebaseMessaging firebaseMessaging; + public FcmService(FirebaseMessaging firebaseMessaging){ + this.firebaseMessaging = firebaseMessaging; + } + public void sendNotification(NotificationRequest request) throws FirebaseMessagingException { Message message = Message.builder() .setToken(request.getDeviceToken())