Skip to content

Commit

Permalink
[FEAT] FcmService Logic
Browse files Browse the repository at this point in the history
  • Loading branch information
jinjoo-lab committed Dec 23, 2023
1 parent f211a04 commit ef7bddc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -116,6 +122,8 @@ public GroupInfoResponse inviteGroup(InviteGroupRequest inviteGroupRequest) {
memberService.getMembersByIds(inviteGroupRequest.getFriendMemberIds());
group.inviteAll(friends);

// invite push Alert

return groupMapper.toGroupInfo(group);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit ef7bddc

Please sign in to comment.