services

package
v1.0.0-rc1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 16, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FeedbackCategoryBug     = "bug"
	FeedbackCategoryFeature = "feature"
	FeedbackCategoryOther   = "other"

	DefaultSupportFeedbackToEmail       = "support@superplane.com"
	MaxSupportFeedbackDetailsRunes      = 8000
	MaxSupportFeedbackAttachmentBytes   = 5 << 20
	MaxSupportFeedbackRequestBytes      = MaxSupportFeedbackAttachmentBytes + 1<<20
	MaxSupportFeedbackPagePathRunes     = 500
	MaxSupportFeedbackAttachmentNameLen = 255
)

Variables

View Source
var (
	ErrFeedbackCategoryInvalid    = errors.New("feedback category is invalid")
	ErrFeedbackDetailsRequired    = errors.New("feedback details are required")
	ErrFeedbackDetailsTooLong     = errors.New("feedback details are too long")
	ErrFeedbackAttachmentTooLarge = errors.New("feedback attachment is too large")
	ErrFeedbackAttachmentType     = errors.New("feedback attachment type is not allowed")
	ErrFeedbackAttachmentName     = errors.New("feedback attachment name is invalid")
)

Functions

func FeedbackCategoryLabel

func FeedbackCategoryLabel(category string) string

func FormatDiscordFeedbackContent

func FormatDiscordFeedbackContent(feedback SupportFeedback) string

func NormalizeFeedbackCategory

func NormalizeFeedbackCategory(category string) (string, error)

func NormalizeFeedbackDetails

func NormalizeFeedbackDetails(details string) (string, error)

func NormalizeFeedbackPagePath

func NormalizeFeedbackPagePath(pagePath string) string

func SupportFeedbackToEmail

func SupportFeedbackToEmail() string

Types

type DatabaseEmailSettingsProvider added in v0.0.43

type DatabaseEmailSettingsProvider struct {
	Encryptor crypto.Encryptor
}

func (*DatabaseEmailSettingsProvider) GetSMTPSettings added in v0.0.43

func (p *DatabaseEmailSettingsProvider) GetSMTPSettings(ctx context.Context) (*SMTPSettings, error)

type DiscordWebhookClient

type DiscordWebhookClient struct {
	WebhookURL string
	HTTPClient *http.Client
}

func NewDiscordWebhookClient

func NewDiscordWebhookClient(webhookURL string) *DiscordWebhookClient

func (*DiscordWebhookClient) Enabled

func (c *DiscordWebhookClient) Enabled() bool

func (*DiscordWebhookClient) SendSupportFeedback

func (c *DiscordWebhookClient) SendSupportFeedback(feedback SupportFeedback) error

type EmailService

type EmailService interface {
	SendMagicCodeEmail(toEmail, code, magicLink string) error
	SendWorkOrderNotificationEmail(toEmail, subject string, data WorkOrderNotificationTemplateData) error
	SendSupportFeedbackEmail(toEmail string, feedback SupportFeedback) error
}

func BuildEmailService added in v0.14.0

func BuildEmailService(encryptor crypto.Encryptor, cfg EmailServiceConfig) EmailService

BuildEmailService creates an EmailService based on the provided configuration. Returns nil if required configuration is missing.

type EmailServiceConfig added in v0.14.0

type EmailServiceConfig struct {
	TemplateDir       string
	OwnerSetupEnabled bool
	ResendAPIKey      string
	FromName          string
	FromEmail         string
}

type EmailSettingsProvider added in v0.0.43

type EmailSettingsProvider interface {
	GetSMTPSettings(ctx context.Context) (*SMTPSettings, error)
}

type MagicCodeTemplateData added in v0.14.0

type MagicCodeTemplateData struct {
	Code      string
	MagicLink string
}

type NoopEmailService added in v0.0.43

type NoopEmailService struct {
	// contains filtered or unexported fields
}

func NewNoopEmailService added in v0.0.43

func NewNoopEmailService() *NoopEmailService

func (*NoopEmailService) Reset added in v0.0.43

func (s *NoopEmailService) Reset()

func (*NoopEmailService) SendMagicCodeEmail added in v0.14.0

func (s *NoopEmailService) SendMagicCodeEmail(toEmail, code, magicLink string) error

func (*NoopEmailService) SendSupportFeedbackEmail

func (s *NoopEmailService) SendSupportFeedbackEmail(toEmail string, feedback SupportFeedback) error

func (*NoopEmailService) SendWorkOrderNotificationEmail

func (s *NoopEmailService) SendWorkOrderNotificationEmail(
	toEmail, subject string,
	data WorkOrderNotificationTemplateData,
) error

func (*NoopEmailService) SentMagicCodeEmails added in v0.14.0

func (s *NoopEmailService) SentMagicCodeEmails() []SentMagicCodeEmail

func (*NoopEmailService) SentSupportFeedbackEmails

func (s *NoopEmailService) SentSupportFeedbackEmails() []SentSupportFeedbackEmail

func (*NoopEmailService) SentWorkOrderNotificationEmails

func (s *NoopEmailService) SentWorkOrderNotificationEmails() []SentWorkOrderNotificationEmail

type ResendEmailService

type ResendEmailService struct {
	// contains filtered or unexported fields
}

func NewResendEmailService

func NewResendEmailService(apiKey, fromName, fromEmail, templateDir string) *ResendEmailService

func (*ResendEmailService) SendMagicCodeEmail added in v0.14.0

func (s *ResendEmailService) SendMagicCodeEmail(toEmail, code, magicLink string) error

func (*ResendEmailService) SendSupportFeedbackEmail

func (s *ResendEmailService) SendSupportFeedbackEmail(toEmail string, feedback SupportFeedback) error

func (*ResendEmailService) SendWorkOrderNotificationEmail

func (s *ResendEmailService) SendWorkOrderNotificationEmail(
	toEmail, subject string,
	data WorkOrderNotificationTemplateData,
) error

type SMTPEmailService added in v0.0.43

type SMTPEmailService struct {
	// contains filtered or unexported fields
}

func NewSMTPEmailService added in v0.0.43

func NewSMTPEmailService(settingsProvider EmailSettingsProvider, templateDir string) *SMTPEmailService

func (*SMTPEmailService) SendMagicCodeEmail added in v0.14.0

func (s *SMTPEmailService) SendMagicCodeEmail(toEmail, code, magicLink string) error

func (*SMTPEmailService) SendSupportFeedbackEmail

func (s *SMTPEmailService) SendSupportFeedbackEmail(toEmail string, feedback SupportFeedback) error

func (*SMTPEmailService) SendWorkOrderNotificationEmail

func (s *SMTPEmailService) SendWorkOrderNotificationEmail(
	toEmail, subject string,
	data WorkOrderNotificationTemplateData,
) error

type SMTPSettings added in v0.0.43

type SMTPSettings struct {
	Host      string
	Port      int
	Username  string
	Password  string
	FromName  string
	FromEmail string
	UseTLS    bool
}

type SentMagicCodeEmail added in v0.14.0

type SentMagicCodeEmail struct {
	ToEmail   string
	Code      string
	MagicLink string
}

type SentSupportFeedbackEmail

type SentSupportFeedbackEmail struct {
	ToEmail  string
	Feedback SupportFeedback
}

type SentWorkOrderNotificationEmail

type SentWorkOrderNotificationEmail struct {
	ToEmail string
	Subject string
	Data    WorkOrderNotificationTemplateData
}

type SupportFeedback

type SupportFeedback struct {
	Category         string
	Details          string
	UserName         string
	UserEmail        string
	OrganizationID   string
	OrganizationName string
	PagePath         string
	Attachment       *SupportFeedbackAttachment
}

func (SupportFeedback) EmailSubject

func (f SupportFeedback) EmailSubject() string

func (SupportFeedback) TemplateData

type SupportFeedbackAttachment

type SupportFeedbackAttachment struct {
	Filename    string
	ContentType string
	Content     []byte
}

func NormalizeFeedbackAttachment

func NormalizeFeedbackAttachment(filename, contentType string, content []byte) (*SupportFeedbackAttachment, error)

type SupportFeedbackTemplateData

type SupportFeedbackTemplateData struct {
	CategoryLabel    string
	Details          string
	FromLine         string
	UserName         string
	UserEmail        string
	OrganizationName string
	OrganizationID   string
	PagePath         string
	AttachmentName   string
}

type WorkOrderNotificationTemplateData

type WorkOrderNotificationTemplateData struct {
	// Summary is the one-line event description, for example
	// "Ana Souza commented on SP-42".
	Summary        string
	WorkOrderKey   string
	WorkOrderTitle string
	// Detail is optional supporting text (comment excerpt, state change).
	Detail        string
	WorkOrderLink string
	// DetailCtaLabel and DetailCtaURL render a secondary HTML link under
	// the detail block (status-note CTAs). Empty URL skips the link.
	DetailCtaLabel string
	DetailCtaURL   string
	// Kanban-card fields. Colors are light-theme hex values so the HTML
	// email matches the work order board card.
	StatusLabel      string
	StatusFg         string
	StatusBg         string
	StatusBorder     string
	StatusDot        string
	LineStepLabel    string
	UpdatedLabel     string
	AssigneeInitials string
	AssigneeOverflow string
}

WorkOrderNotificationTemplateData feeds the shared work_order_notification templates. One template renders every notification type; the consumer builds the summary and detail lines.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL