Skip to content

Commit

Permalink
fix: team invite token displayed in game challenge
Browse files Browse the repository at this point in the history
  • Loading branch information
ElaBosak233 committed Apr 15, 2024
1 parent 5bde355 commit 3dce13c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions internal/model/team.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ type Team struct {
Users []*User `gorm:"many2many:user_teams;" json:"users,omitempty"` // The team's users.
}

func (t *Team) Simplify() {
t.InviteToken = ""
}

func (t *Team) BeforeDelete(db *gorm.DB) (err error) {
db.Table("user_teams").Where("team_id = ?", t.ID).Delete(&UserTeam{})
db.Table("game_teams").Where("team_id = ?", t.ID).Delete(&GameTeam{})
Expand Down
4 changes: 3 additions & 1 deletion internal/repository/game_challenge.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ func (t *GameChallengeRepository) Find(req request.GameChallengeFindRequest) (ga
Preload("User", func(db *gorm.DB) *gorm.DB {
return db.Select([]string{"id", "username", "nickname", "email"})
}).
Preload("Team").
Preload("Team", func(db *gorm.DB) *gorm.DB {
return db.Select([]string{"id", "name", "email"})
}).
Order("submissions.created_at ASC").
Where("status = ?", 2).
Where("game_id = ?", req.GameID).
Expand Down

0 comments on commit 3dce13c

Please sign in to comment.