Skip to content

Commit

Permalink
Merge pull request #123 from TelePigeon/chore/122
Browse files Browse the repository at this point in the history
[chore] 시연 영상 및 공모전 위한 로깅 추가
  • Loading branch information
minwoo0419 authored Aug 26, 2024
2 parents 17ed7ce + 06a6b01 commit b6324e2
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/main/java/com/telepigeon/server/domain/Worry.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public static Worry create(

public FcmMessageDto toFcmMessageDto() {
return FcmMessageDto.builder()
.receiverName(this.profile.getUser().getName())
.title(this.name)
.body(this.content)
.type("worry")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@

@Builder
public record FcmMessageDto(
String senderName,
String receiverName,
String title,
String body,
String clickAction,
String type,
Long id
){
public static FcmMessageDto of(FcmContent fcmContent, Long id){
public static FcmMessageDto of(String senderName, String receiverName, FcmContent fcmContent, Long id){
return FcmMessageDto.builder()
.senderName(senderName)
.receiverName(receiverName)
.title(fcmContent.getTitle())
.body(fcmContent.getBody())
.clickAction(fcmContent.getBody())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.telepigeon.server.service.question.QuestionRetriever;
import com.telepigeon.server.service.room.RoomRetriever;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.util.Pair;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
Expand All @@ -36,6 +37,7 @@

import static java.time.temporal.ChronoUnit.DAYS;

@Slf4j
@Service
@RequiredArgsConstructor
public class AnswerService {
Expand Down Expand Up @@ -80,7 +82,7 @@ public Answer create(
question,
profile)
);

Double preEmotion = profile.getEmotion();
profile.updateEmotion(
CalculateEmotion(
profile.getEmotion(),
Expand All @@ -91,6 +93,8 @@ public Answer create(
fcmService.send(
receiver.getUser().getFcmToken(),
FcmMessageDto.of(
null,
user.getName(),
FcmContent.EMOTION,
roomId
)
Expand All @@ -101,10 +105,13 @@ public Answer create(
fcmService.send(
receiver.getUser().getFcmToken(),
FcmMessageDto.of(
user.getName(),
receiver.getUser().getName(),
FcmContent.ANSWER,
roomId
)
);
log.info("답장 생성 완료.\n내용 : {}\n감정 점수 : {}\n이전 평균 감정 점수 : {}\n현재 평균 감정 점수 : {}", answer.getContent(), answer.getEmotion(), preEmotion, profile.getEmotion());
return answer;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public void send(
Message message = createMessage(fcmToken, fcmMessageDto);
try{
FirebaseMessaging.getInstance().send(message);
log.info("{} 사용자 -> {} 사용자 푸시 알림 성공.\n알림 유형 : {}\n내용 : {}", fcmMessageDto.senderName(), fcmMessageDto.receiverName(), fcmMessageDto.type(), fcmMessageDto.body());
} catch (FirebaseMessagingException e){
log.error("Failed to send message. fcm Token : {}", fcmToken);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public void create(
fcmService.send(
receiver.getUser().getFcmToken(),
FcmMessageDto.of(
user.getName(),
receiver.getUser().getName(),
FcmContent.HURRY,
roomId
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ public Question create(final Profile profile){
fcmService.send(
receiver.getUser().getFcmToken(),
FcmMessageDto.of(
profile.getUser().getName(),
receiver.getUser().getName(),
FcmContent.QUESTION,
profile.getRoom().getId()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ public Profile enterRoom(final RoomEnterDto roomEnterDto, final Long userId) {
fcmService.send(
receiver.getUser().getFcmToken(),
FcmMessageDto.of(
profile.getUser().getName(),
receiver.getUser().getName(),
FcmContent.ROOM_ENTER,
room.getId()
)
Expand All @@ -169,6 +171,8 @@ public void deleteRoom(final Long roomId, final Long userId) {
fcmService.send(
opponentProfile.getUser().getFcmToken(),
FcmMessageDto.of(
profile.getUser().getName(),
opponentProfile.getUser().getName(),
FcmContent.ROOM_LEAVE,
room.getId()
)
Expand Down Expand Up @@ -204,6 +208,8 @@ private void sendQuestionFirst(Profile profile, Profile receiver){
fcmService.send(
receiver.getUser().getFcmToken(),
FcmMessageDto.of(
profile.getUser().getName(),
receiver.getUser().getName(),
FcmContent.QUESTION,
profile.getRoom().getId()
)
Expand Down

0 comments on commit b6324e2

Please sign in to comment.