feat: game lobby service
This commit is contained in:
@@ -82,6 +82,13 @@ const (
|
||||
// `lobby.membership.rejected` notification.
|
||||
NotificationTypeLobbyMembershipRejected NotificationType = "lobby.membership.rejected"
|
||||
|
||||
// NotificationTypeLobbyMembershipBlocked identifies the
|
||||
// `lobby.membership.blocked` notification published by Game Lobby
|
||||
// to the private-game owner when an active membership is blocked
|
||||
// by the user-lifecycle cascade reacting to a `permanent_block` or
|
||||
// `DeleteUser` event.
|
||||
NotificationTypeLobbyMembershipBlocked NotificationType = "lobby.membership.blocked"
|
||||
|
||||
// NotificationTypeLobbyInviteCreated identifies the
|
||||
// `lobby.invite.created` notification.
|
||||
NotificationTypeLobbyInviteCreated NotificationType = "lobby.invite.created"
|
||||
@@ -93,6 +100,24 @@ const (
|
||||
// NotificationTypeLobbyInviteExpired identifies the
|
||||
// `lobby.invite.expired` notification.
|
||||
NotificationTypeLobbyInviteExpired NotificationType = "lobby.invite.expired"
|
||||
|
||||
// NotificationTypeLobbyRaceNameRegistrationEligible identifies the
|
||||
// `lobby.race_name.registration_eligible` notification published by
|
||||
// Game Lobby when capability evaluation at game finish promotes a
|
||||
// reservation to `pending_registration`.
|
||||
NotificationTypeLobbyRaceNameRegistrationEligible NotificationType = "lobby.race_name.registration_eligible"
|
||||
|
||||
// NotificationTypeLobbyRaceNameRegistered identifies the
|
||||
// `lobby.race_name.registered` notification published by Game Lobby
|
||||
// when a user converts a `pending_registration` into a permanent
|
||||
// registered race name.
|
||||
NotificationTypeLobbyRaceNameRegistered NotificationType = "lobby.race_name.registered"
|
||||
|
||||
// NotificationTypeLobbyRaceNameRegistrationDenied identifies the
|
||||
// `lobby.race_name.registration_denied` notification published by
|
||||
// Game Lobby when capability evaluation at game finish releases a
|
||||
// reservation because the member did not meet the capability rule.
|
||||
NotificationTypeLobbyRaceNameRegistrationDenied NotificationType = "lobby.race_name.registration_denied"
|
||||
)
|
||||
|
||||
// String returns the wire value for notificationType.
|
||||
@@ -111,9 +136,13 @@ func (notificationType NotificationType) IsKnown() bool {
|
||||
NotificationTypeLobbyApplicationSubmitted,
|
||||
NotificationTypeLobbyMembershipApproved,
|
||||
NotificationTypeLobbyMembershipRejected,
|
||||
NotificationTypeLobbyMembershipBlocked,
|
||||
NotificationTypeLobbyInviteCreated,
|
||||
NotificationTypeLobbyInviteRedeemed,
|
||||
NotificationTypeLobbyInviteExpired:
|
||||
NotificationTypeLobbyInviteExpired,
|
||||
NotificationTypeLobbyRaceNameRegistrationEligible,
|
||||
NotificationTypeLobbyRaceNameRegistered,
|
||||
NotificationTypeLobbyRaceNameRegistrationDenied:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
@@ -133,9 +162,13 @@ func (notificationType NotificationType) ExpectedProducer() Producer {
|
||||
NotificationTypeLobbyApplicationSubmitted,
|
||||
NotificationTypeLobbyMembershipApproved,
|
||||
NotificationTypeLobbyMembershipRejected,
|
||||
NotificationTypeLobbyMembershipBlocked,
|
||||
NotificationTypeLobbyInviteCreated,
|
||||
NotificationTypeLobbyInviteRedeemed,
|
||||
NotificationTypeLobbyInviteExpired:
|
||||
NotificationTypeLobbyInviteExpired,
|
||||
NotificationTypeLobbyRaceNameRegistrationEligible,
|
||||
NotificationTypeLobbyRaceNameRegistered,
|
||||
NotificationTypeLobbyRaceNameRegistrationDenied:
|
||||
return ProducerGameLobby
|
||||
default:
|
||||
return ""
|
||||
@@ -169,7 +202,8 @@ func (notificationType NotificationType) SupportsChannel(audienceKind AudienceKi
|
||||
return channel == ChannelEmail
|
||||
}
|
||||
return channel == ChannelPush || channel == ChannelEmail
|
||||
case NotificationTypeLobbyInviteExpired:
|
||||
case NotificationTypeLobbyInviteExpired,
|
||||
NotificationTypeLobbyRaceNameRegistrationDenied:
|
||||
return audienceKind == AudienceKindUser && channel == ChannelEmail
|
||||
default:
|
||||
return audienceKind == AudienceKindUser && (channel == ChannelPush || channel == ChannelEmail)
|
||||
@@ -752,10 +786,21 @@ func validatePayloadObject(notificationType NotificationType, payload map[string
|
||||
return validateStringFields(payload, "game_id", "game_name", "applicant_user_id", "applicant_name")
|
||||
case NotificationTypeLobbyMembershipApproved, NotificationTypeLobbyMembershipRejected:
|
||||
return validateStringFields(payload, "game_id", "game_name")
|
||||
case NotificationTypeLobbyMembershipBlocked:
|
||||
return validateStringFields(payload, "game_id", "game_name", "membership_user_id", "membership_user_name", "reason")
|
||||
case NotificationTypeLobbyInviteCreated:
|
||||
return validateStringFields(payload, "game_id", "game_name", "inviter_user_id", "inviter_name")
|
||||
case NotificationTypeLobbyInviteRedeemed, NotificationTypeLobbyInviteExpired:
|
||||
return validateStringFields(payload, "game_id", "game_name", "invitee_user_id", "invitee_name")
|
||||
case NotificationTypeLobbyRaceNameRegistrationEligible:
|
||||
if err := validateStringFields(payload, "game_id", "game_name", "race_name"); err != nil {
|
||||
return err
|
||||
}
|
||||
return validatePositiveIntFields(payload, "eligible_until_ms")
|
||||
case NotificationTypeLobbyRaceNameRegistered:
|
||||
return validateStringFields(payload, "race_name")
|
||||
case NotificationTypeLobbyRaceNameRegistrationDenied:
|
||||
return validateStringFields(payload, "game_id", "game_name", "race_name", "reason")
|
||||
default:
|
||||
return fmt.Errorf("payload_json notification type %q is unsupported", notificationType)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user