Add player profiles and community settings
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -65,6 +65,9 @@ func New(service *application.Service, store application.Store, hub *realtime.Hu
|
||||
api.Get("/api/me", s.me)
|
||||
api.Patch("/api/me/player", s.updateProfile)
|
||||
api.Get("/api/players", s.players)
|
||||
api.Get("/api/players/{playerID}", s.playerProfile)
|
||||
api.Get("/api/community/settings", s.communitySettings)
|
||||
api.Put("/api/community/settings", s.updateCommunitySettings)
|
||||
api.Get("/api/accounts", s.accounts)
|
||||
api.Patch("/api/accounts/{accountID}/moderator", s.setModerator)
|
||||
api.Get("/api/events", s.events)
|
||||
@@ -246,7 +249,8 @@ func (s *Server) me(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
func (s *Server) updateProfile(w http.ResponseWriter, r *http.Request) {
|
||||
var in struct {
|
||||
DisplayName string `json:"displayName"`
|
||||
DisplayName *string `json:"displayName"`
|
||||
BattleTag *string `json:"battleTag"`
|
||||
Ratings domain.Ratings `json:"ratings"`
|
||||
PreferredRoles []domain.Role `json:"preferredRoles"`
|
||||
PreferredPlayerIDs []string `json:"preferredPlayerIds"`
|
||||
@@ -256,7 +260,10 @@ func (s *Server) updateProfile(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
id := who(r)
|
||||
out, err := s.service.UpdateOwnProfile(r.Context(), id.account, id.player, in.DisplayName, in.Ratings, in.PreferredRoles, in.PreferredPlayerIDs, in.AvoidedPlayerIDs)
|
||||
out, err := s.service.UpdateOwnProfile(r.Context(), id.account, id.player, application.UpdateOwnProfileInput{
|
||||
DisplayName: in.DisplayName, BattleTag: in.BattleTag, Ratings: in.Ratings,
|
||||
PreferredRoles: in.PreferredRoles, PreferredPlayerIDs: in.PreferredPlayerIDs, AvoidedPlayerIDs: in.AvoidedPlayerIDs,
|
||||
})
|
||||
respond(w, out, err, http.StatusOK)
|
||||
}
|
||||
|
||||
@@ -265,6 +272,27 @@ func (s *Server) players(w http.ResponseWriter, r *http.Request) {
|
||||
respond(w, out, err, 200)
|
||||
}
|
||||
|
||||
func (s *Server) playerProfile(w http.ResponseWriter, r *http.Request) {
|
||||
out, err := s.service.GetPlayerProfile(r.Context(), chi.URLParam(r, "playerID"))
|
||||
respond(w, out, err, http.StatusOK)
|
||||
}
|
||||
|
||||
func (s *Server) communitySettings(w http.ResponseWriter, r *http.Request) {
|
||||
out, err := s.service.GetCommunitySettings(r.Context())
|
||||
respond(w, out, err, http.StatusOK)
|
||||
}
|
||||
|
||||
func (s *Server) updateCommunitySettings(w http.ResponseWriter, r *http.Request) {
|
||||
var input struct {
|
||||
DiscordInviteURL string `json:"discordInviteUrl"`
|
||||
}
|
||||
if !decode(w, r, &input) {
|
||||
return
|
||||
}
|
||||
out, err := s.service.UpdateCommunitySettings(r.Context(), who(r).account, input.DiscordInviteURL)
|
||||
respond(w, out, err, http.StatusOK)
|
||||
}
|
||||
|
||||
func (s *Server) accounts(w http.ResponseWriter, r *http.Request) {
|
||||
out, err := s.service.ListAccounts(r.Context(), who(r).account)
|
||||
respond(w, out, err, http.StatusOK)
|
||||
|
||||
Reference in New Issue
Block a user