fix deleting head account amo

This commit is contained in:
Pavel 2024-06-02 16:44:58 +03:00
parent e5e60e2ee2
commit 53769438ba

@ -108,20 +108,6 @@ func (m *Methods) CheckUsers(ctx context.Context, allTokens []model.Token) error
}
for _, user := range users {
if user.ID == mainAccount.AmoID {
err := m.repo.AmoRepo.CheckMainUser(ctx, model.User{
Name: user.Name,
Role: int32(user.Rights.RoleID),
Group: int32(user.Rights.GroupID),
Email: user.Email,
AmoID: user.ID,
})
if err != nil {
m.logger.Error("error update main user data in db", zap.Error(err))
return err
}
}
usersForUpdateAndCreate = append(usersForUpdateAndCreate, model.User{
AmoID: user.ID,
Name: user.FullName,
@ -134,6 +120,11 @@ func (m *Methods) CheckUsers(ctx context.Context, allTokens []model.Token) error
var deletedUserIDs []int64
for _, currentUserUser := range currentUserUsers {
// todo костыль нужно главный аккаунт выносить в отдельную таблицу - например companyAmo
if currentUserUser.AmoID == mainAccount.AmoID {
continue
}
found := false
for _, user := range users {
if currentUserUser.AmoID == user.ID {