-
Notifications
You must be signed in to change notification settings - Fork 139
/
email.go
77 lines (63 loc) · 2.64 KB
/
email.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
76
77
package email
import (
"context"
"github.com/hatchet-dev/hatchet/internal/integrations/alerting/alerttypes"
)
type TenantInviteEmailData struct {
InviteSenderName string `json:"invite_sender_name"`
TenantName string `json:"tenant_name"`
ActionURL string `json:"action_url"`
}
type WorkflowRunsFailedEmailData struct {
Items []alerttypes.WorkflowRunFailedItem `json:"items"`
Subject string `json:"subject"`
Summary string `json:"summary"`
TenantName string `json:"tenant_name"`
SettingsLink string `json:"settings_link"`
}
type ExpiringTokenEmailData struct {
ExpiresAtAbsoluteDate string `json:"expires_at_absolute_date"`
ExpiresAtRelativeDate string `json:"expires_at_relative_date"`
TokenName string `json:"token_name"`
Subject string `json:"subject"`
TenantName string `json:"tenant_name"`
TokenSettings string `json:"token_settings"`
SettingsLink string `json:"settings_link"`
}
type ResourceLimitAlertData struct {
Subject string `json:"subject"`
Summary string `json:"summary"`
Summary2 string `json:"summary2"`
TenantName string `json:"tenant_name"`
Link string `json:"link"`
Resource string `json:"resource"`
AlertType string `json:"alert_type"`
CurrentValue int `json:"current_value"`
LimitValue int `json:"limit_value"`
Percentage int `json:"percentage"`
SettingsLink string `json:"settings_link"`
}
type EmailService interface {
// for clients to show email settings
IsValid() bool
SendTenantInviteEmail(ctx context.Context, email string, data TenantInviteEmailData) error
SendWorkflowRunFailedAlerts(ctx context.Context, emails []string, data WorkflowRunsFailedEmailData) error
SendExpiringTokenEmail(ctx context.Context, emails []string, data ExpiringTokenEmailData) error
SendTenantResourceLimitAlert(ctx context.Context, emails []string, data ResourceLimitAlertData) error
}
type NoOpService struct{}
func (s *NoOpService) IsValid() bool {
return false
}
func (s *NoOpService) SendTenantInviteEmail(ctx context.Context, email string, data TenantInviteEmailData) error {
return nil
}
func (s *NoOpService) SendWorkflowRunFailedAlerts(ctx context.Context, emails []string, data WorkflowRunsFailedEmailData) error {
return nil
}
func (s *NoOpService) SendExpiringTokenEmail(ctx context.Context, emails []string, data ExpiringTokenEmailData) error {
return nil
}
func (s *NoOpService) SendTenantResourceLimitAlert(ctx context.Context, emails []string, data ResourceLimitAlertData) error {
return nil
}