Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v.1.0.10 #309

Merged
merged 34 commits into from
Sep 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
1a87c66
fix : 모든 score 값 100 넘지 않도록
seungueonn Apr 17, 2024
6f76768
Merge branch 'main' of https://github.com/Modagbul/MOING_server_release
seungueonn May 6, 2024
67b954f
fix : 미션 인증 시 commentNum 디폴트값 지정
seungueonn May 7, 2024
2a5234e
Merge branch 'main' of https://github.com/Modagbul/MOING_server_release
seungueonn May 9, 2024
70c26c0
Merge branch 'main' of https://github.com/Modagbul/MOING_server_release
seungueonn Jun 4, 2024
99a5927
MNG-25 feat : 불던지기 푸시알림 메시지 추가에 따른 entity 칼럼 추가
seungueonn Jun 23, 2024
444580a
MNG-25 feat : 불던지기 푸시알림 메시지 추가 기능 구현
seungueonn Jun 23, 2024
1652f22
Merge branch 'MNG-25' of https://github.com/Modagbul/MOING_server_rel…
seungueonn Jun 24, 2024
e43d564
feat : 불 던지기 메시지 저장 안하도록 엔티티 수정
seungueonn Jul 1, 2024
c13f83c
MNG-25 fix : 불 던지기 메시지 저장 안하도록 엔티티 수정
seungueonn Jul 1, 2024
b1f3679
MNG-26 feat : 미션 인증 시 푸시 알림 전송
seungueonn Jul 1, 2024
228836c
MNG-26 fix : 불필요한 필드 삭제
seungueonn Jul 1, 2024
77ead00
MNG-25 feat : 불던지기 메시지 관련 API 문서 추가
seungueonn Jul 2, 2024
852b2a8
MNG-25 chore : 로그파일(logs/) gitignore 추가
seungueonn Jul 7, 2024
3258a92
Merge branch 'MNG-25' of https://github.com/Modagbul/MOING_Server_Rel…
seungueonn Jul 7, 2024
5f62c3f
MNG-25 chore : 불필요한 import 삭제 및 field 순서 변경
seungueonn Jul 7, 2024
eafc1ed
Merge pull request #299 from Modagbul/MNG-26
minsu20 Jul 7, 2024
accdbb7
Merge pull request #298 from Modagbul/MNG-25
minsu20 Jul 7, 2024
f1de5a6
MNG-28 feat: 도메인에 isCommentPush 추가
minsu20 Jul 10, 2024
5639506
MNG-28 feat: 미션 댓글 생성 시 푸시 알림 기능 추가
minsu20 Jul 10, 2024
4a3950e
MNG-28 docs: 댓글 생성 알림 Category에 추가
minsu20 Jul 10, 2024
22411ca
Merge pull request #300 from Modagbul/MNG-28
seungueonn Jul 16, 2024
ba7b49b
MNG-28 fix: missionComment path 수정
minsu20 Jul 22, 2024
e0dc9e0
MNG-28 fix: 오타 수정
minsu20 Jul 22, 2024
29dc9f3
Merge pull request #301 from Modagbul/MNG-28
minsu20 Jul 22, 2024
9b3a081
MNG-28 feat: 푸시 알림 보낼 떼 idInfo에 type 추가
minsu20 Aug 9, 2024
75c31fa
Merge pull request #303 from Modagbul/MNG-28
seungueonn Aug 9, 2024
df1681e
fix: 회원가입시 미션댓글 알림 여부 true로 수정
minsu20 Aug 9, 2024
e46b0a4
Merge pull request #304 from Modagbul/MNG-28
minsu20 Aug 9, 2024
446e9aa
MNG-28 feat: 푸시알림 보낼 때 idInfo에 tyep 추가
minsu20 Aug 11, 2024
5f283e5
Merge pull request #305 from Modagbul/MNG-28
minsu20 Aug 12, 2024
8e7d9e2
fix/#307: 신고된 인증 이미지 url 변경
seungueonn Sep 2, 2024
ae59e52
fix/#307: /mission/prove 에 해당하는 idinfo에 isRepeat 추가
seungueonn Sep 2, 2024
88ccc3b
Merge pull request #308 from Modagbul/fix/#307
seungueonn Sep 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,4 @@ data.sql

firebase-key.json
apple-key.p8
logs/
2 changes: 2 additions & 0 deletions src/docs/asciidoc/AlarmHistory-API.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ operation::alarm-history-controller-test/get_all_alarm_history[snippets='http-re
| `REJECT_TEAM`
| 소모임 반려

| `COMMENT`
| 댓글 생성 알림
|===

[[AlarmHistory-알림-단건-조회하기]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.moing.backend.domain.history.application.dto.response.MemberIdAndToken;
import com.moing.backend.domain.history.application.dto.response.NewUploadInfo;
import com.moing.backend.domain.history.application.mapper.AlarmHistoryMapper;
import com.moing.backend.domain.history.domain.entity.AlarmType;
import com.moing.backend.domain.history.domain.entity.PagePath;
import com.moing.backend.domain.member.domain.entity.Member;
import com.moing.backend.domain.team.domain.entity.Team;
Expand All @@ -20,6 +19,7 @@
import java.util.List;
import java.util.Optional;

import static com.moing.backend.domain.history.domain.entity.AlarmType.NEW_UPLOAD;
import static com.moing.backend.global.config.fcm.constant.NewNoticeUploadMessage.NEW_NOTICE_UPLOAD_MESSAGE;

@Service
Expand All @@ -41,14 +41,15 @@ public void sendNewUploadAlarm(BaseServiceResponse baseServiceResponse, Board bo
Optional<List<MemberIdAndToken>> memberIdAndTokensByPush = AlarmHistoryMapper.getNewUploadPushInfo(newUploadInfos);
Optional<List<MemberIdAndToken>> memberIdAndTokensBySave = AlarmHistoryMapper.getNewUploadSaveInfo(newUploadInfos);
// 알림 보내기
eventPublisher.publishEvent(new MultiFcmEvent(title, body, memberIdAndTokensByPush, memberIdAndTokensBySave, createIdInfo(team.getTeamId(), board.getBoardId()), team.getName(), AlarmType.NEW_UPLOAD, PagePath.NOTICE_PATH.getValue()));
eventPublisher.publishEvent(new MultiFcmEvent(title, body, memberIdAndTokensByPush, memberIdAndTokensBySave, createIdInfo(team.getTeamId(), board.getBoardId()), team.getName(), NEW_UPLOAD, PagePath.NOTICE_PATH.getValue()));
}
}

private String createIdInfo(Long teamId, Long boardId) {
JSONObject jo = new JSONObject();
jo.put("teamId", teamId);
jo.put("boardId", boardId);
jo.put("type", "NEW_UPLOAD_BOARD");
return jo.toJSONString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class CreateBoardCommentUseCase {
private final BoardCommentSaveService boardCommentSaveService;
private final BaseBoardService baseBoardService;
private final CheckLeaderUseCase checkLeaderUseCase;
private final SendCommentAlarmUseCase sendCommentAlarmUseCase;
private final SendBoardCommentAlarmUseCase sendCommentAlarm;
/**
* 게시글 댓글 생성
*/
Expand All @@ -33,7 +33,7 @@ public CreateCommentResponse createBoardComment(String socialId, Long teamId, Lo
// 2. 게시글 댓글 개수 증가
data.getBoard().incrComNum();
// 3. 게시글 댓글 알림
sendCommentAlarmUseCase.sendNewUploadAlarm(data, boardComment);
sendCommentAlarm.sendCommentAlarm(data, boardComment);
return new CreateCommentResponse(boardComment.getBoardCommentId());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
@Service
@RequiredArgsConstructor
@Transactional
public class SendCommentAlarmUseCase {
public class SendBoardCommentAlarmUseCase {

private final ApplicationEventPublisher eventPublisher;
private final BoardCommentGetService boardCommentGetService;

public void sendNewUploadAlarm(BaseBoardServiceResponse response, BoardComment comment) {
public void sendCommentAlarm(BaseBoardServiceResponse response, BoardComment comment) {
Member member = response.getMember();
Team team = response.getTeam();
Board board = response.getBoard();
Expand All @@ -50,21 +50,22 @@ private void sendBoardWriter(Board board, Member member, String title, String bo
Member receiver = board.getTeamMember().getMember();

if (checkBoardWriter(receiver, member, newUploadInfos)) {
eventPublisher.publishEvent(new SingleFcmEvent(receiver, title, body, createIdInfo(team.getTeamId(), board.getBoardId()), team.getName(), AlarmType.NEW_UPLOAD, PagePath.NOTICE_PATH.getValue(), receiver.isNewUploadPush()));
eventPublisher.publishEvent(new SingleFcmEvent(receiver, title, body, createIdInfo(team.getTeamId(), board.getBoardId()), team.getName(), AlarmType.COMMENT, PagePath.NOTICE_PATH.getValue(), receiver.isCommentPush()));
}
}

private void sendBoardCommentWriter(Board board, Member member, String title, String body, Team team, Optional<List<NewUploadInfo>> newUploadInfos) {
Optional<List<MemberIdAndToken>> memberIdAndTokensByPush = AlarmHistoryMapper.getNewUploadPushInfo(newUploadInfos);
Optional<List<MemberIdAndToken>> memberIdAndTokensBySave = AlarmHistoryMapper.getNewUploadSaveInfo(newUploadInfos);

eventPublisher.publishEvent(new MultiFcmEvent(title, body, memberIdAndTokensByPush, memberIdAndTokensBySave, createIdInfo(team.getTeamId(), board.getBoardId()), team.getName(), AlarmType.NEW_UPLOAD, PagePath.NOTICE_PATH.getValue()));
eventPublisher.publishEvent(new MultiFcmEvent(title, body, memberIdAndTokensByPush, memberIdAndTokensBySave, createIdInfo(team.getTeamId(), board.getBoardId()), team.getName(), AlarmType.COMMENT, PagePath.NOTICE_PATH.getValue()));
}

private String createIdInfo(Long teamId, Long boardId) {
JSONObject jo = new JSONObject();
jo.put("teamId", teamId);
jo.put("boardId", boardId);
jo.put("type", "COMMENT_BOARD");
return jo.toJSONString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public Optional<List<NewUploadInfo>> findNewUploadInfo(Long memberId, Long board
List<NewUploadInfo> result = queryFactory.select(Projections.constructor(NewUploadInfo.class,
boardComment.teamMember.member.fcmToken,
boardComment.teamMember.member.memberId,
boardComment.teamMember.member.isNewUploadPush,
boardComment.teamMember.member.isCommentPush,
boardComment.teamMember.member.isSignOut))
.distinct()
.from(boardComment)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.moing.backend.domain.fire.application.dto.req;

import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@NoArgsConstructor
@Getter
public class FireThrowReq {

private String message;

@Builder
public FireThrowReq(String message) {
this.message = message;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.moing.backend.domain.fire.application.service;

import com.moing.backend.domain.history.domain.entity.AlarmType;
import com.moing.backend.domain.fire.application.dto.req.FireThrowReq;
import com.moing.backend.domain.member.domain.entity.Member;
import com.moing.backend.domain.mission.domain.entity.Mission;
import com.moing.backend.domain.mission.domain.entity.constant.MissionType;
Expand All @@ -14,6 +14,7 @@
import javax.transaction.Transactional;
import java.util.Random;

import static com.moing.backend.domain.history.domain.entity.AlarmType.FIRE;
import static com.moing.backend.domain.history.domain.entity.PagePath.MISSION_PATH;
import static com.moing.backend.global.config.fcm.constant.FireThrowMessage.*;

Expand All @@ -24,28 +25,31 @@ public class FireThrowAlarmUseCase {

private final ApplicationEventPublisher eventPublisher;

public void sendFireThrowAlarm(Member throwMember, Member receiveMember, Team team, Mission mission) {
public void sendFireThrowAlarm(Member throwMember, Member receiveMember, Team team, Mission mission, FireThrowReq fireThrowReq) {

Random random = new Random(System.currentTimeMillis());
int randomNum = random.nextInt(2);
int randomNum = new Random(System.currentTimeMillis()).nextInt(2);

String title = getTitle(throwMember.getNickName(), receiveMember.getNickName(), randomNum);
String message = getMessage(throwMember.getNickName(), receiveMember.getNickName(), randomNum);
String idInfo = createIdInfo(mission.getType() == MissionType.REPEAT, mission.getTeam().getTeamId(), mission.getId());
String title = fireThrowReq != null ? NEW_FIRE_THROW_TITLE_WITH_COMMENT.to(throwMember.getNickName())
: getRandomTitle(throwMember.getNickName(), receiveMember.getNickName(), randomNum);
String message = fireThrowReq != null ? fireThrowReq.getMessage()
: getRandomMessage(throwMember.getNickName(), receiveMember.getNickName(), randomNum);
String idInfo = createIdInfo(mission.getType() == MissionType.REPEAT, mission.getTeam().getTeamId(), mission.getId(), fireThrowReq == null);

eventPublisher.publishEvent(new SingleFcmEvent(receiveMember, title, message, idInfo, team.getName(), AlarmType.FIRE, MISSION_PATH.getValue(), receiveMember.isFirePush()));
eventPublisher.publishEvent(new SingleFcmEvent(receiveMember, title, message, idInfo, team.getName(), FIRE, MISSION_PATH.getValue(), receiveMember.isFirePush()));
}

public String getMessage(String pusher, String receiver, int num) {
public String getRandomMessage(String pusher, String receiver, int num) {

switch (num) {
case 0: return pusher + "님이 " + receiver + NEW_FIRE_THROW_MESSAGE1.getMessage();
case 1: return receiver + "님! " + pusher + NEW_FIRE_THROW_MESSAGE2.getMessage();
case 0:
return NEW_FIRE_THROW_MESSAGE1.fromTo(pusher, receiver);
case 1: return NEW_FIRE_THROW_MESSAGE2.toFrom(receiver, pusher);

}
return pusher + "님이" + receiver + NEW_FIRE_THROW_MESSAGE1.getMessage();
return NEW_FIRE_THROW_MESSAGE1.fromTo(pusher, receiver);
}

public String getTitle(String pusher, String receiver, int num) {
public String getRandomTitle(String pusher, String receiver, int num) {

switch (num) {
case 0:
Expand All @@ -56,13 +60,20 @@ public String getTitle(String pusher, String receiver, int num) {
return NEW_FIRE_THROW_TITLE1.getMessage();
}

private String createIdInfo(boolean isRepeated, Long teamId, Long missionId) {
private String createIdInfo(boolean isRepeated, Long teamId, Long missionId, boolean isMessageNull) {
JSONObject jo = new JSONObject();
jo.put("isRepeated", isRepeated);
jo.put("teamId", teamId);
jo.put("missionId", missionId);
jo.put("type", getType(isMessageNull));
return jo.toJSONString();
}

private String getType(boolean isMessageNull){
if(isMessageNull)
return "FIRE_MESSAGE_NULL";
return "FIRE_MESSAGE_EXIST";
}


}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.moing.backend.domain.fire.application.service;

import com.moing.backend.domain.fire.application.dto.req.FireThrowReq;
import com.moing.backend.domain.fire.application.dto.res.FireReceiveRes;
import com.moing.backend.domain.fire.application.dto.res.FireThrowRes;
import com.moing.backend.domain.fire.application.mapper.FireMapper;
Expand All @@ -19,6 +20,7 @@
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Optional;

@Service
@Transactional
Expand All @@ -33,7 +35,7 @@ public class FireThrowUseCase {
private final MissionQueryService missionQueryService;
private final TeamGetService teamGetService;

public FireThrowRes createFireThrow(String userId, Long receiveMemberId, Long missionId, Long teamId) {
public FireThrowRes createFireThrow(String userId, Long receiveMemberId, Long missionId, Long teamId, FireThrowReq fireThrowReq) {

Member throwMember = memberGetService.getMemberBySocialId(userId);
Member receiveMember = memberGetService.getMemberByMemberId(receiveMemberId);
Expand All @@ -50,12 +52,14 @@ public FireThrowRes createFireThrow(String userId, Long receiveMemberId, Long mi
throw new NoAuthThrowFireException();
}

fireThrowAlarmUseCase.sendFireThrowAlarm(throwMember, receiveMember, team, mission);
fireThrowAlarmUseCase.sendFireThrowAlarm(throwMember, receiveMember, team, mission, fireThrowReq);

return FireMapper.mapToFireThrowRes(fireSaveService.save(Fire.builder()
Fire save = fireSaveService.save(Fire.builder()
.throwMemberId(throwMember.getMemberId())
.receiveMemberId(receiveMemberId)
.build()));
.build());

return FireMapper.mapToFireThrowRes(fireSaveService.save(save));
}

public List<FireReceiveRes> getFireReceiveList(String userId,Long teamId, Long missionId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
@AllArgsConstructor
public class Fire extends BaseTimeEntity {


@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "fire_id")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.moing.backend.domain.fire.presentation;

import com.moing.backend.domain.fire.application.dto.req.FireThrowReq;
import com.moing.backend.domain.fire.application.dto.res.FireReceiveRes;
import com.moing.backend.domain.fire.application.dto.res.FireThrowRes;
import com.moing.backend.domain.fire.application.service.FireThrowUseCase;
Expand Down Expand Up @@ -30,8 +31,8 @@ public class FireController {

@PostMapping("/{receiveMemberId}")
public ResponseEntity<SuccessResponse<FireThrowRes>> throwFire (@AuthenticationPrincipal User user, @PathVariable("teamId") Long teamId,
@PathVariable("receiveMemberId") Long receiveMemberId, @PathVariable("missionId") Long missionId) {
return ResponseEntity.ok(SuccessResponse.create(THROW_FIRE_SUCCESS.getMessage(), this.fireThrowUseCase.createFireThrow(user.getSocialId(), receiveMemberId, missionId, teamId)));
@PathVariable("receiveMemberId") Long receiveMemberId, @PathVariable("missionId") Long missionId, @RequestBody(required = false) FireThrowReq fireThrowReq) {
return ResponseEntity.ok(SuccessResponse.create(THROW_FIRE_SUCCESS.getMessage(), this.fireThrowUseCase.createFireThrow(user.getSocialId(), receiveMemberId, missionId, teamId, fireThrowReq)));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ public enum AlarmType {
FIRE,
REMIND,
APPROVE_TEAM,
REJECT_TEAM
REJECT_TEAM,
COMMENT
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ public class Member extends BaseTimeEntity {
@Column(nullable = false)
private boolean isFirePush;

@ColumnDefault("true")
@Column(nullable = false)
private boolean isCommentPush;

private boolean isDeleted;

private LocalDateTime lastSignInTime;
Expand Down Expand Up @@ -140,10 +144,15 @@ public void updateFirePush(boolean firePush) {
this.isFirePush = firePush;
}

public void updateCommentPush(boolean commentPush){
this.isCommentPush=commentPush;
}

public void updateAllPush(boolean allPush) {
this.isNewUploadPush = allPush;
this.isRemindPush = allPush;
this.isFirePush = allPush;
this.isCommentPush=allPush;
}

public void updateFcmToken(String fcmToken) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.moing.backend.domain.history.application.dto.response.MemberIdAndToken;
import com.moing.backend.domain.history.application.dto.response.NewUploadInfo;
import com.moing.backend.domain.history.application.mapper.AlarmHistoryMapper;
import com.moing.backend.domain.history.domain.entity.AlarmType;
import com.moing.backend.domain.history.domain.entity.PagePath;
import com.moing.backend.domain.member.domain.entity.Member;
import com.moing.backend.domain.mission.domain.entity.Mission;
Expand All @@ -21,6 +20,7 @@
import java.util.List;
import java.util.Optional;

import static com.moing.backend.domain.history.domain.entity.AlarmType.NEW_UPLOAD;
import static com.moing.backend.global.config.fcm.constant.NewMissionTitle.NEW_SINGLE_MISSION_COMING;

@Service
Expand All @@ -43,7 +43,7 @@ public void sendNewMissionUploadAlarm(Member member, Mission mission) {
Optional<List<MemberIdAndToken>> memberIdAndTokensByPush = AlarmHistoryMapper.getNewUploadPushInfo(newUploadInfos);
Optional<List<MemberIdAndToken>> memberIdAndTokensBySave = AlarmHistoryMapper.getNewUploadSaveInfo(newUploadInfos);
// 알림 보내기
eventPublisher.publishEvent(new MultiFcmEvent(title, message, memberIdAndTokensByPush, memberIdAndTokensBySave, createIdInfo(team.getTeamId(), mission.getId(),mission.getType(),mission.getStatus()), team.getName(), AlarmType.NEW_UPLOAD, PagePath.MISSION_PATH.getValue()));
eventPublisher.publishEvent(new MultiFcmEvent(title, message, memberIdAndTokensByPush, memberIdAndTokensBySave, createIdInfo(team.getTeamId(), mission.getId(),mission.getType(),mission.getStatus()), team.getName(), NEW_UPLOAD, PagePath.MISSION_PATH.getValue()));
}

private String createIdInfo(Long teamId, Long missionId,MissionType type, MissionStatus status) {
Expand All @@ -52,6 +52,7 @@ private String createIdInfo(Long teamId, Long missionId,MissionType type, Missio
jo.put("teamId", teamId);
jo.put("missionId", missionId);
jo.put("status", status.name());
jo.put("type", "NEW_UPLOAD_MISSION");
return jo.toJSONString();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.moing.backend.domain.missionArchive.application.service;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor
public enum MissionArchiveCreateMessage {

CREATOR_CREATE_MISSION_ARCHIVE("%s님이 미션을 인증했어요!"),
TEAM_AND_TITLE("[%s] %s");

private final String message;

public String to(String creator) {
return String.format(message, creator);
}

public String teamAndTitle(String team, String title) {
return String.format(message, team, title);
}
}
Loading
Loading