KotlinIntermediate
Kotlin Null-Safety & Data Class Cleanup
src/services/UserProfileService.kt
0.0s/ 38s0/ 42
Press Enter to start
1package com.vimhero.account2 3data class UserProfile(4 val id: String,5 val email: String,6 val displayName: String?,7 val status: String = "PENDING_VERIFICATION",8 val tier: String = "FREE"9)10 11class UserProfileService(12 private val repository: ProfileRepository13) {14 fun activateProfile(userId: String): UserProfile {15 val existing = repository.findById(userId)16 ?: throw IllegalArgumentException("User not found")17 println("DEBUG: activating profile for " + existing.email)18 val resolvedName = existing.displayName ?: "Guest"19 val updated = existing.copy(20 displayName = resolvedName,21 status = "ACTIVE"22 )23 return repository.save(updated)24 }25 26 fun normalizeTier(rawTier: String?): String {27 // TODO: remove legacy tier fallback after migration28 val cleaned = rawTier?.trim()?.uppercase()29 return if (cleaned.isNullOrEmpty()) "FREE" else cleaned30 }31}-L7 val status: String = "PENDING_VERIFICATION",
+L7 val status: String = "ACTIVE",
-L17 println("DEBUG: activating profile for " + existing.email)
-L18 val resolvedName = existing.displayName ?: "Guest"
+L17 val resolvedName = existing.displayName ?: "Anonymous"
-L27 // TODO: remove legacy tier fallback after migration