diff --git a/server/action/src/commonMain/kotlin/com/zegreatrob/coupling/server/action/connection/ConnectPartyUserCommand.kt b/server/action/src/commonMain/kotlin/com/zegreatrob/coupling/server/action/connection/ConnectPartyUserCommand.kt index 1a38f783b0..57fab2a199 100644 --- a/server/action/src/commonMain/kotlin/com/zegreatrob/coupling/server/action/connection/ConnectPartyUserCommand.kt +++ b/server/action/src/commonMain/kotlin/com/zegreatrob/coupling/server/action/connection/ConnectPartyUserCommand.kt @@ -2,21 +2,18 @@ package com.zegreatrob.coupling.server.action.connection import com.zegreatrob.coupling.action.valueOrNull import com.zegreatrob.coupling.model.CouplingConnection -import com.zegreatrob.coupling.model.CouplingSocketMessage import com.zegreatrob.coupling.model.party.PartyId import com.zegreatrob.coupling.model.player.Player import com.zegreatrob.coupling.model.user.CurrentUserProvider import com.zegreatrob.coupling.server.action.user.UserIsAuthorizedWithDataAction -import com.zegreatrob.coupling.server.action.user.UserIsAuthorizedWithDataActionDispatcher -import com.zegreatrob.testmints.action.async.SimpleSuspendAction +import com.zegreatrob.testmints.action.annotation.ActionMint import com.zegreatrob.testmints.action.async.SuspendActionExecuteSyntax -data class ConnectPartyUserCommand(val partyId: PartyId, val connectionId: String) : - SimpleSuspendAction, CouplingSocketMessage>?> { - override val performFunc = link(Dispatcher::perform) +@ActionMint +data class ConnectPartyUserCommand(val partyId: PartyId, val connectionId: String) { interface Dispatcher : - UserIsAuthorizedWithDataActionDispatcher, + UserIsAuthorizedWithDataAction.Dispatcher, SuspendActionExecuteSyntax, CouplingConnectionSaveSyntax, CouplingConnectionGetSyntax, diff --git a/server/action/src/commonMain/kotlin/com/zegreatrob/coupling/server/action/user/UserIsAuthorizedWithDataAction.kt b/server/action/src/commonMain/kotlin/com/zegreatrob/coupling/server/action/user/UserIsAuthorizedWithDataAction.kt index 3ec4c4e916..3e939afe2b 100644 --- a/server/action/src/commonMain/kotlin/com/zegreatrob/coupling/server/action/user/UserIsAuthorizedWithDataAction.kt +++ b/server/action/src/commonMain/kotlin/com/zegreatrob/coupling/server/action/user/UserIsAuthorizedWithDataAction.kt @@ -15,38 +15,38 @@ import kotlinx.coroutines.async import kotlinx.coroutines.coroutineScope data class UserIsAuthorizedWithDataAction(val partyId: PartyId) : - SimpleSuspendResultAction>?> { - override val performFunc = link(UserIsAuthorizedWithDataActionDispatcher::perform) -} + SimpleSuspendResultAction>?> { + override val performFunc = link(Dispatcher::perform) -interface UserIsAuthorizedWithDataActionDispatcher : - UserAuthenticatedPartyIdSyntax, - UserPlayerIdsSyntax, - PartyIdGetSyntax, - PartyPlayersSyntax { - override val playerRepository: PlayerEmailRepository + interface Dispatcher : + UserAuthenticatedPartyIdSyntax, + UserPlayerIdsSyntax, + PartyIdGetSyntax, + PartyPlayersSyntax { + override val playerRepository: PlayerEmailRepository - suspend fun perform(action: UserIsAuthorizedWithDataAction) = action.skdjflskdjf().successResult() + suspend fun perform(action: UserIsAuthorizedWithDataAction) = action.skdjflskdjf().successResult() - private suspend fun UserIsAuthorizedWithDataAction.skdjflskdjf(): Pair>? { - val contains = getUserPlayerIds() - .authenticatedPartyIds() - .contains(partyId) + private suspend fun UserIsAuthorizedWithDataAction.skdjflskdjf(): Pair>? { + val contains = getUserPlayerIds() + .authenticatedPartyIds() + .contains(partyId) - if (contains) { - val (party, players) = loadPartyAndPlayers() + if (contains) { + val (party, players) = loadPartyAndPlayers() - if (party != null) { - return party to players + if (party != null) { + return party to players + } } + return null } - return null - } - private suspend fun UserIsAuthorizedWithDataAction.loadPartyAndPlayers() = coroutineScope { - await( - async { partyId.get() }, - async { partyId.getPlayerList() }, - ) + private suspend fun UserIsAuthorizedWithDataAction.loadPartyAndPlayers() = coroutineScope { + await( + async { partyId.get() }, + async { partyId.getPlayerList() }, + ) + } } }