Skip to content

Commit

Permalink
Merge pull request #4251 from nickmango/bug/docusign-email-notification
Browse files Browse the repository at this point in the history
[#4249] Bug/Email & Event Dispatch Docusign
  • Loading branch information
nickmango authored Feb 20, 2024
2 parents d7dcb83 + 7181269 commit 0ab73a1
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 20 deletions.
11 changes: 8 additions & 3 deletions cla-backend-go/events/event_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -2754,9 +2754,14 @@ func (ed *SignatureAutoCreateECLAUpdatedEventData) GetEventSummaryString(args *L
}

func (ed *IndividualSignatureSignedEventData) GetEventSummaryString(args *LogEventArgs) (string, bool) {
data := fmt.Sprintf("The user %s signed an individual CLA for project %s with project ID: %s",
args.LfUsername, ed.ProjectName, ed.ProjectID)
return data, false
data := fmt.Sprintf("The user %s signed an individual CLA", args.LfUsername)
if ed.ProjectName != "" {
data = data + fmt.Sprintf(" for the project %s", ed.ProjectName)
}
if ed.ProjectID != "" {
data = data + fmt.Sprintf(" with project ID: %s", ed.ProjectID)
}
return data + ".", false
}

func (ed *IndividualSignatureSignedEventData) GetEventDetailsString(args *LogEventArgs) (string, bool) {
Expand Down
50 changes: 33 additions & 17 deletions cla-backend-go/v2/sign/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ func NewService(apiURL, v1API string, compRepo company.IRepository, projectRepo
gitlabActivityService: gitlabActivityService,
gitlabApp: gitlabApp,
gerritService: gerritService,
eventsService: eventsService,
}
}

Expand Down Expand Up @@ -522,7 +523,7 @@ func (s *service) SignedIndividualCallbackGithub(ctx context.Context, payload []

recipients := []string{utils.GetBestEmail(claUser)}

body, err := emails.RenderDocumentSignedTemplate(s.emailTemplateService, claGroup.Version, claGroup.ProjectID, emailParams)
body, err := emails.RenderDocumentSignedTemplate(s.emailTemplateService, claGroup.Version, claGroup.ProjectExternalID, emailParams)
if err != nil {
log.WithFields(f).WithError(err).Warnf("unable to render document signed template for project version: %s, project ID: %s", claGroup.Version, claGroup.ProjectID)
return err
Expand Down Expand Up @@ -551,19 +552,38 @@ func (s *service) SignedIndividualCallbackGithub(ctx context.Context, payload []
return err
}

log.WithFields(f).Debugf("cla_group : %+v", claGroup)

pcg, err := s.projectClaGroupsRepo.GetCLAGroup(ctx, signature.ProjectID)
if err != nil {
log.WithFields(f).WithError(err).Warnf("unable to lookup project cla group by project ID: %s", signature.ProjectID)
return err
}

log.WithFields(f).Debugf("project cla group: %+v", pcg)
projectName := claGroup.ProjectName
if projectName == "" {
projectName = pcg.ProjectName
log.WithFields(f).Debugf("project name not found in cla_group, using project cla group name: %s", projectName)
}
log.WithFields(f).Debugf("project name: %s", projectName)

// Log the event
log.WithFields(f).Debugf("logging event...")
s.eventsService.LogEvent(&events.LogEventArgs{
EventType: events.IndividualSignatureSigned,
ProjectID: signature.ProjectID,
UserID: claUser.UserID,
EventData: &events.IndividualSignatureSignedEventData{
ProjectName: claGroup.ProjectName,
Username: fullName,
ProjectID: signature.ProjectID,
},
eventData := events.IndividualSignatureSignedEventData{
ProjectName: projectName,
ProjectID: signature.ProjectID,
}
log.WithFields(f).Debugf("logging event: %+v", eventData)
eventArgs := &events.LogEventArgs{
EventType: events.IndividualSignatureSigned,
ProjectID: signature.ProjectID,
UserID: claUser.UserID,
LfUsername: fullName,
EventData: &eventData,
CLAGroupID: signature.ProjectID,
})
}
log.WithFields(f).Debugf("logging event: %+v", eventArgs)
s.eventsService.LogEvent(eventArgs)

} else {
log.WithFields(f).Debugf("envelope not signed - status: %s", status)
Expand Down Expand Up @@ -776,7 +796,7 @@ func (s *service) SignedIndividualCallbackGitlab(ctx context.Context, payload []

recipients := []string{utils.GetBestEmail(claUser)}

body, err := emails.RenderDocumentSignedTemplate(s.emailTemplateService, claGroup.Version, claGroup.ProjectID, emailParams)
body, err := emails.RenderDocumentSignedTemplate(s.emailTemplateService, claGroup.Version, claGroup.ProjectExternalID, emailParams)
if err != nil {
log.WithFields(f).WithError(err).Warnf("unable to render document signed template for project version: %s, project ID: %s", claGroup.Version, claGroup.ProjectID)
return err
Expand Down Expand Up @@ -1545,12 +1565,8 @@ func (s *service) getIndividualSignatureCallbackURL(ctx context.Context, userID
return "", err
}

// s.ClaV4ApiURL = "https://dc35-41-210-154-131.ngrok-free.app"

callbackURL := fmt.Sprintf("%s/v4/signed/individual/%d/%s/%s", s.ClaV4ApiURL, installationId, repositoryID, pullRequestID)

return callbackURL, nil

}

//nolint:gocyclo
Expand Down

0 comments on commit 0ab73a1

Please sign in to comment.