From 08161e92e1435777db042c77705aa13bb4d8f7da Mon Sep 17 00:00:00 2001 From: Harold Wanyama Date: Wed, 28 Feb 2024 00:29:50 +0300 Subject: [PATCH] [#4247] Feature/Email and event logging - Added the right cla manager email post signing - Associated SFcompany with the event Signed-off-by: Harold Wanyama --- cla-backend-go/v2/sign/service.go | 35 +++++++++++++++++-------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/cla-backend-go/v2/sign/service.go b/cla-backend-go/v2/sign/service.go index bd360e2a4..03ffb2fc1 100644 --- a/cla-backend-go/v2/sign/service.go +++ b/cla-backend-go/v2/sign/service.go @@ -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()) @@ -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 @@ -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