refac: stale test entries, failing web tests, Postgre backup bug, Hardcoded MySQL table count, Stale Postgre connection in test, own-scope visibility filter, GetAll ignoring its error, JSON tags in use-case types, 31 copies of DESKTOP_QUERY, ProfileView endpoint paths
This commit is contained in:
1 parent
efecdee200
commit
5d6f378fce
87 files changed
+696
-373
No files matched your search
@@ -98,7 +98,11 @@ func (g *CreateInviteUseCase) create(command CreateInviteCommand) (invite.Invite
|
||||
return invite.Invite{}, role.Role{}, err
|
||||
}
|
||||
|
||||
if g.emailHasAccount(email) {
|
||||
hasAccount, err := g.emailHasAccount(email)
|
||||
if err != nil {
|
||||
return invite.Invite{}, role.Role{}, err
|
||||
}
|
||||
if hasAccount {
|
||||
return invite.Invite{}, role.Role{}, invite.ErrEmailHasAccount
|
||||
}
|
||||
|
||||
@@ -133,17 +137,25 @@ func (g *CreateInviteUseCase) create(command CreateInviteCommand) (invite.Invite
|
||||
return createdInvite, assigned, nil
|
||||
}
|
||||
|
||||
func (g *CreateInviteUseCase) emailHasAccount(email string) bool {
|
||||
for _, existingUser := range g.userRepository.GetAll() {
|
||||
func (g *CreateInviteUseCase) emailHasAccount(email string) (bool, error) {
|
||||
users, err := g.userRepository.GetAll()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
for _, existingUser := range users {
|
||||
if strings.EqualFold(existingUser.Email, email) {
|
||||
return true
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
return false
|
||||
return false, nil
|
||||
}
|
||||
|
||||
func (g *CreateInviteUseCase) discardOpenInvite(email string, now time.Time) error {
|
||||
for _, existing := range g.inviteRepository.GetAll() {
|
||||
invites, err := g.inviteRepository.GetAll()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, existing := range invites {
|
||||
if existing.Email != email {
|
||||
continue
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user