Skip to content

Commit

Permalink
Merge pull request #4261 from nickmango/bug/signatory-event-email
Browse files Browse the repository at this point in the history
[#4247] Feature/Email and event logging
  • Loading branch information
nickmango authored Feb 27, 2024
2 parents fef4049 + 08161e9 commit b960023
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions cla-backend-go/v2/sign/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,22 @@ func (s *service) RequestCorporateSignature(ctx context.Context, lfUsername stri
log.WithFields(f).Warn("unable to request corporate signature - missing corporate documents in the CLA Group configuration")
return nil, ErrTemplateNotConfigured
}

var currentUserEmail string
log.WithFields(f).Debugf("Loading user by username: %s...", lfUsername)
userModel, userErr := usc.GetUserByUsername(lfUsername)
if userErr != nil {
return nil, userErr
}

if userModel != nil {
for _, email := range userModel.Emails {
if email != nil && *email.IsPrimary {
currentUserEmail = *email.EmailAddress
}
}
}

// Email flow
if input.SendAsEmail {
log.WithFields(f).Debugf("Sending request as an email to: %s...", input.AuthorityEmail.String())
Expand All @@ -307,20 +322,6 @@ func (s *service) RequestCorporateSignature(ctx context.Context, lfUsername stri
} else {
// Direct to DocuSign flow...

log.WithFields(f).Debugf("Loading user by username: %s...", lfUsername)
userModel, userErr := usc.GetUserByUsername(lfUsername)
if userErr != nil {
return nil, userErr
}

if userModel != nil {
for _, email := range userModel.Emails {
if email != nil && *email.IsPrimary {
currentUserEmail = *email.EmailAddress
}
}
}

err = prepareUserForSigning(ctx, currentUserEmail, utils.StringValue(input.CompanySfid), utils.StringValue(input.ProjectSfid), input.SigningEntityName)
if err != nil {
// Ignore conflict - role has already been assigned
Expand Down Expand Up @@ -1171,8 +1172,10 @@ func (s *service) SignedCorporateCallback(ctx context.Context, payload []byte, c
CompanyName: companyModel.CompanyName,
SignatoryName: getUserName(user),
},
CLAGroupID: projectID,
UserID: user.UserID,
CLAGroupID: projectID,
UserID: user.UserID,
CompanyID: companyID,
CompanySFID: companyModel.CompanyExternalID,
})

return nil
Expand Down

0 comments on commit b960023

Please sign in to comment.