feat: notification service
This commit is contained in:
@@ -0,0 +1,162 @@
|
||||
package notificationintent
|
||||
|
||||
// GeoReviewRecommendedPayload stores the normalized payload for
|
||||
// `geo.review_recommended`.
|
||||
type GeoReviewRecommendedPayload struct {
|
||||
UserID string `json:"user_id"`
|
||||
UserEmail string `json:"user_email"`
|
||||
ObservedCountry string `json:"observed_country"`
|
||||
UsualConnectionCountry string `json:"usual_connection_country"`
|
||||
ReviewReason string `json:"review_reason"`
|
||||
}
|
||||
|
||||
// GameTurnReadyPayload stores the normalized payload for `game.turn.ready`.
|
||||
type GameTurnReadyPayload struct {
|
||||
GameID string `json:"game_id"`
|
||||
GameName string `json:"game_name"`
|
||||
TurnNumber int64 `json:"turn_number"`
|
||||
}
|
||||
|
||||
// GameFinishedPayload stores the normalized payload for `game.finished`.
|
||||
type GameFinishedPayload struct {
|
||||
GameID string `json:"game_id"`
|
||||
GameName string `json:"game_name"`
|
||||
FinalTurnNumber int64 `json:"final_turn_number"`
|
||||
}
|
||||
|
||||
// GameGenerationFailedPayload stores the normalized payload for
|
||||
// `game.generation_failed`.
|
||||
type GameGenerationFailedPayload struct {
|
||||
GameID string `json:"game_id"`
|
||||
GameName string `json:"game_name"`
|
||||
FailureReason string `json:"failure_reason"`
|
||||
}
|
||||
|
||||
// LobbyRuntimePausedAfterStartPayload stores the normalized payload for
|
||||
// `lobby.runtime_paused_after_start`.
|
||||
type LobbyRuntimePausedAfterStartPayload struct {
|
||||
GameID string `json:"game_id"`
|
||||
GameName string `json:"game_name"`
|
||||
}
|
||||
|
||||
// LobbyApplicationSubmittedPayload stores the normalized payload for
|
||||
// `lobby.application.submitted`.
|
||||
type LobbyApplicationSubmittedPayload struct {
|
||||
GameID string `json:"game_id"`
|
||||
GameName string `json:"game_name"`
|
||||
ApplicantUserID string `json:"applicant_user_id"`
|
||||
ApplicantName string `json:"applicant_name"`
|
||||
}
|
||||
|
||||
// LobbyMembershipApprovedPayload stores the normalized payload for
|
||||
// `lobby.membership.approved`.
|
||||
type LobbyMembershipApprovedPayload struct {
|
||||
GameID string `json:"game_id"`
|
||||
GameName string `json:"game_name"`
|
||||
}
|
||||
|
||||
// LobbyMembershipRejectedPayload stores the normalized payload for
|
||||
// `lobby.membership.rejected`.
|
||||
type LobbyMembershipRejectedPayload struct {
|
||||
GameID string `json:"game_id"`
|
||||
GameName string `json:"game_name"`
|
||||
}
|
||||
|
||||
// LobbyInviteCreatedPayload stores the normalized payload for
|
||||
// `lobby.invite.created`.
|
||||
type LobbyInviteCreatedPayload struct {
|
||||
GameID string `json:"game_id"`
|
||||
GameName string `json:"game_name"`
|
||||
InviterUserID string `json:"inviter_user_id"`
|
||||
InviterName string `json:"inviter_name"`
|
||||
}
|
||||
|
||||
// LobbyInviteRedeemedPayload stores the normalized payload for
|
||||
// `lobby.invite.redeemed`.
|
||||
type LobbyInviteRedeemedPayload struct {
|
||||
GameID string `json:"game_id"`
|
||||
GameName string `json:"game_name"`
|
||||
InviteeUserID string `json:"invitee_user_id"`
|
||||
InviteeName string `json:"invitee_name"`
|
||||
}
|
||||
|
||||
// LobbyInviteExpiredPayload stores the normalized payload for
|
||||
// `lobby.invite.expired`.
|
||||
type LobbyInviteExpiredPayload struct {
|
||||
GameID string `json:"game_id"`
|
||||
GameName string `json:"game_name"`
|
||||
InviteeUserID string `json:"invitee_user_id"`
|
||||
InviteeName string `json:"invitee_name"`
|
||||
}
|
||||
|
||||
// NewGeoReviewRecommendedIntent builds the admin-email intent published by Geo
|
||||
// Profile Service when a user becomes review-worthy.
|
||||
func NewGeoReviewRecommendedIntent(metadata Metadata, payload GeoReviewRecommendedPayload) (Intent, error) {
|
||||
return newIntent(NotificationTypeGeoReviewRecommended, ProducerGeoProfile, AudienceKindAdminEmail, nil, metadata, payload)
|
||||
}
|
||||
|
||||
// NewGameTurnReadyIntent builds the user-targeted intent published by Game
|
||||
// Master when a new turn is ready for active accepted participants.
|
||||
func NewGameTurnReadyIntent(metadata Metadata, recipientUserIDs []string, payload GameTurnReadyPayload) (Intent, error) {
|
||||
return newIntent(NotificationTypeGameTurnReady, ProducerGameMaster, AudienceKindUser, recipientUserIDs, metadata, payload)
|
||||
}
|
||||
|
||||
// NewGameFinishedIntent builds the user-targeted intent published by Game
|
||||
// Master when a running game finishes.
|
||||
func NewGameFinishedIntent(metadata Metadata, recipientUserIDs []string, payload GameFinishedPayload) (Intent, error) {
|
||||
return newIntent(NotificationTypeGameFinished, ProducerGameMaster, AudienceKindUser, recipientUserIDs, metadata, payload)
|
||||
}
|
||||
|
||||
// NewGameGenerationFailedIntent builds the admin-email intent published by
|
||||
// Game Master when turn generation fails.
|
||||
func NewGameGenerationFailedIntent(metadata Metadata, payload GameGenerationFailedPayload) (Intent, error) {
|
||||
return newIntent(NotificationTypeGameGenerationFailed, ProducerGameMaster, AudienceKindAdminEmail, nil, metadata, payload)
|
||||
}
|
||||
|
||||
// NewLobbyRuntimePausedAfterStartIntent builds the admin-email intent
|
||||
// published by Game Lobby when a game is paused after runtime startup.
|
||||
func NewLobbyRuntimePausedAfterStartIntent(metadata Metadata, payload LobbyRuntimePausedAfterStartPayload) (Intent, error) {
|
||||
return newIntent(NotificationTypeLobbyRuntimePausedAfterStart, ProducerGameLobby, AudienceKindAdminEmail, nil, metadata, payload)
|
||||
}
|
||||
|
||||
// NewPrivateLobbyApplicationSubmittedIntent builds the private-game owner
|
||||
// intent published by Game Lobby when an application is submitted.
|
||||
func NewPrivateLobbyApplicationSubmittedIntent(metadata Metadata, ownerUserID string, payload LobbyApplicationSubmittedPayload) (Intent, error) {
|
||||
return newIntent(NotificationTypeLobbyApplicationSubmitted, ProducerGameLobby, AudienceKindUser, []string{ownerUserID}, metadata, payload)
|
||||
}
|
||||
|
||||
// NewPublicLobbyApplicationSubmittedIntent builds the public-game admin-email
|
||||
// intent published by Game Lobby when an application is submitted.
|
||||
func NewPublicLobbyApplicationSubmittedIntent(metadata Metadata, payload LobbyApplicationSubmittedPayload) (Intent, error) {
|
||||
return newIntent(NotificationTypeLobbyApplicationSubmitted, ProducerGameLobby, AudienceKindAdminEmail, nil, metadata, payload)
|
||||
}
|
||||
|
||||
// NewLobbyMembershipApprovedIntent builds the applicant-user intent published
|
||||
// by Game Lobby when membership is approved.
|
||||
func NewLobbyMembershipApprovedIntent(metadata Metadata, applicantUserID string, payload LobbyMembershipApprovedPayload) (Intent, error) {
|
||||
return newIntent(NotificationTypeLobbyMembershipApproved, ProducerGameLobby, AudienceKindUser, []string{applicantUserID}, metadata, payload)
|
||||
}
|
||||
|
||||
// NewLobbyMembershipRejectedIntent builds the applicant-user intent published
|
||||
// by Game Lobby when membership is rejected.
|
||||
func NewLobbyMembershipRejectedIntent(metadata Metadata, applicantUserID string, payload LobbyMembershipRejectedPayload) (Intent, error) {
|
||||
return newIntent(NotificationTypeLobbyMembershipRejected, ProducerGameLobby, AudienceKindUser, []string{applicantUserID}, metadata, payload)
|
||||
}
|
||||
|
||||
// NewLobbyInviteCreatedIntent builds the invited-user intent published by Game
|
||||
// Lobby when a private-game invite is created.
|
||||
func NewLobbyInviteCreatedIntent(metadata Metadata, invitedUserID string, payload LobbyInviteCreatedPayload) (Intent, error) {
|
||||
return newIntent(NotificationTypeLobbyInviteCreated, ProducerGameLobby, AudienceKindUser, []string{invitedUserID}, metadata, payload)
|
||||
}
|
||||
|
||||
// NewLobbyInviteRedeemedIntent builds the private-game owner intent published
|
||||
// by Game Lobby when an invite is redeemed.
|
||||
func NewLobbyInviteRedeemedIntent(metadata Metadata, ownerUserID string, payload LobbyInviteRedeemedPayload) (Intent, error) {
|
||||
return newIntent(NotificationTypeLobbyInviteRedeemed, ProducerGameLobby, AudienceKindUser, []string{ownerUserID}, metadata, payload)
|
||||
}
|
||||
|
||||
// NewLobbyInviteExpiredIntent builds the private-game owner intent published
|
||||
// by Game Lobby when an invite expires.
|
||||
func NewLobbyInviteExpiredIntent(metadata Metadata, ownerUserID string, payload LobbyInviteExpiredPayload) (Intent, error) {
|
||||
return newIntent(NotificationTypeLobbyInviteExpired, ProducerGameLobby, AudienceKindUser, []string{ownerUserID}, metadata, payload)
|
||||
}
|
||||
Reference in New Issue
Block a user