fix: send preferred login name on init user mail (#3105)

* fix: send preferred login name on init user

* trigger gh actions

Co-authored-by: Livio Amstutz <livio.a@gmail.com>
This commit is contained in:
Fabi 2022-01-24 15:22:27 +01:00 committed by GitHub
parent a824312be3
commit b64b5d89ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 34 deletions

View File

@ -61,7 +61,7 @@ func Register(configs Configs, bulkLimit, errorCount uint64, view *view.View, es
func (configs Configs) cycleDuration(viewModel string) time.Duration {
c, ok := configs[viewModel]
if !ok {
return 3 * time.Minute
return 1 * time.Minute
}
return c.MinimumCycleDuration.Duration
}

View File

@ -436,25 +436,5 @@ func (n *Notification) getTranslatorWithOrgTexts(orgID, textType string) (*i18n.
}
func (n *Notification) getUserByID(userID string) (*model.NotifyUser, error) {
user, usrErr := n.view.NotifyUserByID(userID)
if usrErr != nil && !errors.IsNotFound(usrErr) {
return nil, usrErr
}
if user == nil {
user = &model.NotifyUser{}
}
events, err := n.getUserEvents(userID, user.Sequence)
if err != nil {
return user, usrErr
}
userCopy := *user
for _, event := range events {
if err := userCopy.AppendEvent(event); err != nil {
return user, nil
}
}
if userCopy.State == int32(model.UserStateDeleted) {
return nil, errors.ThrowNotFound(nil, "HANDLER-3n8fs", "Errors.User.NotFound")
}
return &userCopy, nil
return n.view.NotifyUserByID(userID)
}

View File

@ -196,13 +196,11 @@ func (u *NotifyUser) fillPreferredLoginNamesOnOrgUsers(event *es_models.Event) e
if err != nil {
return err
}
policy := new(query2.OrgIAMPolicy)
if policy == nil {
policy, err = u.getDefaultOrgIAMPolicy(context.Background())
policy, err := u.getDefaultOrgIAMPolicy(context.Background())
if err != nil {
return err
}
}
if !policy.UserLoginMustBeDomain {
return nil
}
@ -225,13 +223,11 @@ func (u *NotifyUser) fillLoginNames(user *view_model.NotifyUser) (err error) {
if err != nil {
return err
}
policy := new(query2.OrgIAMPolicy)
if policy == nil {
policy, err = u.getDefaultOrgIAMPolicy(context.Background())
policy, err := u.getDefaultOrgIAMPolicy(context.Background())
if err != nil {
return err
}
}
user.SetLoginNames(policy, org.Domains)
user.PreferredLoginName = user.GenerateLoginName(org.GetPrimaryDomain().Domain, policy.UserLoginMustBeDomain)
return nil