Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 15 additions & 1 deletion apps/flipcash/core/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,9 @@
<string name="error_title_imageNotSupported">This Image is Not Supported</string>
<string name="error_description_imageNotSupported">Try a different image format</string>

<string name="error_title_imageTooLarge">This Image is Too Large</string>
<string name="error_description_imageTooLarge">Try a smaller image</string>

<string name="error_title_descriptionNotAllowed">This Description is Not Allowed</string>
<string name="error_description_descriptionNotAllowed">Try a different currency description</string>

Expand Down Expand Up @@ -865,8 +868,19 @@
<string name="hint_profileName">Your Name</string>
<string name="error_title_profileNameNotAllowed">This Name is Not Allowed</string>
<string name="error_description_profileNameNotAllowed">Try a different name</string>
<string name="error_description_profileNameNotAllowedFlaggedOther">AI flagged this name. Please try a different name. If you think the name was rejected in error please DM @flipcash on X</string>
<string name="error_description_profileNameNotAllowedFlaggedNsfw">AI flagged this name as sexually explicit. Please try a different name. If you think the name was rejected in error please DM @flipcash on X</string>
<string name="error_description_profileNameNotAllowedFlaggedImpersonation">AI flagged this name for impersonation. Please try a different name. If you think the name was rejected in error please DM @flipcash on X</string>
<string name="error_description_profileNameNotAllowedFlaggedMisleading">AI flagged this name as misleading. Please try a different name. If you think the name was rejected in error please DM @flipcash on X</string>
<string name="error_description_profileNameNotAllowedFlaggedSpam">AI flagged this name as spam. Please try a different name. If you think the name was rejected in error please DM @flipcash on X</string>
<string name="error_title_profilePhotoNotAllowed">This Photo is Not Allowed</string>
<string name="error_description_profilePhotoNotAllowedFlaggedOther">AI flagged this photo. Please try a different photo. If you think the photo was rejected in error please DM @flipcash on X</string>
<string name="error_description_profilePhotoNotAllowedFlaggedNsfw">AI flagged this photo as sexually explicit. Please try a different photo. If you think the photo was rejected in error please DM @flipcash on X</string>
<string name="error_description_profilePhotoNotAllowedFlaggedImpersonation">AI flagged this photo for impersonation. Please try a different photo. If you think the photo was rejected in error please DM @flipcash on X</string>
<string name="error_description_profilePhotoNotAllowedFlaggedMisleading">AI flagged this photo as misleading. Please try a different photo. If you think the photo was rejected in error please DM @flipcash on X</string>
<string name="error_description_profilePhotoNotAllowedFlaggedSpam">AI flagged this photo as spam. Please try a different photo. If you think the photo was rejected in error please DM @flipcash on X</string>
<string name="title_profileImageSelection">Upload Your Photo</string>
<string name="subtitle_profileImageSelection">CThis photo will be shown when receiving tips</string>
<string name="subtitle_profileImageSelection">This photo will be shown when receiving tips</string>
<string name="placeholder_profileDisplayName">Your Name</string>
<string name="subtitle_profileImageRecommended">500x500 Recommended</string>
<string name="title_myTipCard">My Tip Card</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.flipcash.features.userprofile.R
import com.flipcash.services.controllers.ModerationController
import com.flipcash.services.controllers.ProfileController
import com.flipcash.services.models.ModerationResult
import com.flipcash.services.models.SetDisplayNameError
import com.flipcash.services.models.TextModerationError
import com.flipcash.services.user.UserManager
import com.getcode.manager.BottomBarManager
Expand Down Expand Up @@ -69,16 +70,7 @@ class NameEntryViewModel @Inject constructor(
.filterIsInstance<Event.CheckName>()
.map { stateFlow.value.nameFieldState.text.toString() }
.onEach { dispatchEvent(Event.UpdateProcessingState(loading = true)) }
.map { moderationController.moderateText(it.trim()) }
.flatMapResult { result ->
when (result.flaggedCategory) {
ModerationResult.FlaggedCategory.NONE -> {
Result.success(result.attestation)
}

else -> Result.failure(TextModerationError.Flagged(result.flaggedCategory))
}
}.flatMapResult {
.map {
profileController.setDisplayName(stateFlow.value.nameFieldState.text.toString())
}.onResult(
onSuccess = {
Expand All @@ -91,27 +83,68 @@ class NameEntryViewModel @Inject constructor(
},
onError = { cause ->
dispatchEvent(Event.UpdateProcessingState())
when (cause) {
is ValidationException,
is TextModerationError.Flagged,
is TextModerationError.Denied -> {
BottomBarManager.showAlert(
title = resources.getString(R.string.error_title_profileNameNotAllowed),
message = resources.getString(R.string.error_description_profileNameNotAllowed)
)
}

else -> {
BottomBarManager.showError(
title = resources.getString(R.string.error_title_nameCheckFailed),
message = resources.getString(R.string.error_description_nameCheckFailed),
)
}
}
handleNameSetFailure(cause)
}
).launchIn(viewModelScope)
}

private fun handleNameSetFailure(cause: Throwable) {
when (cause) {
is SetDisplayNameError.FailedModerated -> {
when (cause.category) {
ModerationResult.FlaggedCategory.NONE -> {
BottomBarManager.showAlert(
title = resources.getString(R.string.error_title_profileNameNotAllowed),
message = resources.getString(R.string.error_description_profileNameNotAllowed)
)
}
ModerationResult.FlaggedCategory.OTHER -> {
BottomBarManager.showAlert(
title = resources.getString(R.string.error_title_profileNameNotAllowed),
message = resources.getString(R.string.error_description_profileNameNotAllowedFlaggedOther)
)
}
ModerationResult.FlaggedCategory.NSFW -> {
BottomBarManager.showAlert(
title = resources.getString(R.string.error_title_profileNameNotAllowed),
message = resources.getString(R.string.error_description_profileNameNotAllowedFlaggedNsfw)
)
}
ModerationResult.FlaggedCategory.IMPERSONATION -> {
BottomBarManager.showAlert(
title = resources.getString(R.string.error_title_profileNameNotAllowed),
message = resources.getString(R.string.error_description_profileNameNotAllowedFlaggedImpersonation)
)
}
ModerationResult.FlaggedCategory.MISLEADING -> {
BottomBarManager.showAlert(
title = resources.getString(R.string.error_title_profileNameNotAllowed),
message = resources.getString(R.string.error_description_profileNameNotAllowedFlaggedMisleading)
)
}
ModerationResult.FlaggedCategory.SPAM -> {
BottomBarManager.showAlert(
title = resources.getString(R.string.error_title_profileNameNotAllowed),
message = resources.getString(R.string.error_description_profileNameNotAllowedFlaggedSpam)
)
}
}
}
is ValidationException -> {
BottomBarManager.showAlert(
title = resources.getString(R.string.error_title_profileNameNotAllowed),
message = resources.getString(R.string.error_description_profileNameNotAllowed)
)
}

else -> {
BottomBarManager.showError(
title = resources.getString(R.string.error_title_nameCheckFailed),
message = resources.getString(R.string.error_description_nameCheckFailed),
)
}
}
}
companion object {
private val updateStateForEvent: (Event) -> (State.() -> State) = { event ->
when (event) {
Expand Down
Loading
Loading