-
Notifications
You must be signed in to change notification settings - Fork 11
/
intake_review.go
75 lines (68 loc) · 1.85 KB
/
intake_review.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package email
import (
"bytes"
"context"
"errors"
"html/template"
"path"
"github.com/google/uuid"
"github.com/cmsgov/easi-app/pkg/apperrors"
"github.com/cmsgov/easi-app/pkg/models"
)
type intakeReview struct {
ProjectName string
GRTEmail string
Requester string
EmailText template.HTML
TaskListPath string
}
func (c Client) systemIntakeReviewBody(
systemIntakeID uuid.UUID,
projectName string,
requester string,
emailText models.HTML,
) (string, error) {
taskListPath := path.Join("governance-task-list", systemIntakeID.String())
data := intakeReview{
ProjectName: projectName,
GRTEmail: string(c.config.GRTEmail),
Requester: requester,
EmailText: emailText.ToTemplate(),
TaskListPath: c.urlFromPath(taskListPath),
}
var b bytes.Buffer
if c.templates.intakeReviewTemplate == nil {
return "", errors.New("system intake review template is nil")
}
err := c.templates.intakeReviewTemplate.Execute(&b, data)
if err != nil {
return "", err
}
return b.String(), nil
}
// SendSystemIntakeReviewEmails sends emails to multiple recipients (possibly including the IT Governance and IT Investment teams) about GRT review on a submitted system intake
func (c Client) SendSystemIntakeReviewEmails(
ctx context.Context,
recipients models.EmailNotificationRecipients,
systemIntakeID uuid.UUID,
projectName string,
requester string,
emailText models.HTML,
) error {
subject := "Feedback for request in EASi"
body, err := c.systemIntakeReviewBody(systemIntakeID, projectName, requester, emailText)
if err != nil {
return &apperrors.NotificationError{Err: err, DestinationType: apperrors.DestinationTypeEmail}
}
err = c.sender.Send(
ctx,
c.listAllRecipients(recipients),
nil,
subject,
body,
)
if err != nil {
return &apperrors.NotificationError{Err: err, DestinationType: apperrors.DestinationTypeEmail}
}
return nil
}