Skip to content

Commit

Permalink
refactor: fcmService 의존성 삭제
Browse files Browse the repository at this point in the history
  • Loading branch information
minsu20 committed Dec 4, 2023
1 parent 8dc654d commit 1c16c6a
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
import com.moing.backend.domain.mission.domain.entity.Mission;
import com.moing.backend.domain.team.domain.entity.Team;
import com.moing.backend.domain.teamMember.domain.service.TeamMemberGetService;
import com.moing.backend.global.config.fcm.dto.event.FcmEvent;
import com.moing.backend.global.config.fcm.dto.request.MultiRequest;
import com.moing.backend.global.config.fcm.service.FcmService;
import com.moing.backend.global.response.BaseServiceResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.EventListener;
import java.util.List;
import java.util.Optional;

Expand All @@ -24,20 +27,16 @@
public class SendMissionCreateAlarmUseCase {

private final TeamMemberGetService teamMemberGetService;
private final FcmService fcmService;
private final ApplicationEventPublisher eventPublisher;

public void sendNewMissionUploadAlarm(Member member, Mission mission) {
Team team = mission.getTeam();
Optional<List<String>> fcmTokensExceptMe = teamMemberGetService.getFcmTokensExceptMe(team.getTeamId(), member.getMemberId());

String title = team.getName() + " " + NEW_SINGLE_MISSION_COMING.getTitle();
String message = mission.getTitle();

Optional<List<String>> fcmTokens = teamMemberGetService.getFcmTokensExceptMe(team.getTeamId(), member.getMemberId());
if (fcmTokens.isPresent() && !fcmTokens.get().isEmpty()) {
MultiRequest toMultiRequest = new MultiRequest(fcmTokens.get(), title, message);
fcmService.sendMultipleDevices(toMultiRequest);

eventPublisher.publishEvent(new FcmEvent(title, message, fcmTokens.get()));
}
}
}
Expand Down

0 comments on commit 1c16c6a

Please sign in to comment.