푸시 알림 전송 언어 처리

This commit is contained in:
2026-01-15 17:21:22 +09:00
parent 9dc23f0622
commit ed2660adc6
18 changed files with 258 additions and 503 deletions

View File

@@ -1,9 +1,9 @@
package kr.co.vividnext.sodalive.member
import com.querydsl.jpa.impl.JPAQueryFactory
import kr.co.vividnext.sodalive.fcm.GetMessageRecipientPushTokenResponse
import kr.co.vividnext.sodalive.fcm.QGetMessageRecipientPushTokenResponse
import kr.co.vividnext.sodalive.fcm.PushTokenInfo
import kr.co.vividnext.sodalive.fcm.QPushToken.pushToken
import kr.co.vividnext.sodalive.fcm.QPushTokenInfo
import kr.co.vividnext.sodalive.live.reservation.QLiveReservation.liveReservation
import kr.co.vividnext.sodalive.live.room.QLiveRoom.liveRoom
import kr.co.vividnext.sodalive.member.QMember.member
@@ -29,36 +29,33 @@ interface MemberRepository : JpaRepository<Member, Long>, MemberQueryRepository
interface MemberQueryRepository {
fun findByNicknameAndOtherCondition(nickname: String, member: Member): List<Member>
fun findCreatorByIdOrNull(memberId: Long): Member?
fun getAllRecipientPushTokens(isAuth: Boolean?, container: String): List<List<String>>
fun getAllRecipientPushTokens(isAuth: Boolean?): List<PushTokenInfo>
fun getCreateLiveRoomNotificationRecipientPushTokens(
creatorId: Long,
isAuth: Boolean,
isAvailableJoinCreator: Boolean,
container: String
): List<List<String>>
isAvailableJoinCreator: Boolean
): List<PushTokenInfo>
fun getStartLiveRoomNotificationRecipientPushTokens(
creatorId: Long,
roomId: Long,
isAuth: Boolean,
isAvailableJoinCreator: Boolean,
container: String
): List<List<String>>
isAvailableJoinCreator: Boolean
): List<PushTokenInfo>
fun getUploadContentNotificationRecipientPushTokens(
creatorId: Long,
isAuth: Boolean,
container: String
): List<List<String>>
isAuth: Boolean
): List<PushTokenInfo>
fun getMessageRecipientPushToken(messageId: Long): GetMessageRecipientPushTokenResponse?
fun getIndividualRecipientPushTokens(recipients: List<Long>, isAuth: Boolean?): Map<String, List<List<String>>>
fun getMessageRecipientPushToken(messageId: Long): PushTokenInfo?
fun getIndividualRecipientPushTokens(recipients: List<Long>, isAuth: Boolean?): List<PushTokenInfo>
fun getChangeNicknamePrice(memberId: Long): GetChangeNicknamePriceResponse
fun getMemberByEmail(email: String): Member?
fun getChangeNoticeRecipientPushTokens(creatorId: Long): Map<String, List<List<String>>>
fun getPushTokenFromReservationList(roomId: Long): Map<String, List<List<String>>>
fun getAuditionNoticeRecipientPushTokens(isAuth: Boolean): Map<String, List<List<String>>>
fun getChangeNoticeRecipientPushTokens(creatorId: Long): List<PushTokenInfo>
fun getPushTokenFromReservationList(roomId: Long): List<PushTokenInfo>
fun getAuditionNoticeRecipientPushTokens(isAuth: Boolean): List<PushTokenInfo>
fun getMemberProfile(memberId: Long, myMemberId: Long): GetMemberProfileResponse
@@ -103,10 +100,9 @@ class MemberQueryRepositoryImpl(
.fetchFirst()
}
override fun getAllRecipientPushTokens(isAuth: Boolean?, container: String): List<List<String>> {
override fun getAllRecipientPushTokens(isAuth: Boolean?): List<PushTokenInfo> {
var where = member.isActive.isTrue
.and(member.email.notIn("admin@sodalive.net"))
.and(pushToken.deviceType.eq(container))
if (isAuth != null) {
where = if (isAuth) {
@@ -117,22 +113,25 @@ class MemberQueryRepositoryImpl(
}
return queryFactory
.select(pushToken.token)
.select(
QPushTokenInfo(
pushToken.token,
pushToken.deviceType,
pushToken.languageCode.coalesce("ko")
)
)
.from(member)
.innerJoin(pushToken).on(member.id.eq(pushToken.member.id))
.leftJoin(member.auth, auth)
.where(where)
.fetch()
.toSet()
.chunked(500)
}
override fun getCreateLiveRoomNotificationRecipientPushTokens(
creatorId: Long,
isAuth: Boolean,
isAvailableJoinCreator: Boolean,
container: String
): List<List<String>> {
isAvailableJoinCreator: Boolean
): List<PushTokenInfo> {
val member = QMember.member
val creator = QMember.member
@@ -147,7 +146,6 @@ class MemberQueryRepositoryImpl(
)
)
.and(creatorFollowing.isNotify.isTrue)
.and(pushToken.deviceType.eq(container))
.or(member.id.eq(4))
if (isAuth) {
@@ -159,7 +157,13 @@ class MemberQueryRepositoryImpl(
}
return queryFactory
.select(pushToken.token)
.select(
QPushTokenInfo(
pushToken.token,
pushToken.deviceType,
pushToken.languageCode.coalesce("ko")
)
)
.from(creatorFollowing)
.innerJoin(creatorFollowing.creator, creator)
.innerJoin(creatorFollowing.member, member)
@@ -168,17 +172,14 @@ class MemberQueryRepositoryImpl(
.leftJoin(creatorFollowing.member.auth, auth)
.where(where)
.fetch()
.toSet()
.chunked(500)
}
override fun getStartLiveRoomNotificationRecipientPushTokens(
creatorId: Long,
roomId: Long,
isAuth: Boolean,
isAvailableJoinCreator: Boolean,
container: String
): List<List<String>> {
isAvailableJoinCreator: Boolean
): List<PushTokenInfo> {
val member = QMember.member
val creator = QMember.member
@@ -193,7 +194,6 @@ class MemberQueryRepositoryImpl(
)
)
.and(creatorFollowing.isNotify.isTrue)
.and(pushToken.deviceType.eq(container))
.or(creatorFollowing.member.id.eq(4))
if (isAuth) {
@@ -205,7 +205,13 @@ class MemberQueryRepositoryImpl(
}
val followingMemberPushToken = queryFactory
.select(pushToken.token)
.select(
QPushTokenInfo(
pushToken.token,
pushToken.deviceType,
pushToken.languageCode.coalesce("ko")
)
)
.from(creatorFollowing)
.innerJoin(creatorFollowing.creator, creator)
.innerJoin(creatorFollowing.member, member)
@@ -224,14 +230,19 @@ class MemberQueryRepositoryImpl(
blockMemberRepository.getBlockedMemberIdList(creatorId)
)
)
.and(pushToken.deviceType.eq(container))
if (isAuth) {
where = where.and(auth.isNotNull)
}
val reservationMemberPushToken = queryFactory
.select(pushToken.token)
.select(
QPushTokenInfo(
pushToken.token,
pushToken.deviceType,
pushToken.languageCode.coalesce("ko")
)
)
.from(liveReservation)
.innerJoin(liveReservation.member, member)
.innerJoin(liveReservation.member.notification, memberNotification)
@@ -240,16 +251,13 @@ class MemberQueryRepositoryImpl(
.where(where)
.fetch()
return (followingMemberPushToken + reservationMemberPushToken)
.toSet()
.chunked(500)
return (followingMemberPushToken + reservationMemberPushToken).distinctBy { it.token }
}
override fun getUploadContentNotificationRecipientPushTokens(
creatorId: Long,
isAuth: Boolean,
container: String
): List<List<String>> {
isAuth: Boolean
): List<PushTokenInfo> {
val member = QMember.member
val creator = QMember.member
@@ -263,7 +271,6 @@ class MemberQueryRepositoryImpl(
)
)
.and(creatorFollowing.isNotify.isTrue)
.and(pushToken.deviceType.eq(container))
.or(member.id.eq(4))
if (isAuth) {
@@ -271,7 +278,13 @@ class MemberQueryRepositoryImpl(
}
return queryFactory
.select(pushToken.token)
.select(
QPushTokenInfo(
pushToken.token,
pushToken.deviceType,
pushToken.languageCode.coalesce("ko")
)
)
.from(creatorFollowing)
.innerJoin(creatorFollowing.creator, creator)
.innerJoin(creatorFollowing.member, member)
@@ -280,16 +293,15 @@ class MemberQueryRepositoryImpl(
.leftJoin(member.auth, auth)
.where(where)
.fetch()
.toSet()
.chunked(500)
}
override fun getMessageRecipientPushToken(messageId: Long): GetMessageRecipientPushTokenResponse? {
override fun getMessageRecipientPushToken(messageId: Long): PushTokenInfo? {
return queryFactory
.select(
QGetMessageRecipientPushTokenResponse(
QPushTokenInfo(
pushToken.token,
pushToken.deviceType
pushToken.deviceType,
pushToken.languageCode.coalesce("ko")
)
)
.from(message)
@@ -306,7 +318,7 @@ class MemberQueryRepositoryImpl(
override fun getIndividualRecipientPushTokens(
recipients: List<Long>,
isAuth: Boolean?
): Map<String, List<List<String>>> {
): List<PushTokenInfo> {
var where = member.isActive.isTrue
.and(member.email.notIn("admin@sodalive.net"))
.and(member.id.`in`(*recipients.toTypedArray()))
@@ -319,27 +331,19 @@ class MemberQueryRepositoryImpl(
}
}
val aosPushTokens = queryFactory
.select(pushToken.token)
return queryFactory
.select(
QPushTokenInfo(
pushToken.token,
pushToken.deviceType,
pushToken.languageCode.coalesce("ko")
)
)
.from(member)
.innerJoin(pushToken).on(member.id.eq(pushToken.member.id))
.leftJoin(member.auth, auth)
.where(where.and(pushToken.deviceType.eq("aos")))
.where(where)
.fetch()
.toSet()
.chunked(500)
val iosPushTokens = queryFactory
.select(pushToken.token)
.from(member)
.innerJoin(pushToken).on(member.id.eq(pushToken.member.id))
.leftJoin(member.auth, auth)
.where(where.and(pushToken.deviceType.eq("ios")))
.fetch()
.toSet()
.chunked(500)
return mapOf("aos" to aosPushTokens, "ios" to iosPushTokens)
}
override fun getChangeNicknamePrice(memberId: Long): GetChangeNicknamePriceResponse {
@@ -366,7 +370,7 @@ class MemberQueryRepositoryImpl(
.fetchOne()
}
override fun getChangeNoticeRecipientPushTokens(creatorId: Long): Map<String, List<List<String>>> {
override fun getChangeNoticeRecipientPushTokens(creatorId: Long): List<PushTokenInfo> {
val member = QMember.member
val creator = QMember.member
@@ -381,90 +385,63 @@ class MemberQueryRepositoryImpl(
)
.and(creatorFollowing.isNotify.isTrue)
val aosPushTokens = queryFactory
.select(pushToken.token)
return queryFactory
.select(
QPushTokenInfo(
pushToken.token,
pushToken.deviceType,
pushToken.languageCode.coalesce("ko")
)
)
.from(creatorFollowing)
.innerJoin(creatorFollowing.creator, creator)
.innerJoin(creatorFollowing.member, member)
.innerJoin(pushToken).on(creatorFollowing.member.id.eq(pushToken.member.id))
.where(where.and(pushToken.deviceType.eq("aos")))
.where(where)
.fetch()
.toSet()
.chunked(500)
val iosPushTokens = queryFactory
.select(pushToken.token)
.from(creatorFollowing)
.innerJoin(creatorFollowing.creator, creator)
.innerJoin(creatorFollowing.member, member)
.innerJoin(pushToken).on(creatorFollowing.member.id.eq(pushToken.member.id))
.where(where.and(pushToken.deviceType.eq("ios")))
.fetch()
.toSet()
.chunked(500)
return mapOf("aos" to aosPushTokens, "ios" to iosPushTokens)
}
override fun getPushTokenFromReservationList(roomId: Long): Map<String, List<List<String>>> {
override fun getPushTokenFromReservationList(roomId: Long): List<PushTokenInfo> {
val where = liveRoom.id.eq(roomId)
.and(liveReservation.isActive.isTrue)
val aosPushTokens = queryFactory
.select(pushToken.token)
return queryFactory
.select(
QPushTokenInfo(
pushToken.token,
pushToken.deviceType,
pushToken.languageCode.coalesce("ko")
)
)
.from(liveReservation)
.innerJoin(liveReservation.room, liveRoom)
.innerJoin(liveReservation.member, member)
.innerJoin(pushToken).on(member.id.eq(pushToken.member.id))
.where(where.and(pushToken.deviceType.eq("aos")))
.where(where)
.fetch()
.toSet()
.chunked(500)
val iosPushTokens = queryFactory
.select(pushToken.token)
.from(liveReservation)
.innerJoin(liveReservation.room, liveRoom)
.innerJoin(liveReservation.member, member)
.innerJoin(pushToken).on(member.id.eq(pushToken.member.id))
.where(where.and(pushToken.deviceType.eq("ios")))
.fetch()
.toSet()
.chunked(500)
return mapOf("aos" to aosPushTokens, "ios" to iosPushTokens)
}
override fun getAuditionNoticeRecipientPushTokens(isAuth: Boolean): Map<String, List<List<String>>> {
override fun getAuditionNoticeRecipientPushTokens(isAuth: Boolean): List<PushTokenInfo> {
var where = memberNotification.audition.isTrue
if (isAuth) {
where = where.and(auth.isNotNull)
}
val aosPushTokens = queryFactory
.select(pushToken.token)
return queryFactory
.select(
QPushTokenInfo(
pushToken.token,
pushToken.deviceType,
pushToken.languageCode.coalesce("ko")
)
)
.from(member)
.innerJoin(pushToken).on(member.id.eq(pushToken.member.id))
.leftJoin(member.auth, auth)
.leftJoin(memberNotification).on(memberNotification.member.id.eq(member.id))
.where(where.and(pushToken.deviceType.eq("aos")))
.where(where)
.fetch()
.toSet()
.chunked(500)
val iosPushTokens = queryFactory
.select(pushToken.token)
.from(member)
.innerJoin(pushToken).on(member.id.eq(pushToken.member.id))
.leftJoin(member.auth, auth)
.leftJoin(memberNotification).on(memberNotification.member.id.eq(member.id))
.where(where.and(pushToken.deviceType.eq("ios")))
.fetch()
.toSet()
.chunked(500)
return mapOf("aos" to aosPushTokens, "ios" to iosPushTokens)
}
override fun getMemberProfile(memberId: Long, myMemberId: Long): GetMemberProfileResponse {