Skip to content

Commit

Permalink
- Added initiate sign request (void and create envelope)
Browse files Browse the repository at this point in the history
Signed-off-by: Harold Wanyama <[email protected]>
  • Loading branch information
nickmango committed Oct 19, 2023
1 parent c1bedfc commit e627131
Show file tree
Hide file tree
Showing 15 changed files with 969 additions and 55 deletions.
35 changes: 35 additions & 0 deletions cla-backend-go/github/github_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -643,3 +643,38 @@ func CreateStatus(ctx context.Context, client *github.Client, owner, repo, sha s

return c, resp, nil
}

func GetReturnURL(ctx context.Context, installationID, repositoryID int64, pullRequestID int) (string, error) {
f := logrus.Fields{
"functionName": "github.github_repository.GetReturnURL",
utils.XREQUESTID: ctx.Value(utils.XREQUESTID),
"installationID": installationID,
"repositoryID": repositoryID,
"pullRequestID": pullRequestID,
}

client, err := NewGithubAppClient(installationID)

if err != nil {
log.WithFields(f).WithError(err).Warn("unable to create Github client")
return "", err
}

log.WithFields(f).Debugf("getting github repository by id: %d", repositoryID)
repo, _, err := client.Repositories.GetByID(ctx, repositoryID)
if err != nil {
log.WithFields(f).WithError(err).Warnf("unable to get repository by ID: %d", repositoryID)
return "", err
}

log.WithFields(f).Debugf("getting pull request by id: %d", pullRequestID)
pullRequest, _, err := client.PullRequests.Get(ctx, *repo.Owner.Login, *repo.Name, pullRequestID)
if err != nil {
log.WithFields(f).WithError(err).Warnf("unable to get pull request by ID: %d", pullRequestID)
return "", err
}

log.WithFields(f).Debugf("returning pull request html url: %s", *pullRequest.HTMLURL)

return *pullRequest.HTMLURL, nil
}
27 changes: 20 additions & 7 deletions cla-backend-go/project/common/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ func GetCurrentDocument(ctx context.Context, docs []models.ClaGroupDocument) (mo
continue
}

// No previous, use the first...
if currentDoc == (models.ClaGroupDocument{}) {
currentDoc = doc
currentDocVersion = version
currentDocDateTime = dateTime
continue
}
// // No previous, use the first...
// if currentDoc == (models.ClaGroupDocument{}) {
// currentDoc = doc
// currentDocVersion = version
// currentDocDateTime = dateTime
// continue
// }

// Newer version...
if version > currentDocVersion {
Expand All @@ -127,3 +127,16 @@ func GetCurrentDocument(ctx context.Context, docs []models.ClaGroupDocument) (mo

return currentDoc, nil
}

func AreClaGroupDocumentsEqual(doc1, doc2 models.ClaGroupDocument) bool {
return doc1.DocumentName == doc2.DocumentName &&
doc1.DocumentAuthorName == doc2.DocumentAuthorName &&
doc1.DocumentContentType == doc2.DocumentContentType &&
doc1.DocumentFileID == doc2.DocumentFileID &&
doc1.DocumentLegalEntityName == doc2.DocumentLegalEntityName &&
doc1.DocumentPreamble == doc2.DocumentPreamble &&
doc1.DocumentS3URL == doc2.DocumentS3URL &&
doc1.DocumentMajorVersion == doc2.DocumentMajorVersion &&
doc1.DocumentMinorVersion == doc2.DocumentMinorVersion &&
doc1.DocumentCreationDate == doc2.DocumentCreationDate
}
8 changes: 4 additions & 4 deletions cla-backend-go/project/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ func (s ProjectService) GetCLAGroupCurrentICLATemplateURLByID(ctx context.Contex
}
}

if currentDoc == (models.ClaGroupDocument{}) {
log.WithFields(f).WithError(err).Warn("problem determining current ICLA for this CLA Group")
if common.AreClaGroupDocumentsEqual(currentDoc, models.ClaGroupDocument{}) {
log.WithFields(f).WithError(err).Warn("problem determining current ICLA for this CLA Group - document is empty")
return "", &utils.CLAGroupICLANotConfigured{
CLAGroupID: claGroupID,
CLAGroupName: claGroupModel.ProjectName,
Expand Down Expand Up @@ -288,8 +288,8 @@ func (s ProjectService) GetCLAGroupCurrentCCLATemplateURLByID(ctx context.Contex
}
}

if currentDoc == (models.ClaGroupDocument{}) {
log.WithFields(f).WithError(err).Warn("problem determining current CCLA for this CLA Group")
if common.AreClaGroupDocumentsEqual(currentDoc, models.ClaGroupDocument{}) {
log.WithFields(f).WithError(err).Warn("problem determining current CCLA for this CLA Group - document is empty")
return "", &utils.CLAGroupCCLANotConfigured{
CLAGroupID: claGroupID,
CLAGroupName: claGroupModel.ProjectName,
Expand Down
1 change: 1 addition & 0 deletions cla-backend-go/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ provider:
DOCUSIGN_INTEGRATOR_KEY: ${file(./env.json):docusign-integrator-key, ssm:/cla-docusign-integrator-key-${opt:stage}}
DOCUSIGN_AUTH_SERVER: ${file(./env.json):docusign-auth-server, ssm:/cla-docusign-auth-server-${opt:stage}}
DOCUSIGN_USER_ID: ${file(./env.json):docusign-auth-server, ssm:/cla-docusign-user-id-${opt:stage}}
DOCUSIGN_ACCOUNT_ID: ${file(./env.json):docusign-account-id, ssm:/cla-docusign-account-id-${opt:stage}}
CLA_API_BASE: ${file(./env.json):cla-api-base, ssm:/cla-api-base-${opt:stage}}
CLA_CONTRIBUTOR_BASE: ${file(./env.json):cla-contributor-base, ssm:/cla-contributor-base-${opt:stage}}
CLA_CONTRIBUTOR_V2_BASE: ${file(./env.json):cla-contributor-v2-base, ssm:/cla-contributor-v2-base-${opt:stage}}
Expand Down
1 change: 1 addition & 0 deletions cla-backend-go/signatures/converters.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ func (repo repository) buildProjectSignatureModels(ctx context.Context, results
SignatureCallbackURL: dbSignature.SignatureCallbackURL,
SignatureReturnURL: dbSignature.SignatureReturnURL,
SignatureReturnURLType: dbSignature.SignatureReturnURLType,
SignatureEnvelopeID: dbSignature.SignatureEnvelopeID,
}

sigs = append(sigs, sig)
Expand Down
1 change: 1 addition & 0 deletions cla-backend-go/signatures/dbmodels.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type ItemSignature struct {
SignatureProjectID string `json:"signature_project_id"`
SignatureReferenceType string `json:"signature_reference_type"`
SignatureType string `json:"signature_type"`
SignatureEnvelopeID string `json:"signature_envelope_id"`
SignatureUserCompanyID string `json:"signature_user_ccla_company_id"`
EmailApprovalList []string `json:"email_whitelist"`
EmailDomainApprovalList []string `json:"domain_whitelist"`
Expand Down
3 changes: 3 additions & 0 deletions cla-backend-go/swagger/cla.v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2854,6 +2854,9 @@ definitions:

cla-group-document:
$ref: './common/cla-group-document.yaml'

document-tab:
$ref: './common/document-tab.yaml'

create-cla-group-template:
$ref: './common/create-cla-group-template.yaml'
Expand Down
3 changes: 3 additions & 0 deletions cla-backend-go/swagger/cla.v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5680,6 +5680,9 @@ definitions:

cla-group-summary:
$ref: './common/cla-group-summary.yaml'

document-tab:
$ref: './common/document-tab.yaml'

cla-group-project:
type: object
Expand Down
7 changes: 7 additions & 0 deletions cla-backend-go/swagger/common/cla-group-document.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ properties:
description: the document content type
example: 'storage+pdf'
type: string
documentContent:
description: the document content
type: string
documentS3URL:
description: the document S3 URL
example: "https://cla-signature-files-dev.s3.amazonaws.com/contract-group/f7222222-7777-4444-aaaa-1c1c1c1c1c1c/template/ccla.pdf"
Expand All @@ -46,3 +49,7 @@ properties:
description: the document creation date
example: '2019-08-01T06:55:09Z'
type: string
documentTabs:
type: array
items:
$ref: '#/definitions/document-tab'
41 changes: 41 additions & 0 deletions cla-backend-go/swagger/common/document-tab.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright The Linux Foundation and each contributor to CommunityBridge.
# SPDX-License-Identifier: MIT

type: object
x-nullable: false
title: Docusign Document Tab
description: Docusign Document Tab
properties:
document_tab_type:
type: string
document_tab_id:
type: string
document_tab_name:
type: string
document_tab_page:
type: integer
document_tab_position_x:
type: integer
document_tab_position_y:
type: integer
document_tab_width:
type: integer
document_tab_height:
type: integer
document_tab_is_locked:
type: boolean
document_tab_is_required:
type: boolean
document_tab_anchor_string:
type: string
document_tab_anchor_ignore_if_not_present:
type: boolean
document_tab_anchor_x_offset:
type: integer
document_tab_anchor_y_offset:
type: integer





3 changes: 3 additions & 0 deletions cla-backend-go/swagger/common/signature.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ properties:
signatureReturnURLType:
type: string
description: the signature return URL type
signatureEnvelopeId:
type: string
description: the signature envelope ID
emailApprovalList:
type: array
description: a list of zero or more email addresses in the approval list
Expand Down
Loading

0 comments on commit e627131

Please sign in to comment.