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

카테고리별 푸시 on/off #341

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open

Conversation

SeonghaeJo
Copy link
Contributor

push_opt_out DB collection 추가

  • opt-out은 GPT가 추천해준 이름인데 "기본적으로 활성화되어 있지만, 사용자가 '거부'해서 제외할 수 있는 방식"을 의미한다고 합니다 (opt-in은 반대로 "기본적으로 비활성화되어 있지만, 사용자가 '동의'해야 활성화되는 방식"을 의미한다고 하네요)
  • 기본적으로는 모든 카테고리의 푸시가 활성화되어 있고 push_opt_out에 (user_id, push_category)를 추가하면 해당 카테고리의 푸시를 비활성화하는 방식입니다.
  • 68bd80b

기존 푸시 전송 로직 수정

  • 푸시 카테고리는 일단 NORMAL, 강의 업데이트, 빈자리알림만 있습니다.
  • NORMAL이면 on/off 설정을 따로 고려하지 않습니다.
  • 강의 업데이트는 SugangSnuNotificationService에서 반영됩니다.
  • 빈자리알림은 VacancyNotifierService에서 발생하는데, 여기서 PushWithNotificationService를 사용하므로 해당 서비스를 수정하였습니다.
  • d13cd59, 8c67b4b

Push on/off api

  • PushPreferenceHandlerPushPreferenceService 중점으로 보시면 됩니다.
  • 2cf26d5

docs, 테스트는 시간날 때 진행할게요

@SeonghaeJo SeonghaeJo requested review from PFCJeong and a team as code owners February 9, 2025 14:44
@SeonghaeJo SeonghaeJo requested review from asp345, davin111 and Hank-Choi and removed request for a team February 9, 2025 14:44
Copy link
Member

@Hank-Choi Hank-Choi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

일단 첫번째 커밋 위주로 코멘트 남겼어요
데이터 모델이 조금 변경되면 좋을 것 같아요
이거 아마 나중에 개발할 때 여기저기서 가져다 쓰는 주요 컬렉션으로 동작할 것 같은데 현재는 사용하기 힘든 것 같습니다.
코멘트 반영하면 변경사항 좀 많아질 것 같긴한데 반영하면 더 코드가 쉬워질 것 같습니다.

Comment on lines 9 to 33
enum class PushCategory(
@JsonValue val value: Int,
) {
LECTURE_UPDATE(1),
VACANCY_NOTIFICATION(2),
;

companion object {
private val valueMap = PushCategory.entries.associateBy { e -> e.value }

fun getOfValue(value: Int): PushCategory? = valueMap[value]
}
}

@ReadingConverter
@Component
class PushCategoryReadConverter : Converter<Int, PushCategory> {
override fun convert(source: Int): PushCategory = PushCategory.getOfValue(source)!!
}

@WritingConverter
@Component
class PushCategoryWriteConverter : Converter<PushCategory, Int> {
override fun convert(source: PushCategory): Int = source.value
}
Copy link
Member

@Hank-Choi Hank-Choi Feb 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DB에 int 값으로 두면 파악하기 힘들다고 생각합니다.
걍 enum string 그대로 넣어도 될듯합니다.
원래 int로 되어있는건 구버전 대응용이에요

Comment on lines 10 to 18
@Document(collection = "push_opt_out")
@CompoundIndex(def = "{ 'user_id': 1, 'push_category': 1 }")
data class PushOptOut(
@Id
val id: String? = null,
@Indexed
@Field("user_id", targetType = FieldType.OBJECT_ID)
val userId: String,
@Field("push_category")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

그리고 DB 필드, 컬렉션명도 camel로 명명하자고 얘기한적 있긴 합니다. #70 (comment)
snake case 로 된건 다 옛날 옛적 컬렉션, 필드에요

Comment on lines +12 to +21
data class PushOptOut(
@Id
val id: String? = null,
@Indexed
@Field("user_id", targetType = FieldType.OBJECT_ID)
val userId: String,
@Field("push_category")
@Indexed
val pushCategory: PushCategory,
)
Copy link
Member

@Hank-Choi Hank-Choi Feb 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

row 하나로 유저의 모든 설정값을 보면 좋을 것 같은데 현재는 좀 RDB스러운 접근이라고 생각합니다.
개인적으론 해당 컬렉션을 조회할 때 바로 어떤 유저가 어떤 푸시를 키고 껐는지 알 수 있었으면 좋겠습니다.
아래처럼 되면 좋을 것 같아요
ex)

{
    "userId": "abcdefg123123",
    "pushSetting": [
        {
            "category": "LECTURE_UPDATE",
            "enable": true
        },
        {
            "category": "VACANCY_NOTIFICATION",
            "enable": false
        },
        ...
    ]
}

Comment on lines +83 to +92

override suspend fun sendCategoricalPush(
pushMessage: PushMessage,
userId: String,
pushCategory: PushCategory,
) {
if (pushCategory == PushCategory.NORMAL || !pushOptOutRepository.existsByUserIdAndPushCategory(userId, pushCategory)) {
sendPush(pushMessage, userId)
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PushService가 PushCategory에 대해 알 필요가 있을까요?
PushPreferenceService가 있는 것 같은데 유저 필터링은 거기서 해결해도 될 것 같아요

Comment on lines +9 to +11
enum class PushCategory(
@JsonValue val value: Int,
) {
Copy link
Member

@Hank-Choi Hank-Choi Feb 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 PushCategory라는 이름이 헷갈리네요
NotificationType이랑 거의 비슷해서 헷갈려요

유저가 설정할 수 있는 값이라는 PushPreference같은 느낌이 이름에 같이 들어갔으면 좋겠습니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants