Add enum to handle rejected status of trust center document access
Signed-off-by: Émile Ré <nemile.re@gmail.com>
This commit is contained in:
@@ -22,11 +22,11 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"go.gearno.de/kit/pg"
|
||||
"go.probo.inc/probo/pkg/baseurl"
|
||||
"go.probo.inc/probo/pkg/coredata"
|
||||
"go.probo.inc/probo/pkg/gid"
|
||||
"go.probo.inc/probo/pkg/slack"
|
||||
"go.gearno.de/kit/pg"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -40,23 +40,23 @@ type (
|
||||
}
|
||||
|
||||
SlackMessageDocument struct {
|
||||
ID string
|
||||
Title string
|
||||
Granted bool
|
||||
ID string
|
||||
Title string
|
||||
Status string
|
||||
}
|
||||
|
||||
SlackMessageReport struct {
|
||||
ID string
|
||||
Title string
|
||||
AuditID string
|
||||
Granted bool
|
||||
Status string
|
||||
}
|
||||
|
||||
SlackMessageFile struct {
|
||||
ID string
|
||||
Name string
|
||||
Category string
|
||||
Granted bool
|
||||
Status string
|
||||
}
|
||||
|
||||
SlackMessageMetadata struct {
|
||||
@@ -336,9 +336,9 @@ func (s *SlackMessageService) loadDocumentsReportsAndFilesFromAccesses(
|
||||
return nil, nil, nil, fmt.Errorf("cannot load document: %w", err)
|
||||
}
|
||||
documents = append(documents, SlackMessageDocument{
|
||||
ID: access.DocumentID.String(),
|
||||
Title: doc.Title,
|
||||
Granted: access.Active,
|
||||
ID: access.DocumentID.String(),
|
||||
Title: doc.Title,
|
||||
Status: access.Status.String(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -366,7 +366,7 @@ func (s *SlackMessageService) loadDocumentsReportsAndFilesFromAccesses(
|
||||
ID: access.ReportID.String(),
|
||||
Title: label,
|
||||
AuditID: audit.ID.String(),
|
||||
Granted: access.Active,
|
||||
Status: access.Status.String(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -379,7 +379,7 @@ func (s *SlackMessageService) loadDocumentsReportsAndFilesFromAccesses(
|
||||
ID: access.TrustCenterFileID.String(),
|
||||
Name: file.Name,
|
||||
Category: file.Category,
|
||||
Granted: access.Active,
|
||||
Status: access.Status.String(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,14 +66,28 @@
|
||||
"type": "mrkdwn",
|
||||
"text": "<https://{{$.Domain}}/organizations/{{$.OrganizationID}}/documents/{{.ID}}|{{jsonEscape .Title}}>"
|
||||
},
|
||||
"accessory": {{if .Granted}}{
|
||||
"accessory": {{if eq .Status "GRANTED"}}{
|
||||
"type": "button",
|
||||
"text": {
|
||||
"type": "plain_text",
|
||||
"text": "✓ Granted"
|
||||
},
|
||||
"url": "https://{{$.Domain}}/organizations/{{$.OrganizationID}}/trust-center/access"
|
||||
}{{else}}{
|
||||
}{{else if eq .Status "REJECTED"}}{
|
||||
"type": "button",
|
||||
"text": {
|
||||
"type": "plain_text",
|
||||
"text": "✗ Rejected"
|
||||
},
|
||||
"url": "https://{{$.Domain}}/organizations/{{$.OrganizationID}}/trust-center/access"
|
||||
}{{else if eq .Status "REVOKED"}}{
|
||||
"type": "button",
|
||||
"text": {
|
||||
"type": "plain_text",
|
||||
"text": "✗ Revoked"
|
||||
},
|
||||
"url": "https://{{$.Domain}}/organizations/{{$.OrganizationID}}/trust-center/access"
|
||||
}{{else if eq .Status "REQUESTED"}}{
|
||||
"type": "button",
|
||||
"text": {
|
||||
"type": "plain_text",
|
||||
|
||||
@@ -572,20 +572,20 @@ func (s *TrustCenterAccessService) RejectByIDs(
|
||||
|
||||
if len(documentIDs) > 0 {
|
||||
shouldSendEmail = true
|
||||
if err := coredata.DeleteByDocumentIDs(ctx, tx, s.svc.scope, access.ID, documentIDs); err != nil {
|
||||
return fmt.Errorf("cannot delete document accesses: %w", err)
|
||||
if err := coredata.RejectByDocumentIDs(ctx, tx, s.svc.scope, access.ID, documentIDs); err != nil {
|
||||
return fmt.Errorf("cannot reject document accesses: %w", err)
|
||||
}
|
||||
}
|
||||
if len(reportIDs) > 0 {
|
||||
shouldSendEmail = true
|
||||
if err := coredata.DeleteByReportIDs(ctx, tx, s.svc.scope, access.ID, reportIDs); err != nil {
|
||||
return fmt.Errorf("cannot delete report accesses: %w", err)
|
||||
if err := coredata.RejectByReportIDs(ctx, tx, s.svc.scope, access.ID, reportIDs); err != nil {
|
||||
return fmt.Errorf("cannot reject report accesses: %w", err)
|
||||
}
|
||||
}
|
||||
if len(fileIDs) > 0 {
|
||||
shouldSendEmail = true
|
||||
if err := coredata.DeleteByTrustCenterFileIDs(ctx, tx, s.svc.scope, access.ID, fileIDs); err != nil {
|
||||
return fmt.Errorf("cannot delete trust center file accesses: %w", err)
|
||||
if err := coredata.RejectByTrustCenterFileIDs(ctx, tx, s.svc.scope, access.ID, fileIDs); err != nil {
|
||||
return fmt.Errorf("cannot reject trust center file accesses: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user