Skip to content

Commit

Permalink
Mark as optional some poll related fields
Browse files Browse the repository at this point in the history
  • Loading branch information
JcMinarro committed Aug 9, 2024
1 parent bfaa857 commit 7bda8bc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ internal fun DownstreamPollDto.toDomain(currentUserId: UserId?): Poll {
options = options.map { it.toDomain() },
votingVisibility = voting_visibility.toVotingVisibility(),
enforceUniqueVote = enforce_unique_vote,
maxVotesAllowed = max_votes_allowed,
maxVotesAllowed = max_votes_allowed ?: 1,
allowUserSuggestedOptions = allow_user_suggested_options,
allowAnswers = allow_answers,
voteCountsByOption = vote_counts_by_option ?: emptyMap(),
Expand Down Expand Up @@ -86,8 +86,10 @@ internal fun DownstreamVoteDto.toDomain(currentUserId: UserId?): Vote = Vote(
*
* @return VotingVisibility
*/
private fun String.toVotingVisibility(): VotingVisibility = when (this) {
"public" -> VotingVisibility.PUBLIC
private fun String?.toVotingVisibility(): VotingVisibility = when (this) {
null,
"public",
-> VotingVisibility.PUBLIC
"anonymous" -> VotingVisibility.ANONYMOUS
else -> throw IllegalArgumentException("Unknown voting visibility: $this")
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ internal data class DownstreamVoteDto(
val created_at: Date,
val updated_at: Date,
val user: DownstreamUserDto?,
val user_id: String,
val user_id: String?,
)

/**
Expand Down Expand Up @@ -80,9 +80,9 @@ internal data class DownstreamPollDto(
val id: String,
val name: String,
val description: String,
val voting_visibility: String,
val voting_visibility: String?,
val enforce_unique_vote: Boolean,
val max_votes_allowed: Int,
val max_votes_allowed: Int?,
val allow_user_suggested_options: Boolean,
val allow_answers: Boolean,
val options: List<DownstreamOptionDto>,
Expand Down

0 comments on commit 7bda8bc

Please sign in to comment.