Skip to content

Commit b28ccad

Browse files
authored
푸시 딥링크 추가 및 초대장 발신자 수신 필터링 (#40)
* feat: 회원 탈퇴시 모임 참여한�모임에서 전부 제거 * refactor: 코드 정리 * Auto stash before rebase of "feat/delete-gathering-member" onto "origin/main" * fix: 브랜치 충돌 * fix: test * feat: 제안한 사람 푸시 필터링 * refactor: 코드 정리 * feat: dto 변경 * feat: deep link 변경 * refactor: 코드 정리 * refactor: 코드 정리
1 parent 8262750 commit b28ccad

File tree

23 files changed

+226
-139
lines changed

23 files changed

+226
-139
lines changed

tuk-api/src/main/kotlin/nexters/tuk/application/gathering/GatheringCommandService.kt

Lines changed: 0 additions & 25 deletions
This file was deleted.

tuk-api/src/main/kotlin/nexters/tuk/application/gathering/GatheringMemberService.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,9 @@ class GatheringMemberService(
5959

6060
return gatheringMembers.map { it.memberId }
6161
}
62+
63+
@Transactional
64+
fun deleteGatheringMember(memberId: Long) {
65+
gatheringMemberRepository.deleteAllByMemberId(memberId)
66+
}
6267
}

tuk-api/src/main/kotlin/nexters/tuk/application/gathering/GatheringProposalService.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ class GatheringProposalService(
3737
pushService.sendPush(
3838
PushCommand.Push.Proposal(
3939
pushType = PushType.PROPOSAL,
40-
gatheringId = command.gatheringId
40+
gatheringId = command.gatheringId,
41+
proposalId = command.proposalId,
42+
proposerMemberId = command.memberId,
4143
)
4244
)
4345
}

tuk-api/src/main/kotlin/nexters/tuk/application/gathering/GatheringGenerateService.kt renamed to tuk-api/src/main/kotlin/nexters/tuk/application/gathering/GatheringService.kt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ import nexters.tuk.application.gathering.dto.request.GatheringCommand
44
import nexters.tuk.application.gathering.dto.response.GatheringResponse
55
import nexters.tuk.domain.gathering.Gathering
66
import nexters.tuk.domain.gathering.GatheringRepository
7+
import nexters.tuk.domain.gathering.findByIdOrThrow
78
import org.springframework.stereotype.Service
89
import org.springframework.transaction.annotation.Transactional
910

1011
@Service
11-
class GatheringGenerateService(
12+
class GatheringService(
1213
private val gatheringRepository: GatheringRepository,
1314
private val gatheringMemberService: GatheringMemberService,
1415
private val gatheringTagService: GatheringTagService,
@@ -32,4 +33,16 @@ class GatheringGenerateService(
3233
gathering.id,
3334
)
3435
}
36+
37+
@Transactional
38+
fun updateGathering(command: GatheringCommand.Update): GatheringResponse.Simple {
39+
val gathering = gatheringRepository.findByIdOrThrow(command.gatheringId)
40+
gathering.update(command)
41+
42+
return GatheringResponse.Simple(
43+
gatheringId = gathering.id,
44+
gatheringName = gathering.name,
45+
intervalDays = gathering.intervalDays,
46+
)
47+
}
3548
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package nexters.tuk.application.gathering.handler
2+
3+
import nexters.tuk.application.gathering.GatheringMemberService
4+
import nexters.tuk.application.member.MemberService
5+
import nexters.tuk.application.member.event.MemberEvent
6+
import org.springframework.context.event.EventListener
7+
import org.springframework.stereotype.Component
8+
import org.springframework.transaction.event.TransactionPhase
9+
import org.springframework.transaction.event.TransactionalEventListener
10+
11+
@Component
12+
class GatheringHandler(
13+
private val gatheringMemberService: GatheringMemberService,
14+
) {
15+
16+
@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT)
17+
fun handleDeleteMember(event: MemberEvent.MemberDeleted) {
18+
gatheringMemberService.deleteGatheringMember(event.memberId)
19+
}
20+
}

tuk-api/src/main/kotlin/nexters/tuk/application/member/MemberService.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@ package nexters.tuk.application.member
22

33
import nexters.tuk.application.member.dto.request.MemberCommand
44
import nexters.tuk.application.member.dto.response.MemberResponse
5+
import nexters.tuk.application.member.event.MemberEvent
56
import nexters.tuk.contract.ApiResponse
67
import nexters.tuk.contract.BaseException
78
import nexters.tuk.contract.ErrorType
89
import nexters.tuk.domain.member.Member
910
import nexters.tuk.domain.member.MemberRepository
11+
import org.springframework.context.ApplicationEventPublisher
1012
import org.springframework.stereotype.Service
1113
import org.springframework.transaction.annotation.Transactional
1214

1315
@Service
1416
class MemberService(
1517
private val memberRepository: MemberRepository,
18+
private val applicationEventPublisher: ApplicationEventPublisher,
1619
) {
1720
@Transactional
1821
fun login(command: MemberCommand.Login): MemberResponse.Login {
@@ -48,6 +51,7 @@ class MemberService(
4851
@Transactional
4952
fun deleteMember(memberId: Long) {
5053
memberRepository.leave(memberId)
54+
applicationEventPublisher.publishEvent(MemberEvent.MemberDeleted(memberId))
5155
}
5256

5357
@Transactional(readOnly = true)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package nexters.tuk.application.member.event
2+
3+
class MemberEvent {
4+
data class MemberDeleted(
5+
val memberId: Long,
6+
)
7+
}

tuk-api/src/main/kotlin/nexters/tuk/application/proposal/dto/request/ProposalCommand.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import nexters.tuk.application.proposal.vo.ProposalPurposeInfo
55
class ProposalCommand {
66
data class Propose(
77
val memberId: Long,
8-
val gatheringId: Long?,
8+
val gatheringId: Long? = null,
99
val purpose: ProposalPurposeInfo,
1010
)
1111
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package nexters.tuk.application.push
2+
3+
enum class PushDeepLink(
4+
val link: String,
5+
) {
6+
DEFAULT("tuk-app://tuk"),
7+
PROPOSAL("tuk-app://tuk/proposal-detail/%s"),
8+
;
9+
}

tuk-api/src/main/kotlin/nexters/tuk/application/push/PushService.kt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,18 @@ class PushService(
1919

2020
@Transactional
2121
fun sendPush(command: PushCommand.Push) {
22-
val pushMessage = PushMessage.random()
2322
when (command) {
2423
is PushCommand.Push.GatheringNotification -> {
25-
val memberIds = command.recipients.map { it.memberId }
24+
val pushMessage = PushMessage.random(pushType = command.pushType)
25+
val memberIds = gatheringMemberService.getGatheringMemberIds(gatheringId = command.gatheringId)
2626
pushAll(memberIds = memberIds, pushMessage = pushMessage)
27-
logger.info("Sent gathering notification push. Recipients: ${command.recipients.size}, PushType: ${command.pushType}")
27+
logger.info("Sent gathering notification push. Recipients: ${memberIds.size}, PushType: ${command.pushType}")
2828
}
2929

3030
is PushCommand.Push.Proposal -> {
31+
val pushMessage = PushMessage.random(pushType = command.pushType, proposalId = command.proposalId)
3132
val memberIds = gatheringMemberService.getGatheringMemberIds(gatheringId = command.gatheringId)
33+
.filter { memberId -> memberId != command.proposerMemberId }
3234
pushAll(memberIds = memberIds, pushMessage = pushMessage)
3335
logger.info("Sent proposal push. GatheringId: ${command.gatheringId}, Recipients: ${memberIds.size}, PushType: ${command.pushType}")
3436
}
@@ -37,7 +39,7 @@ class PushService(
3739

3840
private fun pushAll(
3941
memberIds: List<Long>,
40-
pushMessage: PushMessage,
42+
pushMessage: PushData,
4143
) {
4244
logger.info("PushService.pushAll -> memberIds: $memberIds")
4345
val memberNameMap = memberService.getMembers(memberIds).associate { it.memberId to it.memberName }
@@ -50,7 +52,8 @@ class PushService(
5052
memberNameMap[token.memberId]
5153
?: return@forEach
5254
),
53-
body = pushMessage.body
55+
body = pushMessage.body,
56+
deepLink = pushMessage.deepLink(pushMessage.meta?.proposalId),
5457
)
5558
)
5659
}

0 commit comments

Comments
 (0)