/
notification_provider.go
67 lines (58 loc) · 2.02 KB
/
notification_provider.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
package notifications
import (
"context"
"github.com/openline-ai/openline-customer-os/packages/server/customer-os-common-module/aws_client"
"github.com/openline-ai/openline-customer-os/packages/server/customer-os-common-module/logger"
"github.com/opentracing/opentracing-go"
)
const (
WorkflowIdTestFlow = "test-workflow"
WorkflowIdOrgOwnerUpdateEmail = "org-owner-update-email"
WorkflowIdOrgOwnerUpdateAppNotification = "org-owner-update-in-app-notification"
WorkflowInvoicePaid = "invoice-paid"
WorkflowInvoiceReadyWithPaymentLink = "invoice-ready"
WorkflowInvoiceReadyNoPaymentLink = "invoice-ready-nolink"
WorkflowInvoiceVoided = "invoice-voided"
WorkflowFailedWebhook = "failed-webhook"
WorkflowReminderNotificationEmail = "reminder-notification-email"
WorkflowReminderInAppNotification = "reminder-in-app-notification"
)
var REQUIRED_TEMPLATE_VALUES = map[string][]string{
WorkflowIdOrgOwnerUpdateEmail: {
"{{userFirstName}}",
"{{actorFirstName}}",
"{{actorLastName}}",
"{{orgName}}",
"{{orgLink}}",
},
WorkflowFailedWebhook: {
"{{userFirstName}}",
"{{webhookName}}",
"{{webhookUrl}}",
},
WorkflowReminderNotificationEmail: {
"{{reminderContent}}",
"{{reminderCreatedAt}}",
"{{orgName}}",
"{{orgLink}}",
},
}
type NotifiableUser struct {
FirstName string `json:"firstName"`
LastName string `json:"lastName"`
Email string `json:"email"`
SubscriberID string `json:"subscriberId"` // must be unique uuid for user
}
type NovuNotification struct {
WorkflowId string
TemplateData map[string]string
To *NotifiableUser
Subject string
Payload map[string]interface{}
}
type NotificationProvider interface {
SendNotification(ctx context.Context, notification *NovuNotification, span opentracing.Span) error
}
func NewNovuNotificationProvider(log logger.Logger, apiKey string, s3Client aws_client.S3ClientI) NotificationProvider {
return newNovuProvider(log, apiKey, s3Client)
}