service

package
v0.0.0-...-4cd0f3b Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: AGPL-3.0, GPL-2.0 Imports: 61 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ToolScrapeURL is the name of the scrape URL tool
	ToolScrapeURL = "scrape_url"
	// ToolSearchWeb is the name of the search web tool
	ToolSearchWeb = "search_web"
	// MaxContentSize is the maximum size of content to return (50K chars)
	MaxContentSize = 50000
)
View Source
const (
	// TelemetryEndpoint is the hardcoded endpoint for sending telemetry data
	TelemetryEndpoint = "https://telemetry.notifuse.com"
)

Variables

View Source
var (
	ErrSessionExpired = errors.New("session expired")
	ErrUserNotFound   = errors.New("user not found")
)
View Source
var (
	ErrInvalidAWSCredentials = fmt.Errorf("invalid AWS credentials")
	ErrInvalidSNSDestination = fmt.Errorf("SNS destination and Topic ARN are required")
	ErrInvalidSESConfig      = fmt.Errorf("SES configuration is missing or invalid")
)

Custom domain errors for better testability

View Source
var AllowedContactFields = map[string]bool{

	"external_id": true, "timezone": true, "language": true,
	"first_name": true, "last_name": true, "phone": true, "photo_url": true,

	"address_line_1": true, "address_line_2": true,
	"country": true, "postcode": true, "state": true,

	"custom_string_1": true, "custom_string_2": true, "custom_string_3": true,
	"custom_string_4": true, "custom_string_5": true,

	"custom_number_1": true, "custom_number_2": true, "custom_number_3": true,
	"custom_number_4": true, "custom_number_5": true,

	"custom_datetime_1": true, "custom_datetime_2": true, "custom_datetime_3": true,
	"custom_datetime_4": true, "custom_datetime_5": true,

	"custom_json_1": true, "custom_json_2": true, "custom_json_3": true,
	"custom_json_4": true, "custom_json_5": true,
}

AllowedContactFields defines valid field names for updated_fields filter (prevents SQL injection)

Functions

func CreateSESClient

func CreateSESClient(region, accessKey, secretKey string) domain.SESClient

CreateSESClient creates a new SES client with the provided credentials

func EnsureContactSegmentQueueProcessingTask

func EnsureContactSegmentQueueProcessingTask(ctx context.Context, taskRepo domain.TaskRepository, workspaceID string) error

EnsureContactSegmentQueueProcessingTask creates or updates the permanent queue processing task for a workspace This should be called when a workspace is created or during migration

func EnsureSegmentRecomputeTask

func EnsureSegmentRecomputeTask(ctx context.Context, taskRepo domain.TaskRepository, workspaceID string) error

EnsureSegmentRecomputeTask creates or updates the permanent recompute checking task for a workspace This should be called when a workspace is created or during migration

func ExtractTableOfContents

func ExtractTableOfContents(html string) ([]domain.TOCItem, string, error)

ExtractTableOfContents extracts headings from HTML and generates a table of contents It also ensures all headings have ID attributes for anchor linking

func GenerateSecureKey

func GenerateSecureKey(byteLength int) (string, error)

GenerateSecureKey generates a cryptographically secure random key with the specified byte length and returns it as a hex-encoded string

func ValidateSlug

func ValidateSlug(slug string) error

ValidateSlug checks if slug is valid format (no nanoid - clean slugs)

Types

type ABTestNodeExecutor

type ABTestNodeExecutor struct{}

ABTestNodeExecutor executes A/B test nodes

func NewABTestNodeExecutor

func NewABTestNodeExecutor() *ABTestNodeExecutor

NewABTestNodeExecutor creates a new A/B test node executor

func (*ABTestNodeExecutor) Execute

Execute processes an A/B test node using deterministic variant selection

func (*ABTestNodeExecutor) NodeType

func (e *ABTestNodeExecutor) NodeType() domain.NodeType

NodeType returns the node type this executor handles

type AddToListNodeExecutor

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

AddToListNodeExecutor executes add-to-list nodes

func NewAddToListNodeExecutor

func NewAddToListNodeExecutor(contactListRepo domain.ContactListRepository) *AddToListNodeExecutor

NewAddToListNodeExecutor creates a new add-to-list node executor

func (*AddToListNodeExecutor) Execute

Execute processes an add-to-list node

func (*AddToListNodeExecutor) NodeType

func (e *AddToListNodeExecutor) NodeType() domain.NodeType

NodeType returns the node type this executor handles

type AnalyticsService

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

AnalyticsService handles analytics operations

func NewAnalyticsService

func NewAnalyticsService(
	repo domain.AnalyticsRepository,
	authService domain.AuthService,
	logger logger.Logger,
) *AnalyticsService

NewAnalyticsService creates a new analytics service

func (*AnalyticsService) GetSchemas

func (s *AnalyticsService) GetSchemas(ctx context.Context, workspaceID string) (map[string]analytics.SchemaDefinition, error)

GetSchemas returns the available analytics schemas for a workspace

func (*AnalyticsService) Query

func (s *AnalyticsService) Query(ctx context.Context, workspaceID string, query analytics.Query) (*analytics.Response, error)

Query executes an analytics query for a workspace

type AttachmentService

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

AttachmentService handles attachment storage and retrieval

func NewAttachmentService

func NewAttachmentService(attachmentRepo domain.AttachmentRepository) *AttachmentService

NewAttachmentService creates a new attachment service

func (*AttachmentService) GetAttachment

func (s *AttachmentService) GetAttachment(ctx context.Context, workspaceID string, checksum string) (*domain.AttachmentRecord, error)

GetAttachment retrieves an attachment by checksum

func (*AttachmentService) GetAttachmentsForMessage

func (s *AttachmentService) GetAttachmentsForMessage(ctx context.Context, workspaceID string, metadata []domain.AttachmentMetadata) ([]domain.Attachment, error)

GetAttachmentsForMessage retrieves all attachments for a message

func (*AttachmentService) ProcessAttachments

func (s *AttachmentService) ProcessAttachments(ctx context.Context, workspaceID string, attachments []domain.Attachment) ([]domain.AttachmentMetadata, error)

ProcessAttachments processes and stores attachments, returning metadata

func (*AttachmentService) RetrieveAttachmentContent

func (s *AttachmentService) RetrieveAttachmentContent(ctx context.Context, workspaceID string, metadata []domain.AttachmentMetadata) ([]AttachmentWithContent, error)

RetrieveAttachmentContent retrieves attachment content for sending emails

type AttachmentWithContent

type AttachmentWithContent struct {
	Filename    string
	Content     []byte
	ContentType string
	Disposition string
}

AttachmentWithContent represents an attachment with binary content

type AuthService

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

func NewAuthService

func NewAuthService(cfg AuthServiceConfig) *AuthService

func (*AuthService) AuthenticateUserForWorkspace

func (s *AuthService) AuthenticateUserForWorkspace(ctx context.Context, workspaceID string) (context.Context, *domain.User, *domain.UserWorkspace, error)

AuthenticateUserForWorkspace checks if the user exists and the session is valid for a specific workspace

func (*AuthService) AuthenticateUserFromContext

func (s *AuthService) AuthenticateUserFromContext(ctx context.Context) (*domain.User, error)

func (*AuthService) GenerateAPIAuthToken

func (s *AuthService) GenerateAPIAuthToken(user *domain.User) string

GenerateAPIAuthToken generates an authentication token for an API key

func (*AuthService) GenerateInvitationToken

func (s *AuthService) GenerateInvitationToken(invitation *domain.WorkspaceInvitation) string

GenerateInvitationToken generates a JWT token for a workspace invitation

func (*AuthService) GenerateUserAuthToken

func (s *AuthService) GenerateUserAuthToken(user *domain.User, sessionID string, expiresAt time.Time) string

GenerateUserAuthToken generates an authentication token for a user

func (*AuthService) GetUserByID

func (s *AuthService) GetUserByID(ctx context.Context, userID string) (*domain.User, error)

GetUserByID retrieves a user by their ID

func (*AuthService) InvalidateSecretCache

func (s *AuthService) InvalidateSecretCache()

InvalidateSecretCache clears the cached secret, forcing it to be reloaded on next use

func (*AuthService) ValidateInvitationToken

func (s *AuthService) ValidateInvitationToken(tokenString string) (invitationID, workspaceID, email string, err error)

ValidateInvitationToken validates a JWT invitation token and returns the invitation details

func (*AuthService) VerifyUserSession

func (s *AuthService) VerifyUserSession(ctx context.Context, userID, sessionID string) (*domain.User, error)

VerifyUserSession checks if the user exists and the session is valid

type AuthServiceConfig

type AuthServiceConfig struct {
	Repository          domain.AuthRepository
	WorkspaceRepository domain.WorkspaceRepository
	GetSecret           func() ([]byte, error) // Changed from GetKeys
	Logger              logger.Logger
}

type AutomationExecutor

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

AutomationExecutor processes contacts through automation workflows

func NewAutomationExecutor

func NewAutomationExecutor(
	automationRepo domain.AutomationRepository,
	contactRepo domain.ContactRepository,
	workspaceRepo domain.WorkspaceRepository,
	contactListRepo domain.ContactListRepository,
	templateRepo domain.TemplateRepository,
	emailQueueRepo domain.EmailQueueRepository,
	messageRepo domain.MessageHistoryRepository,
	timelineRepo domain.ContactTimelineRepository,
	log logger.Logger,
	apiEndpoint string,
) *AutomationExecutor

NewAutomationExecutor creates a new AutomationExecutor

func (*AutomationExecutor) Execute

func (e *AutomationExecutor) Execute(ctx context.Context, workspaceID string, contactAutomation *domain.ContactAutomation) error

Execute processes a contact through their automation nodes until a delay or completion. It loops through multiple nodes in a single tick for efficiency, persisting state after each node.

func (*AutomationExecutor) ProcessBatch

func (e *AutomationExecutor) ProcessBatch(ctx context.Context, limit int) (int, error)

ProcessBatch processes a batch of scheduled contacts

type AutomationScheduler

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

AutomationScheduler manages periodic automation execution

func NewAutomationScheduler

func NewAutomationScheduler(
	executor *AutomationExecutor,
	log logger.Logger,
	interval time.Duration,
	batchSize int,
) *AutomationScheduler

NewAutomationScheduler creates a new automation scheduler

func (*AutomationScheduler) IsRunning

func (s *AutomationScheduler) IsRunning() bool

IsRunning returns whether the scheduler is currently running

func (*AutomationScheduler) Start

func (s *AutomationScheduler) Start(ctx context.Context)

Start begins the automation execution scheduler

func (*AutomationScheduler) Stop

func (s *AutomationScheduler) Stop()

Stop gracefully stops the scheduler

type AutomationService

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

AutomationService handles automation business logic

func NewAutomationService

func NewAutomationService(
	repo domain.AutomationRepository,
	authService domain.AuthService,
	logger logger.Logger,
) *AutomationService

NewAutomationService creates a new AutomationService

func (*AutomationService) Activate

func (s *AutomationService) Activate(ctx context.Context, workspaceID, automationID string) error

Activate activates an automation (changes status to live and creates trigger)

func (*AutomationService) Create

func (s *AutomationService) Create(ctx context.Context, workspaceID string, automation *domain.Automation) error

Create creates a new automation

func (*AutomationService) Delete

func (s *AutomationService) Delete(ctx context.Context, workspaceID, automationID string) error

Delete soft-deletes an automation (can delete live automations) The repository handles dropping triggers and exiting active contacts

func (*AutomationService) Get

func (s *AutomationService) Get(ctx context.Context, workspaceID, automationID string) (*domain.Automation, error)

Get retrieves an automation by ID

func (*AutomationService) GetContactNodeExecutions

func (s *AutomationService) GetContactNodeExecutions(ctx context.Context, workspaceID, automationID, email string) (*domain.ContactAutomation, []*domain.NodeExecution, error)

GetContactNodeExecutions retrieves the node executions of a contact through an automation

func (*AutomationService) List

func (s *AutomationService) List(ctx context.Context, workspaceID string, filter domain.AutomationFilter) ([]*domain.Automation, int, error)

List retrieves automations with optional filters

func (*AutomationService) Pause

func (s *AutomationService) Pause(ctx context.Context, workspaceID, automationID string) error

Pause pauses a live automation (changes status to paused and drops trigger)

func (*AutomationService) Update

func (s *AutomationService) Update(ctx context.Context, workspaceID string, automation *domain.Automation) error

Update updates an existing automation

type AutomationTriggerGenerator

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

AutomationTriggerGenerator generates PostgreSQL trigger SQL from automation configuration

func NewAutomationTriggerGenerator

func NewAutomationTriggerGenerator(queryBuilder *QueryBuilder) *AutomationTriggerGenerator

NewAutomationTriggerGenerator creates a new trigger generator

func (*AutomationTriggerGenerator) Generate

func (g *AutomationTriggerGenerator) Generate(automation *domain.Automation) (*TriggerSQL, error)

Generate creates TriggerSQL for the given automation

type BlogService

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

BlogService handles all blog-related operations

func NewBlogService

func NewBlogService(
	logger logger.Logger,
	categoryRepository domain.BlogCategoryRepository,
	postRepository domain.BlogPostRepository,
	themeRepository domain.BlogThemeRepository,
	workspaceRepository domain.WorkspaceRepository,
	listRepository domain.ListRepository,
	templateRepository domain.TemplateRepository,
	authService domain.AuthService,
	cache cache.Cache,
) *BlogService

NewBlogService creates a new blog service

func (*BlogService) CreateCategory

func (s *BlogService) CreateCategory(ctx context.Context, request *domain.CreateBlogCategoryRequest) (*domain.BlogCategory, error)

CreateCategory creates a new blog category

func (*BlogService) CreatePost

func (s *BlogService) CreatePost(ctx context.Context, request *domain.CreateBlogPostRequest) (*domain.BlogPost, error)

CreatePost creates a new blog post

func (*BlogService) CreateTheme

func (s *BlogService) CreateTheme(ctx context.Context, request *domain.CreateBlogThemeRequest) (*domain.BlogTheme, error)

CreateTheme creates a new blog theme

func (*BlogService) DeleteCategory

func (s *BlogService) DeleteCategory(ctx context.Context, request *domain.DeleteBlogCategoryRequest) error

DeleteCategory deletes a blog category and cascade deletes all posts in that category

func (*BlogService) DeletePost

func (s *BlogService) DeletePost(ctx context.Context, request *domain.DeleteBlogPostRequest) error

DeletePost deletes a blog post

func (*BlogService) GetCategory

func (s *BlogService) GetCategory(ctx context.Context, id string) (*domain.BlogCategory, error)

GetCategory retrieves a blog category by ID

func (*BlogService) GetCategoryBySlug

func (s *BlogService) GetCategoryBySlug(ctx context.Context, slug string) (*domain.BlogCategory, error)

GetCategoryBySlug retrieves a blog category by slug

func (*BlogService) GetPost

func (s *BlogService) GetPost(ctx context.Context, id string) (*domain.BlogPost, error)

GetPost retrieves a blog post by ID

func (*BlogService) GetPostByCategoryAndSlug

func (s *BlogService) GetPostByCategoryAndSlug(ctx context.Context, categorySlug, postSlug string) (*domain.BlogPost, error)

GetPostByCategoryAndSlug retrieves a blog post by category slug and post slug

func (*BlogService) GetPostBySlug

func (s *BlogService) GetPostBySlug(ctx context.Context, slug string) (*domain.BlogPost, error)

GetPostBySlug retrieves a blog post by slug

func (*BlogService) GetPublicCategoryBySlug

func (s *BlogService) GetPublicCategoryBySlug(ctx context.Context, slug string) (*domain.BlogCategory, error)

GetPublicCategoryBySlug retrieves a blog category by slug for public blog pages (no authentication required)

func (*BlogService) GetPublicPostByCategoryAndSlug

func (s *BlogService) GetPublicPostByCategoryAndSlug(ctx context.Context, categorySlug, postSlug string) (*domain.BlogPost, error)

GetPublicPostByCategoryAndSlug retrieves a published blog post by category slug and post slug (no auth required)

func (*BlogService) GetPublishedTheme

func (s *BlogService) GetPublishedTheme(ctx context.Context) (*domain.BlogTheme, error)

GetPublishedTheme retrieves the currently published blog theme

func (*BlogService) GetTheme

func (s *BlogService) GetTheme(ctx context.Context, version int) (*domain.BlogTheme, error)

GetTheme retrieves a blog theme by version

func (*BlogService) ListCategories

func (s *BlogService) ListCategories(ctx context.Context) (*domain.BlogCategoryListResponse, error)

ListCategories retrieves all blog categories for a workspace

func (*BlogService) ListPosts

ListPosts retrieves blog posts with filtering and pagination

func (*BlogService) ListPublicPosts

ListPublicPosts retrieves published blog posts (no auth required)

func (*BlogService) ListThemes

ListThemes retrieves blog themes with pagination

func (*BlogService) PublishPost

func (s *BlogService) PublishPost(ctx context.Context, request *domain.PublishBlogPostRequest) error

PublishPost publishes a draft blog post

func (*BlogService) PublishTheme

func (s *BlogService) PublishTheme(ctx context.Context, request *domain.PublishBlogThemeRequest) error

PublishTheme publishes a blog theme

func (*BlogService) RenderCategoryPage

func (s *BlogService) RenderCategoryPage(ctx context.Context, workspaceID, categorySlug string, page int, themeVersion *int) (string, error)

RenderCategoryPage renders a category page with posts in that category

func (*BlogService) RenderHomePage

func (s *BlogService) RenderHomePage(ctx context.Context, workspaceID string, page int, themeVersion *int) (string, error)

RenderHomePage renders the blog home page with published posts

func (*BlogService) RenderPostPage

func (s *BlogService) RenderPostPage(ctx context.Context, workspaceID, categorySlug, postSlug string, themeVersion *int) (string, error)

RenderPostPage renders a single blog post page

func (*BlogService) UnpublishPost

func (s *BlogService) UnpublishPost(ctx context.Context, request *domain.UnpublishBlogPostRequest) error

UnpublishPost unpublishes a published blog post

func (*BlogService) UpdateCategory

func (s *BlogService) UpdateCategory(ctx context.Context, request *domain.UpdateBlogCategoryRequest) (*domain.BlogCategory, error)

UpdateCategory updates an existing blog category

func (*BlogService) UpdatePost

func (s *BlogService) UpdatePost(ctx context.Context, request *domain.UpdateBlogPostRequest) (*domain.BlogPost, error)

UpdatePost updates an existing blog post

func (*BlogService) UpdateTheme

func (s *BlogService) UpdateTheme(ctx context.Context, request *domain.UpdateBlogThemeRequest) (*domain.BlogTheme, error)

UpdateTheme updates an existing blog theme

type BranchNodeExecutor

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

BranchNodeExecutor executes branch nodes using database queries

func NewBranchNodeExecutor

func NewBranchNodeExecutor(queryBuilder *QueryBuilder, workspaceRepo domain.WorkspaceRepository) *BranchNodeExecutor

NewBranchNodeExecutor creates a new branch node executor

func (*BranchNodeExecutor) Execute

Execute processes a branch node

func (*BranchNodeExecutor) NodeType

func (e *BranchNodeExecutor) NodeType() domain.NodeType

NodeType returns the node type this executor handles

type BroadcastService

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

BroadcastService handles all broadcast-related operations

func NewBroadcastService

func NewBroadcastService(
	logger logger.Logger,
	repository domain.BroadcastRepository,
	workspaceRepository domain.WorkspaceRepository,
	emailService domain.EmailServiceInterface,
	contactRepository domain.ContactRepository,
	templateService domain.TemplateService,
	taskService domain.TaskService,
	taskRepository domain.TaskRepository,
	authService domain.AuthService,
	eventBus domain.EventBus,
	messageHistoryRepository domain.MessageHistoryRepository,
	listService domain.ListService,
	apiEndpoint string,
) *BroadcastService

NewBroadcastService creates a new broadcast service

func (*BroadcastService) CancelBroadcast

func (s *BroadcastService) CancelBroadcast(ctx context.Context, request *domain.CancelBroadcastRequest) error

CancelBroadcast cancels a scheduled broadcast

func (*BroadcastService) CreateBroadcast

func (s *BroadcastService) CreateBroadcast(ctx context.Context, request *domain.CreateBroadcastRequest) (*domain.Broadcast, error)

CreateBroadcast creates a new broadcast

func (*BroadcastService) DeleteBroadcast

func (s *BroadcastService) DeleteBroadcast(ctx context.Context, request *domain.DeleteBroadcastRequest) error

DeleteBroadcast deletes a broadcast

func (*BroadcastService) GetBroadcast

func (s *BroadcastService) GetBroadcast(ctx context.Context, workspaceID, broadcastID string) (*domain.Broadcast, error)

GetBroadcast retrieves a broadcast by ID

func (*BroadcastService) GetTestResults

func (s *BroadcastService) GetTestResults(ctx context.Context, workspaceID, broadcastID string) (*domain.TestResultsResponse, error)

GetTestResults retrieves A/B test results for a broadcast

func (*BroadcastService) ListBroadcasts

ListBroadcasts retrieves a list of broadcasts with pagination

func (*BroadcastService) PauseBroadcast

func (s *BroadcastService) PauseBroadcast(ctx context.Context, request *domain.PauseBroadcastRequest) error

PauseBroadcast pauses a sending broadcast

func (*BroadcastService) ResumeBroadcast

func (s *BroadcastService) ResumeBroadcast(ctx context.Context, request *domain.ResumeBroadcastRequest) error

ResumeBroadcast resumes a paused broadcast

func (*BroadcastService) ScheduleBroadcast

func (s *BroadcastService) ScheduleBroadcast(ctx context.Context, request *domain.ScheduleBroadcastRequest) error

ScheduleBroadcast schedules a broadcast for sending

func (*BroadcastService) SelectWinner

func (s *BroadcastService) SelectWinner(ctx context.Context, workspaceID, broadcastID, templateID string) error

SelectWinner manually selects the winning variation for an A/B test

func (*BroadcastService) SendToIndividual

func (s *BroadcastService) SendToIndividual(ctx context.Context, request *domain.SendToIndividualRequest) error

SendToIndividual sends a broadcast to an individual recipient

func (*BroadcastService) SetTaskService

func (s *BroadcastService) SetTaskService(taskService domain.TaskService)

SetTaskService sets the task service (used to avoid circular dependencies)

func (*BroadcastService) UpdateBroadcast

func (s *BroadcastService) UpdateBroadcast(ctx context.Context, request *domain.UpdateBroadcastRequest) (*domain.Broadcast, error)

UpdateBroadcast updates an existing broadcast

type ConfigurationStatus

type ConfigurationStatus struct {
	SMTPConfigured        bool
	APIEndpointConfigured bool
	RootEmailConfigured   bool
	SMTPRelayConfigured   bool
}

ConfigurationStatus represents which configuration groups are set via environment

type ContactListService

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

func (*ContactListService) GetContactListByIDs

func (s *ContactListService) GetContactListByIDs(ctx context.Context, workspaceID string, email, listID string) (*domain.ContactList, error)

func (*ContactListService) GetContactsByListID

func (s *ContactListService) GetContactsByListID(ctx context.Context, workspaceID string, listID string) ([]*domain.ContactList, error)

func (*ContactListService) GetListsByEmail

func (s *ContactListService) GetListsByEmail(ctx context.Context, workspaceID string, email string) ([]*domain.ContactList, error)

func (*ContactListService) RemoveContactFromList

func (s *ContactListService) RemoveContactFromList(ctx context.Context, workspaceID string, email, listID string) error

func (*ContactListService) UpdateContactListStatus

func (s *ContactListService) UpdateContactListStatus(ctx context.Context, workspaceID string, email, listID string, status domain.ContactListStatus) (*domain.UpdateContactListStatusResult, error)

type ContactSegmentQueueProcessor

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

ContactSegmentQueueProcessor processes queued contacts for segment recomputation

func NewContactSegmentQueueProcessor

func NewContactSegmentQueueProcessor(
	queueRepo domain.ContactSegmentQueueRepository,
	segmentRepo domain.SegmentRepository,
	contactRepo domain.ContactRepository,
	workspaceRepo domain.WorkspaceRepository,
	logger logger.Logger,
) *ContactSegmentQueueProcessor

NewContactSegmentQueueProcessor creates a new contact segment queue processor

func (*ContactSegmentQueueProcessor) GetQueueSize

func (p *ContactSegmentQueueProcessor) GetQueueSize(ctx context.Context, workspaceID string) (int, error)

GetQueueSize returns the number of contacts waiting to be processed

func (*ContactSegmentQueueProcessor) ProcessQueue

func (p *ContactSegmentQueueProcessor) ProcessQueue(ctx context.Context, workspaceID string) (int, error)

ProcessQueue processes pending contacts in the queue for segment recomputation Uses a transaction to ensure row locks are held during processing Returns the number of contacts successfully processed

type ContactSegmentQueueTaskProcessor

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

ContactSegmentQueueTaskProcessor handles the execution of contact segment queue processing tasks This is a permanent, recurring task that runs for each workspace

func NewContactSegmentQueueTaskProcessor

func NewContactSegmentQueueTaskProcessor(
	queueProcessor *ContactSegmentQueueProcessor,
	taskRepo domain.TaskRepository,
	logger logger.Logger,
) *ContactSegmentQueueTaskProcessor

NewContactSegmentQueueTaskProcessor creates a new contact segment queue task processor

func (*ContactSegmentQueueTaskProcessor) CanProcess

func (p *ContactSegmentQueueTaskProcessor) CanProcess(taskType string) bool

CanProcess returns whether this processor can handle the given task type

func (*ContactSegmentQueueTaskProcessor) Process

func (p *ContactSegmentQueueTaskProcessor) Process(ctx context.Context, task *domain.Task, timeoutAt time.Time) (bool, error)

Process executes the contact segment queue processing task This task is permanent and recurring - it always reschedules itself for the next run It processes batches continuously until the timeout is reached

type ContactService

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

func NewContactService

func NewContactService(
	repo domain.ContactRepository,
	workspaceRepo domain.WorkspaceRepository,
	authService domain.AuthService,
	messageHistoryRepo domain.MessageHistoryRepository,
	inboundWebhookEventRepo domain.InboundWebhookEventRepository,
	contactListRepo domain.ContactListRepository,
	contactTimelineRepo domain.ContactTimelineRepository,
	logger logger.Logger,
) *ContactService

func (*ContactService) BatchImportContacts

func (s *ContactService) BatchImportContacts(ctx context.Context, workspaceID string, contacts []*domain.Contact, listIDs []string) *domain.BatchImportContactsResponse

func (*ContactService) CountContacts

func (s *ContactService) CountContacts(ctx context.Context, workspaceID string) (int, error)

func (*ContactService) DeleteContact

func (s *ContactService) DeleteContact(ctx context.Context, workspaceID string, email string) error

func (*ContactService) GetContactByEmail

func (s *ContactService) GetContactByEmail(ctx context.Context, workspaceID string, email string) (*domain.Contact, error)

func (*ContactService) GetContactByExternalID

func (s *ContactService) GetContactByExternalID(ctx context.Context, workspaceID string, externalID string) (*domain.Contact, error)

func (*ContactService) GetContacts

func (*ContactService) UpsertContact

func (s *ContactService) UpsertContact(ctx context.Context, workspaceID string, contact *domain.Contact) domain.UpsertContactOperation

type ContactTimelineService

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

ContactTimelineService implements domain.ContactTimelineService

func NewContactTimelineService

func NewContactTimelineService(repo domain.ContactTimelineRepository) *ContactTimelineService

NewContactTimelineService creates a new contact timeline service

func (*ContactTimelineService) List

func (s *ContactTimelineService) List(ctx context.Context, workspaceID string, email string, limit int, cursor *string) ([]*domain.ContactTimelineEntry, *string, error)

List retrieves timeline entries for a contact with pagination

type CustomEventService

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

func NewCustomEventService

func NewCustomEventService(
	repo domain.CustomEventRepository,
	contactRepo domain.ContactRepository,
	authService domain.AuthService,
	logger logger.Logger,
) *CustomEventService

func (*CustomEventService) GetEvent

func (s *CustomEventService) GetEvent(ctx context.Context, workspaceID, eventName, externalID string) (*domain.CustomEvent, error)

func (*CustomEventService) ImportEvents

func (*CustomEventService) ListEvents

func (*CustomEventService) UpsertEvent

UpsertEvent creates or updates a custom event with goal tracking and soft-delete support

type DNSVerificationService

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

DNSVerificationService handles DNS verification for custom domains

func NewDNSVerificationService

func NewDNSVerificationService(logger logger.Logger, expectedTarget string) *DNSVerificationService

NewDNSVerificationService creates a new DNS verification service

func (*DNSVerificationService) VerifyDomainOwnership

func (s *DNSVerificationService) VerifyDomainOwnership(ctx context.Context, domainURL string) error

VerifyDomainOwnership checks if the domain has correct CNAME or A record pointing to our service

func (*DNSVerificationService) VerifyTXTRecord

func (s *DNSVerificationService) VerifyTXTRecord(ctx context.Context, domainURL, expectedToken string) error

VerifyTXTRecord verifies domain ownership via TXT record (alternative method) This is useful for apex domains that cannot use CNAME

type DelayNodeExecutor

type DelayNodeExecutor struct{}

DelayNodeExecutor executes delay nodes

func NewDelayNodeExecutor

func NewDelayNodeExecutor() *DelayNodeExecutor

NewDelayNodeExecutor creates a new delay node executor

func (*DelayNodeExecutor) Execute

Execute processes a delay node

func (*DelayNodeExecutor) NodeType

func (e *DelayNodeExecutor) NodeType() domain.NodeType

NodeType returns the node type this executor handles

type DemoService

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

DemoService handles demo workspace operations

func NewDemoService

func NewDemoService(
	logger logger.Logger,
	config *config.Config,
	workspaceService *WorkspaceService,
	userService *UserService,
	contactService *ContactService,
	listService *ListService,
	contactListService *ContactListService,
	templateService *TemplateService,
	emailService *EmailService,
	broadcastService *BroadcastService,
	taskService *TaskService,
	transactionalNotificationService *TransactionalNotificationService,
	inboundWebhookEventService *InboundWebhookEventService,
	webhookRegistrationService *WebhookRegistrationService,
	messageHistoryService *MessageHistoryService,
	notificationCenterService *NotificationCenterService,
	segmentService domain.SegmentService,
	workspaceRepo domain.WorkspaceRepository,
	taskRepo domain.TaskRepository,
	messageHistoryRepo domain.MessageHistoryRepository,
	inboundWebhookEventRepo domain.InboundWebhookEventRepository,
	broadcastRepo domain.BroadcastRepository,
	customEventRepo domain.CustomEventRepository,
	webhookSubscriptionService *WebhookSubscriptionService,
) *DemoService

NewDemoService creates a new demo service instance

func (*DemoService) ResetDemo

func (s *DemoService) ResetDemo(ctx context.Context) error

ResetDemo deletes all existing workspaces and tasks, then creates a new demo workspace

func (*DemoService) VerifyRootEmailHMAC

func (s *DemoService) VerifyRootEmailHMAC(providedHMAC string) bool

VerifyRootEmailHMAC verifies the HMAC of the root email

type EmailNodeExecutor

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

EmailNodeExecutor executes email nodes

func NewEmailNodeExecutor

func NewEmailNodeExecutor(
	emailQueueRepo domain.EmailQueueRepository,
	templateRepo domain.TemplateRepository,
	workspaceRepo domain.WorkspaceRepository,
	apiEndpoint string,
	log logger.Logger,
) *EmailNodeExecutor

NewEmailNodeExecutor creates a new email node executor

func (*EmailNodeExecutor) Execute

Execute processes an email node by enqueuing to the email queue

func (*EmailNodeExecutor) NodeType

func (e *EmailNodeExecutor) NodeType() domain.NodeType

NodeType returns the node type this executor handles

type EmailSender

type EmailSender interface {
	SendMagicCode(email, code string) error
}

type EmailService

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

func NewEmailService

func NewEmailService(
	logger logger.Logger,
	authService domain.AuthService,
	secretKey string,
	isDemo bool,
	workspaceRepo domain.WorkspaceRepository,
	templateRepo domain.TemplateRepository,
	templateService domain.TemplateService,
	messageRepo domain.MessageHistoryRepository,
	httpClient domain.HTTPClient,
	webhookEndpoint string,
	apiEndpoint string,
) *EmailService

NewEmailService creates a new EmailService instance

func (*EmailService) OpenEmail

func (s *EmailService) OpenEmail(ctx context.Context, messageID string, workspaceID string) error

func (*EmailService) SendEmail

func (s *EmailService) SendEmail(ctx context.Context, request domain.SendEmailProviderRequest, isMarketing bool) error

SendEmail sends an email using the specified provider

func (*EmailService) SendEmailForTemplate

func (s *EmailService) SendEmailForTemplate(ctx context.Context, request domain.SendEmailRequest) error

SendEmailForTemplate handles sending through the email channel

func (*EmailService) TestEmailProvider

func (s *EmailService) TestEmailProvider(ctx context.Context, workspaceID string, provider domain.EmailProvider, to string) error

TestEmailProvider sends a test email to verify the provider configuration works

func (s *EmailService) VisitLink(ctx context.Context, messageID string, workspaceID string) error

type EnvironmentConfig

type EnvironmentConfig struct {
	RootEmail              string
	APIEndpoint            string
	SMTPHost               string
	SMTPPort               int
	SMTPUsername           string
	SMTPPassword           string
	SMTPFromEmail          string
	SMTPFromName           string
	SMTPUseTLS             string // "true", "false", or "" (empty = not set, defaults to true)
	SMTPRelayEnabled       string // "true", "false", or "" (empty = not set, allows setup wizard to configure)
	SMTPRelayDomain        string
	SMTPRelayPort          int
	SMTPRelayTLSCertBase64 string
	SMTPRelayTLSKeyBase64  string
}

EnvironmentConfig holds configuration from environment variables

type FilterNodeExecutor

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

FilterNodeExecutor executes filter nodes using database queries

func NewFilterNodeExecutor

func NewFilterNodeExecutor(queryBuilder *QueryBuilder, workspaceRepo domain.WorkspaceRepository) *FilterNodeExecutor

NewFilterNodeExecutor creates a new filter node executor

func (*FilterNodeExecutor) Execute

Execute processes a filter node

func (*FilterNodeExecutor) NodeType

func (e *FilterNodeExecutor) NodeType() domain.NodeType

NodeType returns the node type this executor handles

type FirecrawlScrapeOptions

type FirecrawlScrapeOptions struct {
	Formats         []string `json:"formats,omitempty"`         // Output formats
	OnlyMainContent *bool    `json:"onlyMainContent,omitempty"` // Extract only main content
}

FirecrawlScrapeOptions contains scrape options for search results

type FirecrawlScrapeRequest

type FirecrawlScrapeRequest struct {
	URL                 string   `json:"url"`
	Formats             []string `json:"formats"`                       // ["markdown", "html", "links", "screenshot"]
	OnlyMainContent     *bool    `json:"onlyMainContent,omitempty"`     // Extract only main content
	IncludeTags         []string `json:"includeTags,omitempty"`         // HTML tags to include
	ExcludeTags         []string `json:"excludeTags,omitempty"`         // HTML tags to exclude
	WaitFor             *int     `json:"waitFor,omitempty"`             // Milliseconds to wait before scraping
	Timeout             *int     `json:"timeout,omitempty"`             // Request timeout in milliseconds
	Mobile              *bool    `json:"mobile,omitempty"`              // Render as mobile device
	SkipTLSVerification *bool    `json:"skipTlsVerification,omitempty"` // Skip SSL certificate validation
}

FirecrawlScrapeRequest is the request for scraping a URL

type FirecrawlScrapeResponse

type FirecrawlScrapeResponse struct {
	Success bool `json:"success"`
	Data    struct {
		Markdown string `json:"markdown,omitempty"`
		HTML     string `json:"html,omitempty"`
		Title    string `json:"title,omitempty"`
	} `json:"data"`
	Error string `json:"error,omitempty"`
}

FirecrawlScrapeResponse is the response from scraping

type FirecrawlSearchRequest

type FirecrawlSearchRequest struct {
	Query         string                  `json:"query"`
	Limit         int                     `json:"limit,omitempty"`         // default 5
	Lang          string                  `json:"lang,omitempty"`          // Language code (e.g., "en", "de")
	Country       string                  `json:"country,omitempty"`       // Country code (e.g., "US", "DE")
	Location      string                  `json:"location,omitempty"`      // Location string (e.g., "San Francisco,California,United States")
	TBS           string                  `json:"tbs,omitempty"`           // Time-based search filter (qdr:d, qdr:w, qdr:m)
	ScrapeOptions *FirecrawlScrapeOptions `json:"scrapeOptions,omitempty"` // Options for scraping search results
}

FirecrawlSearchRequest is the request for web search

type FirecrawlSearchResponse

type FirecrawlSearchResponse struct {
	Success bool                    `json:"success"`
	Data    []FirecrawlSearchResult `json:"data"`
	Error   string                  `json:"error,omitempty"`
}

FirecrawlSearchResponse is the response from search

type FirecrawlSearchResult

type FirecrawlSearchResult struct {
	URL         string `json:"url"`
	Title       string `json:"title"`
	Description string `json:"description"`
}

FirecrawlSearchResult is a single search result

type FirecrawlService

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

FirecrawlService handles interactions with the Firecrawl API

func NewFirecrawlService

func NewFirecrawlService(log logger.Logger) *FirecrawlService

NewFirecrawlService creates a new Firecrawl service

func (*FirecrawlService) Scrape

Scrape fetches a URL and returns content based on options

func (*FirecrawlService) Search

Search performs a web search and returns results

type InboundWebhookEventService

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

InboundWebhookEventService implements the domain.InboundWebhookEventServiceInterface

func NewInboundWebhookEventService

func NewInboundWebhookEventService(
	repo domain.InboundWebhookEventRepository,
	authService domain.AuthService,
	logger logger.Logger,
	workspaceRepo domain.WorkspaceRepository,
	messageHistoryRepo domain.MessageHistoryRepository,
) *InboundWebhookEventService

NewInboundWebhookEventService creates a new InboundWebhookEventService

func (*InboundWebhookEventService) ListEvents

ListEvents retrieves all webhook events for a workspace

func (*InboundWebhookEventService) ProcessWebhook

func (s *InboundWebhookEventService) ProcessWebhook(ctx context.Context, workspaceID string, integrationID string, rawPayload []byte) error

ProcessWebhook processes a webhook event from an email provider

type InvitationClaims

type InvitationClaims struct {
	InvitationID string `json:"invitation_id"`
	WorkspaceID  string `json:"workspace_id"`
	Email        string `json:"email"`
	jwt.RegisteredClaims
}

InvitationClaims for workspace invitation tokens

type LLMService

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

LLMService implements the LLM chat functionality

func NewLLMService

func NewLLMService(config LLMServiceConfig) *LLMService

NewLLMService creates a new LLM service

func (*LLMService) StreamChat

func (s *LLMService) StreamChat(ctx context.Context, req *domain.LLMChatRequest, onEvent func(domain.LLMChatEvent) error) error

StreamChat implements streaming chat with Anthropic

type LLMServiceConfig

type LLMServiceConfig struct {
	AuthService   domain.AuthService
	WorkspaceRepo domain.WorkspaceRepository
	Logger        logger.Logger
	ToolRegistry  *ServerSideToolRegistry
}

LLMServiceConfig contains configuration for the LLM service

type ListService

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

func NewListService

func NewListService(repo domain.ListRepository, workspaceRepo domain.WorkspaceRepository, contactListRepo domain.ContactListRepository, contactRepo domain.ContactRepository, messageHistoryRepo domain.MessageHistoryRepository, authService domain.AuthService, emailService domain.EmailServiceInterface, logger logger.Logger, apiEndpoint string, blogCache cache.Cache) *ListService

func (*ListService) CreateList

func (s *ListService) CreateList(ctx context.Context, workspaceID string, list *domain.List) error

func (*ListService) DeleteList

func (s *ListService) DeleteList(ctx context.Context, workspaceID string, id string) error

func (*ListService) GetListByID

func (s *ListService) GetListByID(ctx context.Context, workspaceID string, id string) (*domain.List, error)

func (*ListService) GetListStats

func (s *ListService) GetListStats(ctx context.Context, workspaceID string, id string) (*domain.ListStats, error)

func (*ListService) GetLists

func (s *ListService) GetLists(ctx context.Context, workspaceID string) ([]*domain.List, error)

func (*ListService) SubscribeToLists

func (s *ListService) SubscribeToLists(ctx context.Context, payload *domain.SubscribeToListsRequest, hasBearerToken bool) error

this method is used to subscribe a contact to a list request can come from 3 different sources: 1. API 2. Frontend (authenticated with email and email_hmac) 3. Frontend (unauthenticated with email)

func (*ListService) UnsubscribeFromLists

func (s *ListService) UnsubscribeFromLists(ctx context.Context, payload *domain.UnsubscribeFromListsRequest, hasBearerToken bool) error

this method is used to unsubscribe a contact from a list request can come from 2 different sources: 1. API 2. Frontend (authenticated with email and email_hmac)

func (*ListService) UpdateList

func (s *ListService) UpdateList(ctx context.Context, workspaceID string, list *domain.List) error

type ListStatusBranchNodeExecutor

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

ListStatusBranchNodeExecutor executes list status branch nodes

func NewListStatusBranchNodeExecutor

func NewListStatusBranchNodeExecutor(contactListRepo domain.ContactListRepository) *ListStatusBranchNodeExecutor

NewListStatusBranchNodeExecutor creates a new list status branch node executor

func (*ListStatusBranchNodeExecutor) Execute

Execute processes a list status branch node

func (*ListStatusBranchNodeExecutor) NodeType

NodeType returns the node type this executor handles

type MailgunService

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

MailgunService implements the domain.MailgunServiceInterface

func NewMailgunService

func NewMailgunService(httpClient domain.HTTPClient, authService domain.AuthService, logger logger.Logger, webhookEndpoint string) *MailgunService

NewMailgunService creates a new instance of MailgunService

func (*MailgunService) CreateWebhook

CreateWebhook creates a new webhook

func (*MailgunService) DeleteWebhook

func (s *MailgunService) DeleteWebhook(ctx context.Context, config domain.MailgunSettings, webhookID string) error

DeleteWebhook deletes a webhook by ID

func (*MailgunService) GetWebhook

func (s *MailgunService) GetWebhook(ctx context.Context, config domain.MailgunSettings, webhookID string) (*domain.MailgunWebhook, error)

GetWebhook retrieves a webhook by ID

func (*MailgunService) GetWebhookStatus

func (s *MailgunService) GetWebhookStatus(
	ctx context.Context,
	workspaceID string,
	integrationID string,
	providerConfig *domain.EmailProvider,
) (*domain.WebhookRegistrationStatus, error)

GetWebhookStatus implements the domain.WebhookProvider interface for Mailgun

func (*MailgunService) ListWebhooks

ListWebhooks retrieves all registered webhooks for a domain

func (*MailgunService) RegisterWebhooks

func (s *MailgunService) RegisterWebhooks(
	ctx context.Context,
	workspaceID string,
	integrationID string,
	baseURL string,
	eventTypes []domain.EmailEventType,
	providerConfig *domain.EmailProvider,
) (*domain.WebhookRegistrationStatus, error)

RegisterWebhooks implements the domain.WebhookProvider interface for Mailgun

func (*MailgunService) SendEmail

SendEmail sends an email using Mailgun

func (*MailgunService) TestWebhook

func (s *MailgunService) TestWebhook(ctx context.Context, config domain.MailgunSettings, webhookID string, eventType string) error

TestWebhook sends a test event to a webhook

func (*MailgunService) UnregisterWebhooks

func (s *MailgunService) UnregisterWebhooks(
	ctx context.Context,
	workspaceID string,
	integrationID string,
	providerConfig *domain.EmailProvider,
) error

UnregisterWebhooks implements the domain.WebhookProvider interface for Mailgun

func (*MailgunService) UpdateWebhook

func (s *MailgunService) UpdateWebhook(ctx context.Context, config domain.MailgunSettings, webhookID string, webhook domain.MailgunWebhook) (*domain.MailgunWebhook, error)

UpdateWebhook updates an existing webhook

type MailjetService

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

MailjetService implements the domain.MailjetServiceInterface

func NewMailjetService

func NewMailjetService(httpClient domain.HTTPClient, authService domain.AuthService, logger logger.Logger) *MailjetService

NewMailjetService creates a new instance of MailjetService

func (*MailjetService) CreateWebhook

CreateWebhook creates a new webhook

func (*MailjetService) DeleteWebhook

func (s *MailjetService) DeleteWebhook(ctx context.Context, config domain.MailjetSettings, webhookID int64) error

DeleteWebhook deletes a webhook by ID

func (*MailjetService) GetWebhook

func (s *MailjetService) GetWebhook(ctx context.Context, config domain.MailjetSettings, webhookID int64) (*domain.MailjetWebhook, error)

GetWebhook retrieves a webhook by ID

func (*MailjetService) GetWebhookStatus

func (s *MailjetService) GetWebhookStatus(
	ctx context.Context,
	workspaceID string,
	integrationID string,
	providerConfig *domain.EmailProvider,
) (*domain.WebhookRegistrationStatus, error)

GetWebhookStatus implements the domain.WebhookProvider interface for Mailjet

func (*MailjetService) ListWebhooks

ListWebhooks retrieves all registered webhooks

func (*MailjetService) RegisterWebhooks

func (s *MailjetService) RegisterWebhooks(
	ctx context.Context,
	workspaceID string,
	integrationID string,
	baseURL string,
	eventTypes []domain.EmailEventType,
	providerConfig *domain.EmailProvider,
) (*domain.WebhookRegistrationStatus, error)

RegisterWebhooks implements the domain.WebhookProvider interface for Mailjet

func (*MailjetService) SendEmail

SendEmail sends an email using Mailjet

func (*MailjetService) TestWebhook

func (s *MailjetService) TestWebhook(ctx context.Context, config domain.MailjetSettings, webhookID string, eventType string) error

TestWebhook implements the domain.WebhookProvider interface for Mailjet Mailjet doesn't support testing webhooks directly

func (*MailjetService) UnregisterWebhooks

func (s *MailjetService) UnregisterWebhooks(
	ctx context.Context,
	workspaceID string,
	integrationID string,
	providerConfig *domain.EmailProvider,
) error

UnregisterWebhooks implements the domain.WebhookProvider interface for Mailjet

func (*MailjetService) UpdateWebhook

func (s *MailjetService) UpdateWebhook(ctx context.Context, config domain.MailjetSettings, webhookID int64, webhook domain.MailjetWebhook) (*domain.MailjetWebhook, error)

UpdateWebhook updates an existing webhook

type MessageHistoryService

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

MessageHistoryService implements domain.MessageHistoryService interface

func NewMessageHistoryService

func NewMessageHistoryService(repo domain.MessageHistoryRepository, workspaceRepo domain.WorkspaceRepository, logger logger.Logger, authService domain.AuthService) *MessageHistoryService

NewMessageHistoryService creates a new message history service

func (*MessageHistoryService) GetBroadcastStats

func (s *MessageHistoryService) GetBroadcastStats(ctx context.Context, workspaceID string, id string) (*domain.MessageHistoryStatusSum, error)

func (*MessageHistoryService) GetBroadcastVariationStats

func (s *MessageHistoryService) GetBroadcastVariationStats(ctx context.Context, workspaceID, broadcastID, templateID string) (*domain.MessageHistoryStatusSum, error)

GetBroadcastVariationStats retrieves statistics for a specific variation of a broadcast

func (*MessageHistoryService) ListMessages

func (s *MessageHistoryService) ListMessages(ctx context.Context, workspaceID string, params domain.MessageListParams) (*domain.MessageListResult, error)

ListMessages retrieves messages for a workspace with cursor-based pagination and filters

type NodeExecutionParams

type NodeExecutionParams struct {
	WorkspaceID      string
	Contact          *domain.ContactAutomation
	Node             *domain.AutomationNode
	Automation       *domain.Automation
	ContactData      *domain.Contact        // Full contact data for template rendering
	ExecutionContext map[string]interface{} // Reconstructed context from previous node executions
}

NodeExecutionParams contains all data needed to execute a node

type NodeExecutionResult

type NodeExecutionResult struct {
	NextNodeID  *string                        // Which node to go to next (nil = completed)
	ScheduledAt *time.Time                     // When to process next (nil = now)
	Status      domain.ContactAutomationStatus // New status (active, completed, exited)
	Context     map[string]interface{}         // Updated context
	Output      map[string]interface{}         // Output for node execution log
	Error       error                          // Error if failed
}

NodeExecutionResult contains the outcome of executing a node

type NodeExecutor

type NodeExecutor interface {
	Execute(ctx context.Context, params NodeExecutionParams) (*NodeExecutionResult, error)
	NodeType() domain.NodeType
}

NodeExecutor executes a specific node type

type NotificationCenterService

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

func NewNotificationCenterService

func NewNotificationCenterService(
	contactRepo domain.ContactRepository,
	workspaceRepo domain.WorkspaceRepository,
	listRepo domain.ListRepository,
	logger logger.Logger,
) *NotificationCenterService

func (*NotificationCenterService) GetContactPreferences

func (s *NotificationCenterService) GetContactPreferences(ctx context.Context, workspaceID string, email string, emailHMAC string) (*domain.ContactPreferencesResponse, error)

GetContactPreferences returns the notification center data for a contact It returns public lists and public transactional notifications

type PostmarkService

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

PostmarkService implements the domain.PostmarkServiceInterface

func NewPostmarkService

func NewPostmarkService(httpClient domain.HTTPClient, authService domain.AuthService, logger logger.Logger) *PostmarkService

NewPostmarkService creates a new instance of PostmarkService

func (*PostmarkService) GetWebhook

func (s *PostmarkService) GetWebhook(ctx context.Context, config domain.PostmarkSettings, webhookID int) (*domain.PostmarkWebhookResponse, error)

GetWebhook retrieves a specific webhook by ID

func (*PostmarkService) GetWebhookStatus

func (s *PostmarkService) GetWebhookStatus(
	ctx context.Context,
	workspaceID string,
	integrationID string,
	providerConfig *domain.EmailProvider,
) (*domain.WebhookRegistrationStatus, error)

GetWebhookStatus implements the domain.WebhookProvider interface for Postmark

func (*PostmarkService) ListWebhooks

ListWebhooks retrieves all registered webhooks

func (*PostmarkService) RegisterWebhook

RegisterWebhook registers a new webhook

func (*PostmarkService) RegisterWebhooks

func (s *PostmarkService) RegisterWebhooks(
	ctx context.Context,
	workspaceID string,
	integrationID string,
	baseURL string,
	eventTypes []domain.EmailEventType,
	providerConfig *domain.EmailProvider,
) (*domain.WebhookRegistrationStatus, error)

RegisterWebhooks implements the domain.WebhookProvider interface for Postmark

func (*PostmarkService) SendEmail

SendEmail sends an email using Postmark

func (*PostmarkService) TestWebhook

func (s *PostmarkService) TestWebhook(ctx context.Context, config domain.PostmarkSettings, webhookID int, eventType domain.EmailEventType) error

TestWebhook sends a test event to the webhook

func (*PostmarkService) UnregisterWebhook

func (s *PostmarkService) UnregisterWebhook(ctx context.Context, config domain.PostmarkSettings, webhookID int) error

UnregisterWebhook removes a webhook by ID

func (*PostmarkService) UnregisterWebhooks

func (s *PostmarkService) UnregisterWebhooks(
	ctx context.Context,
	workspaceID string,
	integrationID string,
	providerConfig *domain.EmailProvider,
) error

UnregisterWebhooks implements the domain.WebhookProvider interface for Postmark

func (*PostmarkService) UpdateWebhook

UpdateWebhook updates an existing webhook

type QueryBuilder

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

QueryBuilder converts segment tree structures into safe, parameterized SQL queries

func NewQueryBuilder

func NewQueryBuilder() *QueryBuilder

NewQueryBuilder creates a new query builder with field and operator whitelists

func (*QueryBuilder) BuildSQL

func (qb *QueryBuilder) BuildSQL(tree *domain.TreeNode) (string, []interface{}, error)

BuildSQL converts a segment tree into parameterized SQL Returns: sql string, args []interface{}, error

func (*QueryBuilder) BuildTriggerCondition

func (qb *QueryBuilder) BuildTriggerCondition(tree *domain.TreeNode, emailRef string) (string, []interface{}, error)

BuildTriggerCondition generates SQL for use in PostgreSQL trigger WHEN clauses. Unlike BuildSQL which returns "SELECT email FROM contacts WHERE ...", this returns an EXISTS subquery format with the email reference substituted.

Parameters:

  • tree: The TreeNode conditions to translate
  • emailRef: The email reference in trigger context (e.g., "NEW.email")

Returns SQL condition string and args (args will be embedded by caller using embedArgs)

type RemoveFromListNodeExecutor

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

RemoveFromListNodeExecutor executes remove-from-list nodes

func NewRemoveFromListNodeExecutor

func NewRemoveFromListNodeExecutor(contactListRepo domain.ContactListRepository) *RemoveFromListNodeExecutor

NewRemoveFromListNodeExecutor creates a new remove-from-list node executor

func (*RemoveFromListNodeExecutor) Execute

Execute processes a remove-from-list node

func (*RemoveFromListNodeExecutor) NodeType

NodeType returns the node type this executor handles

type SESService

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

SESService implements the domain.SESServiceInterface

func NewSESService

func NewSESService(authService domain.AuthService, logger logger.Logger) *SESService

NewSESService creates a new instance of SESService with default factories

func NewSESServiceWithClients

func NewSESServiceWithClients(
	authService domain.AuthService,
	logger logger.Logger,
	sessionFactory func(config domain.AmazonSESSettings) (*session.Session, error),
	sesClientFactory func(sess *session.Session) domain.SESWebhookClient,
	snsClientFactory func(sess *session.Session) domain.SNSWebhookClient,
	sesEmailClientFactory func(sess *session.Session) domain.SESClient,
) *SESService

NewSESServiceWithClients creates a new instance of SESService with custom factories for testing

func (*SESService) CreateConfigurationSet

func (s *SESService) CreateConfigurationSet(ctx context.Context, config domain.AmazonSESSettings, name string) error

CreateConfigurationSet creates a new configuration set

func (*SESService) CreateEventDestination

func (s *SESService) CreateEventDestination(ctx context.Context, config domain.AmazonSESSettings, destination domain.SESConfigurationSetEventDestination) error

CreateEventDestination creates an event destination in a configuration set

func (*SESService) CreateSNSTopic

func (s *SESService) CreateSNSTopic(ctx context.Context, config domain.AmazonSESSettings, topicConfig domain.SESTopicConfig) (string, error)

CreateSNSTopic creates a new SNS topic for notifications

func (*SESService) DeleteConfigurationSet

func (s *SESService) DeleteConfigurationSet(ctx context.Context, config domain.AmazonSESSettings, name string) error

DeleteConfigurationSet deletes a configuration set

func (*SESService) DeleteEventDestination

func (s *SESService) DeleteEventDestination(ctx context.Context, config domain.AmazonSESSettings, configSetName, destinationName string) error

DeleteEventDestination deletes an event destination

func (*SESService) DeleteSNSTopic

func (s *SESService) DeleteSNSTopic(ctx context.Context, config domain.AmazonSESSettings, topicARN string) error

DeleteSNSTopic deletes an SNS topic

func (*SESService) GetWebhookStatus

func (s *SESService) GetWebhookStatus(
	ctx context.Context,
	workspaceID string,
	integrationID string,
	providerConfig *domain.EmailProvider,
) (*domain.WebhookRegistrationStatus, error)

GetWebhookStatus implements the domain.WebhookProvider interface for SES

func (*SESService) ListConfigurationSets

func (s *SESService) ListConfigurationSets(ctx context.Context, config domain.AmazonSESSettings) ([]string, error)

ListConfigurationSets lists all configuration sets

func (*SESService) ListEventDestinations

func (s *SESService) ListEventDestinations(ctx context.Context, config domain.AmazonSESSettings, configSetName string) ([]domain.SESConfigurationSetEventDestination, error)

ListEventDestinations lists all event destinations for a configuration set

func (*SESService) RegisterWebhooks

func (s *SESService) RegisterWebhooks(
	ctx context.Context,
	workspaceID string,
	integrationID string,
	baseURL string,
	eventTypes []domain.EmailEventType,
	providerConfig *domain.EmailProvider,
) (*domain.WebhookRegistrationStatus, error)

RegisterWebhooks implements the domain.WebhookProvider interface for SES

func (*SESService) SendEmail

func (s *SESService) SendEmail(ctx context.Context, request domain.SendEmailProviderRequest) error

SendEmail sends an email using AWS SES

func (*SESService) UnregisterWebhooks

func (s *SESService) UnregisterWebhooks(
	ctx context.Context,
	workspaceID string,
	integrationID string,
	providerConfig *domain.EmailProvider,
) error

UnregisterWebhooks implements the domain.WebhookProvider interface for SES

func (*SESService) UpdateEventDestination

func (s *SESService) UpdateEventDestination(ctx context.Context, config domain.AmazonSESSettings, destination domain.SESConfigurationSetEventDestination) error

UpdateEventDestination updates an event destination

type SMTPRelayHandlerService

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

SMTPRelayHandlerService handles incoming SMTP relay messages and converts them to transactional notifications

func NewSMTPRelayHandlerService

func NewSMTPRelayHandlerService(
	authService *AuthService,
	transactionalNotificationService domain.TransactionalNotificationService,
	workspaceRepo domain.WorkspaceRepository,
	logger logger.Logger,
	jwtSecret []byte,
	rateLimiter *ratelimiter.RateLimiter,
) *SMTPRelayHandlerService

NewSMTPRelayHandlerService creates a new SMTP relay handler service

func (*SMTPRelayHandlerService) Authenticate

func (s *SMTPRelayHandlerService) Authenticate(username, password string) (string, error)

Authenticate validates the SMTP credentials (api_email and api_key) Returns the user_id if authentication succeeds Note: workspace_id will be extracted from the JSON payload in the email body

func (*SMTPRelayHandlerService) HandleMessage

func (s *SMTPRelayHandlerService) HandleMessage(userID string, from string, to []string, data []byte) error

HandleMessage processes an incoming SMTP message and triggers a transactional notification The userID parameter is the authenticated API key user's ID

type SMTPService

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

SMTPService implements the domain.EmailProviderService interface for SMTP

func NewSMTPService

func NewSMTPService(logger logger.Logger) *SMTPService

NewSMTPService creates a new instance of SMTPService

func (*SMTPService) SendEmail

func (s *SMTPService) SendEmail(ctx context.Context, request domain.SendEmailProviderRequest) error

SendEmail sends an email using SMTP

type SMTPTestConfig

type SMTPTestConfig struct {
	Host     string
	Port     int
	Username string
	Password string
	UseTLS   bool
}

SMTPTestConfig represents SMTP configuration for testing

type ScrapeOptions

type ScrapeOptions struct {
	OnlyMainContent     bool     // Extract only main content (default true)
	Formats             []string // Output formats: "markdown", "html" (default ["markdown"])
	IncludeTags         []string // HTML tags to include (e.g., ["article", "main"])
	ExcludeTags         []string // HTML tags to exclude (e.g., ["nav", "footer"])
	WaitFor             int      // Milliseconds to wait before scraping (default 0)
	Timeout             int      // Request timeout in milliseconds (default 30000)
	Mobile              bool     // Render as mobile device (default false)
	SkipTLSVerification bool     // Skip SSL certificate validation (default false)
}

ScrapeOptions contains options for scraping

type SearchOptions

type SearchOptions struct {
	Limit                 int      // Maximum number of results (default 5)
	Lang                  string   // Language code (e.g., "en", "de")
	Country               string   // Country code (e.g., "US", "DE")
	Location              string   // Location string (e.g., "San Francisco,California,United States")
	TBS                   string   // Time-based search filter (qdr:d, qdr:w, qdr:m, qdr:y)
	ScrapeFormats         []string // Output formats for scraped results
	ScrapeOnlyMainContent bool     // Extract only main content from results
}

SearchOptions contains options for web search

type SegmentBuildProcessor

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

SegmentBuildProcessor handles the execution of segment building tasks

func NewSegmentBuildProcessor

func NewSegmentBuildProcessor(
	segmentRepo domain.SegmentRepository,
	contactRepo domain.ContactRepository,
	taskRepo domain.TaskRepository,
	workspaceRepo domain.WorkspaceRepository,
	logger logger.Logger,
) *SegmentBuildProcessor

NewSegmentBuildProcessor creates a new segment build processor

func (*SegmentBuildProcessor) CanProcess

func (p *SegmentBuildProcessor) CanProcess(taskType string) bool

CanProcess returns whether this processor can handle the given task type

func (*SegmentBuildProcessor) Process

func (p *SegmentBuildProcessor) Process(ctx context.Context, task *domain.Task, timeoutAt time.Time) (completed bool, err error)

Process executes or continues a segment building task

type SegmentRecomputeTaskProcessor

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

SegmentRecomputeTaskProcessor handles the execution of segment recompute checking tasks This is a permanent, recurring task that runs for each workspace

func NewSegmentRecomputeTaskProcessor

func NewSegmentRecomputeTaskProcessor(
	segmentRepo domain.SegmentRepository,
	taskRepo domain.TaskRepository,
	taskService domain.TaskService,
	logger logger.Logger,
) *SegmentRecomputeTaskProcessor

NewSegmentRecomputeTaskProcessor creates a new segment recompute task processor

func (*SegmentRecomputeTaskProcessor) CanProcess

func (p *SegmentRecomputeTaskProcessor) CanProcess(taskType string) bool

CanProcess returns whether this processor can handle the given task type

func (*SegmentRecomputeTaskProcessor) Process

func (p *SegmentRecomputeTaskProcessor) Process(ctx context.Context, task *domain.Task, timeoutAt time.Time) (bool, error)

Process executes the segment recompute checking task This task is permanent and recurring - it always reschedules itself for the next run It checks for segments due for recomputation and creates build tasks for them

type SegmentService

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

SegmentService handles segment operations

func NewSegmentService

func NewSegmentService(
	segmentRepo domain.SegmentRepository,
	workspaceRepo domain.WorkspaceRepository,
	taskService domain.TaskService,
	logger logger.Logger,
) *SegmentService

NewSegmentService creates a new segment service

func (*SegmentService) CreateSegment

func (s *SegmentService) CreateSegment(ctx context.Context, req *domain.CreateSegmentRequest) (*domain.Segment, error)

CreateSegment creates a new segment

func (*SegmentService) DeleteSegment

func (s *SegmentService) DeleteSegment(ctx context.Context, req *domain.DeleteSegmentRequest) error

DeleteSegment deletes a segment

func (*SegmentService) GetSegment

GetSegment retrieves a segment by ID

func (*SegmentService) GetSegmentContacts

func (s *SegmentService) GetSegmentContacts(ctx context.Context, workspaceID, segmentID string, limit, offset int) ([]string, error)

GetSegmentContacts retrieves contacts that belong to a segment

func (*SegmentService) ListSegments

func (s *SegmentService) ListSegments(ctx context.Context, req *domain.GetSegmentsRequest) ([]*domain.Segment, error)

ListSegments retrieves all segments for a workspace

func (*SegmentService) PreviewSegment

func (s *SegmentService) PreviewSegment(ctx context.Context, workspaceID string, tree *domain.TreeNode, limit int) (*domain.PreviewSegmentResponse, error)

PreviewSegment executes the segment query and returns a preview of matching contacts This does NOT save the results to the database

func (*SegmentService) RebuildSegment

func (s *SegmentService) RebuildSegment(ctx context.Context, workspaceID, segmentID string) error

RebuildSegment triggers a rebuild of segment membership

func (*SegmentService) UpdateSegment

func (s *SegmentService) UpdateSegment(ctx context.Context, req *domain.UpdateSegmentRequest) (*domain.Segment, error)

UpdateSegment updates an existing segment

type ServerSideToolRegistry

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

ServerSideToolRegistry manages server-side tool definitions and execution

func NewServerSideToolRegistry

func NewServerSideToolRegistry(firecrawlService *FirecrawlService, log logger.Logger) *ServerSideToolRegistry

NewServerSideToolRegistry creates a new server-side tool registry

func (*ServerSideToolRegistry) ExecuteTool

func (r *ServerSideToolRegistry) ExecuteTool(ctx context.Context, settings *domain.FirecrawlSettings, toolName string, input map[string]interface{}) (string, error)

ExecuteTool executes a server-side tool and returns the result as string

func (*ServerSideToolRegistry) GetAvailableTools

func (r *ServerSideToolRegistry) GetAvailableTools() []domain.LLMTool

GetAvailableTools returns tools to inject when Firecrawl is configured

func (*ServerSideToolRegistry) IsServerSideTool

func (r *ServerSideToolRegistry) IsServerSideTool(toolName string) bool

IsServerSideTool checks if a tool should be executed server-side

type SettingService

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

SettingService provides methods for managing system settings

func NewSettingService

func NewSettingService(repo domain.SettingRepository) *SettingService

NewSettingService creates a new SettingService

func (*SettingService) GetSetting

func (s *SettingService) GetSetting(ctx context.Context, key string) (string, error)

GetSetting retrieves a single setting by key

func (*SettingService) GetSystemConfig

func (s *SettingService) GetSystemConfig(ctx context.Context, secretKey string) (*SystemConfig, error)

GetSystemConfig loads all system settings from the database

func (*SettingService) IsInstalled

func (s *SettingService) IsInstalled(ctx context.Context) (bool, error)

IsInstalled checks if the system has been installed

func (*SettingService) SetSetting

func (s *SettingService) SetSetting(ctx context.Context, key, value string) error

SetSetting sets a single setting

func (*SettingService) SetSystemConfig

func (s *SettingService) SetSystemConfig(ctx context.Context, config *SystemConfig, secretKey string) error

SetSystemConfig stores all system settings in the database

type SetupConfig

type SetupConfig struct {
	RootEmail              string
	APIEndpoint            string
	SMTPHost               string
	SMTPPort               int
	SMTPUsername           string
	SMTPPassword           string
	SMTPFromEmail          string
	SMTPFromName           string
	SMTPUseTLS             bool
	TelemetryEnabled       bool
	CheckForUpdates        bool
	SMTPRelayEnabled       bool
	SMTPRelayDomain        string
	SMTPRelayPort          int
	SMTPRelayTLSCertBase64 string
	SMTPRelayTLSKeyBase64  string
}

SetupConfig represents the setup initialization configuration

type SetupService

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

SetupService handles setup wizard operations

func NewSetupService

func NewSetupService(
	settingService *SettingService,
	userService *UserService,
	userRepo domain.UserRepository,
	logger logger.Logger,
	secretKey string,
	onSetupCompleted func() error,
	envConfig *EnvironmentConfig,
) *SetupService

NewSetupService creates a new setup service

func (*SetupService) GetConfigurationStatus

func (s *SetupService) GetConfigurationStatus() *ConfigurationStatus

GetConfigurationStatus checks which configuration groups are set via environment

func (*SetupService) Initialize

func (s *SetupService) Initialize(ctx context.Context, config *SetupConfig) error

Initialize completes the setup wizard

func (*SetupService) TestSMTPConnection

func (s *SetupService) TestSMTPConnection(ctx context.Context, config *SMTPTestConfig) error

TestSMTPConnection tests the SMTP connection with the provided configuration

func (*SetupService) ValidateSetupConfig

func (s *SetupService) ValidateSetupConfig(config *SetupConfig) error

ValidateSetupConfig validates the setup configuration, only checking user-provided fields

type SparkPostService

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

SparkPostService implements the domain.SparkPostServiceInterface

func NewSparkPostService

func NewSparkPostService(httpClient domain.HTTPClient, authService domain.AuthService, logger logger.Logger) *SparkPostService

NewSparkPostService creates a new instance of SparkPostService

func (*SparkPostService) CreateWebhook

CreateWebhook creates a new webhook

func (*SparkPostService) DeleteWebhook

func (s *SparkPostService) DeleteWebhook(ctx context.Context, config domain.SparkPostSettings, webhookID string) error

DeleteWebhook deletes a webhook by ID

func (*SparkPostService) GetWebhook

GetWebhook retrieves a webhook by ID

func (*SparkPostService) GetWebhookStatus

func (s *SparkPostService) GetWebhookStatus(
	ctx context.Context,
	workspaceID string,
	integrationID string,
	providerConfig *domain.EmailProvider,
) (*domain.WebhookRegistrationStatus, error)

GetWebhookStatus implements the domain.WebhookProvider interface for SparkPost

func (*SparkPostService) ListWebhooks

ListWebhooks retrieves all registered webhooks

func (*SparkPostService) RegisterWebhooks

func (s *SparkPostService) RegisterWebhooks(
	ctx context.Context,
	workspaceID string,
	integrationID string,
	baseURL string,
	eventTypes []domain.EmailEventType,
	providerConfig *domain.EmailProvider,
) (*domain.WebhookRegistrationStatus, error)

RegisterWebhooks implements the domain.WebhookProvider interface for SparkPost

func (*SparkPostService) SendEmail

SendEmail sends an email using SparkPost

func (*SparkPostService) TestWebhook

func (s *SparkPostService) TestWebhook(ctx context.Context, config domain.SparkPostSettings, webhookID string) error

TestWebhook sends a test event to a webhook

func (*SparkPostService) UnregisterWebhooks

func (s *SparkPostService) UnregisterWebhooks(
	ctx context.Context,
	workspaceID string,
	integrationID string,
	providerConfig *domain.EmailProvider,
) error

UnregisterWebhooks implements the domain.WebhookProvider interface for SparkPost

func (*SparkPostService) UpdateWebhook

UpdateWebhook updates an existing webhook

func (*SparkPostService) ValidateWebhook

func (s *SparkPostService) ValidateWebhook(ctx context.Context, config domain.SparkPostSettings, webhook domain.SparkPostWebhook) (bool, error)

ValidateWebhook validates a webhook's configuration

type SupabaseService

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

SupabaseService handles Supabase webhook processing

func NewSupabaseService

func NewSupabaseService(
	workspaceRepo domain.WorkspaceRepository,
	emailService domain.EmailServiceInterface,
	contactService domain.ContactService,
	listRepo domain.ListRepository,
	contactListRepo domain.ContactListRepository,
	templateRepo domain.TemplateRepository,
	templateService domain.TemplateService,
	transactionalRepo domain.TransactionalNotificationRepository,
	transactionalService domain.TransactionalNotificationService,
	inboundWebhookEventRepo domain.InboundWebhookEventRepository,
	logger logger.Logger,
) *SupabaseService

NewSupabaseService creates a new Supabase service

func (*SupabaseService) CreateDefaultSupabaseNotifications

func (s *SupabaseService) CreateDefaultSupabaseNotifications(ctx context.Context, workspaceID, integrationID string, mappings *domain.SupabaseTemplateMappings) error

CreateDefaultSupabaseNotifications creates the default Supabase auth email transactional notifications

func (*SupabaseService) CreateDefaultSupabaseTemplates

func (s *SupabaseService) CreateDefaultSupabaseTemplates(ctx context.Context, workspaceID, integrationID string) (*domain.SupabaseTemplateMappings, error)

CreateDefaultSupabaseTemplates creates the default Supabase auth email templates

func (*SupabaseService) DeleteIntegrationResources

func (s *SupabaseService) DeleteIntegrationResources(ctx context.Context, workspaceID, integrationID string) error

DeleteIntegrationResources deletes all templates and transactional notifications associated with a Supabase integration This is called when the integration is being deleted from the workspace

func (*SupabaseService) ProcessAuthEmailHook

func (s *SupabaseService) ProcessAuthEmailHook(ctx context.Context, workspaceID, integrationID string, payload []byte, webhookID, webhookTimestamp, webhookSignature string) error

ProcessAuthEmailHook processes a Supabase Send Email Hook webhook

func (*SupabaseService) ProcessUserCreatedHook

func (s *SupabaseService) ProcessUserCreatedHook(ctx context.Context, workspaceID, integrationID string, payload []byte, webhookID, webhookTimestamp, webhookSignature string) error

ProcessUserCreatedHook processes a Supabase Before User Created Hook webhook

type SystemConfig

type SystemConfig struct {
	IsInstalled            bool
	RootEmail              string
	APIEndpoint            string
	SMTPHost               string
	SMTPPort               int
	SMTPUsername           string
	SMTPPassword           string
	SMTPFromEmail          string
	SMTPFromName           string
	SMTPUseTLS             bool
	TelemetryEnabled       bool
	CheckForUpdates        bool
	SMTPRelayEnabled       bool
	SMTPRelayDomain        string
	SMTPRelayPort          int
	SMTPRelayTLSCertBase64 string
	SMTPRelayTLSKeyBase64  string
}

SystemConfig holds all system-level configuration

type SystemNotificationService

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

SystemNotificationService handles system-wide notifications and alerts

func NewSystemNotificationService

func NewSystemNotificationService(
	workspaceRepo domain.WorkspaceRepository,
	broadcastRepo domain.BroadcastRepository,
	mailerInstance mailer.Mailer,
	logger logger.Logger,
) *SystemNotificationService

NewSystemNotificationService creates a new system notification service

func (*SystemNotificationService) HandleBroadcastFailedEvent

func (s *SystemNotificationService) HandleBroadcastFailedEvent(ctx context.Context, payload domain.EventPayload)

HandleBroadcastFailedEvent processes broadcast failure events (placeholder for future use)

func (*SystemNotificationService) HandleCircuitBreakerEvent

func (s *SystemNotificationService) HandleCircuitBreakerEvent(ctx context.Context, payload domain.EventPayload)

HandleCircuitBreakerEvent processes circuit breaker events and sends email notifications

func (*SystemNotificationService) HandleSystemAlert

func (s *SystemNotificationService) HandleSystemAlert(ctx context.Context, payload domain.EventPayload)

HandleSystemAlert processes generic system alerts (placeholder for future use)

func (*SystemNotificationService) RegisterWithEventBus

func (s *SystemNotificationService) RegisterWithEventBus(eventBus domain.EventBus)

RegisterWithEventBus registers the service to listen for various system events

type TaskExecutor

type TaskExecutor interface {
	ExecutePendingTasks(ctx context.Context, maxTasks int) error
}

TaskScheduler manages periodic task execution TaskExecutor defines the interface for executing tasks

type TaskScheduler

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

func NewTaskScheduler

func NewTaskScheduler(
	taskExecutor TaskExecutor,
	logger logger.Logger,
	interval time.Duration,
	maxTasks int,
) *TaskScheduler

NewTaskScheduler creates a new task scheduler

func (*TaskScheduler) IsRunning

func (s *TaskScheduler) IsRunning() bool

IsRunning returns whether the scheduler is currently running

func (*TaskScheduler) Start

func (s *TaskScheduler) Start(ctx context.Context)

Start begins the task execution scheduler

func (*TaskScheduler) Stop

func (s *TaskScheduler) Stop()

Stop gracefully stops the scheduler

type TaskService

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

TaskService manages task execution and state

func NewTaskService

func NewTaskService(repository domain.TaskRepository, settingRepo domain.SettingRepository, logger logger.Logger, authService *AuthService, apiEndpoint string) *TaskService

NewTaskService creates a new task service instance

func (*TaskService) CreateTask

func (s *TaskService) CreateTask(ctx context.Context, workspace string, task *domain.Task) error

CreateTask creates a new task

func (*TaskService) DeleteTask

func (s *TaskService) DeleteTask(ctx context.Context, workspace, id string) error

DeleteTask removes a task

func (*TaskService) ExecutePendingTasks

func (s *TaskService) ExecutePendingTasks(ctx context.Context, maxTasks int) error

ExecutePendingTasks processes a batch of pending tasks

func (*TaskService) ExecuteTask

func (s *TaskService) ExecuteTask(ctx context.Context, workspace, taskID string, timeoutAt time.Time) error

ExecuteTask executes a specific task

func (*TaskService) GetLastCronRun

func (s *TaskService) GetLastCronRun(ctx context.Context) (*time.Time, error)

GetLastCronRun retrieves the last cron execution timestamp

func (*TaskService) GetProcessor

func (s *TaskService) GetProcessor(taskType string) (domain.TaskProcessor, error)

GetProcessor returns the processor for a given task type

func (*TaskService) GetTask

func (s *TaskService) GetTask(ctx context.Context, workspace, id string) (*domain.Task, error)

GetTask retrieves a task by ID

func (*TaskService) IsAutoExecuteEnabled

func (s *TaskService) IsAutoExecuteEnabled() bool

IsAutoExecuteEnabled returns whether automatic task execution is enabled

func (*TaskService) ListTasks

func (s *TaskService) ListTasks(ctx context.Context, workspace string, filter domain.TaskFilter) (*domain.TaskListResponse, error)

ListTasks lists tasks based on filter criteria

func (*TaskService) RegisterProcessor

func (s *TaskService) RegisterProcessor(processor domain.TaskProcessor)

RegisterProcessor registers a task processor for a specific task type

func (*TaskService) SetAutoExecuteImmediate

func (s *TaskService) SetAutoExecuteImmediate(enabled bool)

SetAutoExecuteImmediate sets whether tasks should be automatically executed immediately This is mainly used for testing to disable auto-execution

func (*TaskService) SubscribeToBroadcastEvents

func (s *TaskService) SubscribeToBroadcastEvents(eventBus domain.EventBus)

SubscribeToBroadcastEvents registers handlers for broadcast-related events

func (*TaskService) WithTransaction

func (s *TaskService) WithTransaction(ctx context.Context, fn func(*sql.Tx) error) error

WithTransaction executes a function within a transaction

type TelemetryMetrics

type TelemetryMetrics struct {
	WorkspaceIDSHA1    string `json:"workspace_id_sha1"`
	WorkspaceCreatedAt string `json:"workspace_created_at"`
	WorkspaceUpdatedAt string `json:"workspace_updated_at"`
	LastMessageAt      string `json:"last_message_at"`
	ContactsCount      int    `json:"contacts_count"`
	BroadcastsCount    int    `json:"broadcasts_count"`
	TransactionalCount int    `json:"transactional_count"`
	MessagesCount      int    `json:"messages_count"`
	ListsCount         int    `json:"lists_count"`
	SegmentsCount      int    `json:"segments_count"`
	UsersCount         int    `json:"users_count"`
	BlogPostsCount     int    `json:"blog_posts_count"`
	APIEndpoint        string `json:"api_endpoint"`

	// Integration flags - boolean for each email provider
	Mailgun   bool `json:"mailgun"`
	AmazonSES bool `json:"amazonses"`
	Mailjet   bool `json:"mailjet"`
	SparkPost bool `json:"sparkpost"`
	Postmark  bool `json:"postmark"`
	SMTP      bool `json:"smtp"`
	S3        bool `json:"s3"`
}

TelemetryMetrics represents the metrics data sent to the telemetry endpoint

type TelemetryService

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

TelemetryService handles sending telemetry metrics

func NewTelemetryService

func NewTelemetryService(config TelemetryServiceConfig) *TelemetryService

NewTelemetryService creates a new telemetry service

func (*TelemetryService) SendMetricsForAllWorkspaces

func (t *TelemetryService) SendMetricsForAllWorkspaces(ctx context.Context) error

SendMetricsForAllWorkspaces collects and sends telemetry metrics for all workspaces

func (*TelemetryService) StartDailyScheduler

func (t *TelemetryService) StartDailyScheduler(ctx context.Context)

StartDailyScheduler starts a goroutine that sends telemetry metrics daily

type TelemetryServiceConfig

type TelemetryServiceConfig struct {
	Enabled       bool
	APIEndpoint   string
	WorkspaceRepo domain.WorkspaceRepository
	TelemetryRepo domain.TelemetryRepository
	Logger        logger.Logger
	HTTPClient    *http.Client
}

TelemetryServiceConfig contains configuration for the telemetry service

type TemplateBlockService

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

func NewTemplateBlockService

func NewTemplateBlockService(
	repo domain.WorkspaceRepository,
	authService domain.AuthService,
	logger logger.Logger,
) *TemplateBlockService

func (*TemplateBlockService) CreateTemplateBlock

func (s *TemplateBlockService) CreateTemplateBlock(ctx context.Context, workspaceID string, block *domain.TemplateBlock) error

func (*TemplateBlockService) DeleteTemplateBlock

func (s *TemplateBlockService) DeleteTemplateBlock(ctx context.Context, workspaceID string, id string) error

func (*TemplateBlockService) GetTemplateBlock

func (s *TemplateBlockService) GetTemplateBlock(ctx context.Context, workspaceID string, id string) (*domain.TemplateBlock, error)

func (*TemplateBlockService) ListTemplateBlocks

func (s *TemplateBlockService) ListTemplateBlocks(ctx context.Context, workspaceID string) ([]*domain.TemplateBlock, error)

func (*TemplateBlockService) UpdateTemplateBlock

func (s *TemplateBlockService) UpdateTemplateBlock(ctx context.Context, workspaceID string, block *domain.TemplateBlock) error

type TemplateService

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

func NewTemplateService

func NewTemplateService(repo domain.TemplateRepository, authService domain.AuthService, logger logger.Logger, apiEndpoint string) *TemplateService

func (*TemplateService) CompileTemplate

func (*TemplateService) CreateTemplate

func (s *TemplateService) CreateTemplate(ctx context.Context, workspaceID string, template *domain.Template) error

func (*TemplateService) DeleteTemplate

func (s *TemplateService) DeleteTemplate(ctx context.Context, workspaceID string, id string) error

func (*TemplateService) GetTemplateByID

func (s *TemplateService) GetTemplateByID(ctx context.Context, workspaceID string, id string, version int64) (*domain.Template, error)

func (*TemplateService) GetTemplates

func (s *TemplateService) GetTemplates(ctx context.Context, workspaceID string, category string, channel string) ([]*domain.Template, error)

func (*TemplateService) UpdateTemplate

func (s *TemplateService) UpdateTemplate(ctx context.Context, workspaceID string, template *domain.Template) error

type TransactionalNotificationService

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

TransactionalNotificationService provides operations for managing and sending transactional notifications

func NewTransactionalNotificationService

func NewTransactionalNotificationService(
	transactionalRepo domain.TransactionalNotificationRepository,
	messageHistoryRepo domain.MessageHistoryRepository,
	templateService domain.TemplateService,
	contactService domain.ContactService,
	emailService domain.EmailServiceInterface,
	authService domain.AuthService,
	logger logger.Logger,
	workspaceRepo domain.WorkspaceRepository,
	apiEndpoint string,
) *TransactionalNotificationService

NewTransactionalNotificationService creates a new instance of the transactional notification service

func (*TransactionalNotificationService) CreateNotification

CreateNotification creates a new transactional notification

func (*TransactionalNotificationService) DeleteNotification

func (s *TransactionalNotificationService) DeleteNotification(
	ctx context.Context,
	workspace, id string,
) error

DeleteNotification soft-deletes a transactional notification

func (*TransactionalNotificationService) GetNotification

func (s *TransactionalNotificationService) GetNotification(
	ctx context.Context,
	workspace, id string,
) (*domain.TransactionalNotification, error)

GetNotification retrieves a transactional notification by ID

func (*TransactionalNotificationService) ListNotifications

func (s *TransactionalNotificationService) ListNotifications(
	ctx context.Context,
	workspace string,
	filter map[string]interface{},
	limit, offset int,
) ([]*domain.TransactionalNotification, int, error)

ListNotifications retrieves all transactional notifications with optional filtering

func (*TransactionalNotificationService) SendNotification

SendNotification sends a transactional notification to a contact

func (*TransactionalNotificationService) TestTemplate

func (s *TransactionalNotificationService) TestTemplate(ctx context.Context, workspaceID string, templateID string, integrationID string, senderID string, recipientEmail string, emailOptions domain.EmailOptions) error

TestTemplate sends a test email with a template to verify it works

func (*TransactionalNotificationService) UpdateNotification

UpdateNotification updates an existing transactional notification

type TriggerNodeExecutor

type TriggerNodeExecutor struct{}

TriggerNodeExecutor handles trigger nodes (pass-through to next node) Trigger nodes are entry points - the actual trigger logic is handled by the database trigger during enrollment. This executor just advances to the next node.

func NewTriggerNodeExecutor

func NewTriggerNodeExecutor() *TriggerNodeExecutor

NewTriggerNodeExecutor creates a new trigger node executor

func (*TriggerNodeExecutor) Execute

Execute passes through to the next node

func (*TriggerNodeExecutor) NodeType

func (e *TriggerNodeExecutor) NodeType() domain.NodeType

NodeType returns the node type this executor handles

type TriggerSQL

type TriggerSQL struct {
	FunctionName string // automation_trigger_{id}
	FunctionBody string // CREATE OR REPLACE FUNCTION ...
	TriggerName  string // automation_trigger_{id}
	TriggerDDL   string // CREATE TRIGGER ... WHEN (...) EXECUTE FUNCTION ...
	DropTrigger  string // DROP TRIGGER IF EXISTS ... ON contact_timeline
	DropFunction string // DROP FUNCTION IF EXISTS ...
	WHENClause   string // The WHEN clause alone (for storage/debugging) - values embedded
}

TriggerSQL contains the generated SQL statements for an automation trigger

type UserClaims

type UserClaims struct {
	UserID    string `json:"user_id"`
	Type      string `json:"type"`
	SessionID string `json:"session_id,omitempty"`
	Email     string `json:"email,omitempty"`
	jwt.RegisteredClaims
}

UserClaims for user session tokens

type UserService

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

func NewUserService

func NewUserService(cfg UserServiceConfig) (*UserService, error)

func (*UserService) GetUserByEmail

func (s *UserService) GetUserByEmail(ctx context.Context, email string) (*domain.User, error)

GetUserByEmail retrieves a user by their email address

func (*UserService) GetUserByID

func (s *UserService) GetUserByID(ctx context.Context, userID string) (*domain.User, error)

GetUserByID retrieves a user by their ID

func (*UserService) Logout

func (s *UserService) Logout(ctx context.Context, userID string) error

Logout logs out a user by deleting all their sessions

func (*UserService) RootSignin

func (s *UserService) RootSignin(ctx context.Context, input domain.RootSigninInput) (*domain.AuthResponse, error)

RootSignin authenticates the root user using HMAC signature. This allows programmatic authentication without magic link for automation scenarios.

func (*UserService) SignIn

func (s *UserService) SignIn(ctx context.Context, input domain.SignInInput) (string, error)

func (*UserService) VerifyCode

func (s *UserService) VerifyCode(ctx context.Context, input domain.VerifyCodeInput) (*domain.AuthResponse, error)

func (*UserService) VerifyUserSession

func (s *UserService) VerifyUserSession(ctx context.Context, userID string, sessionID string) (*domain.User, error)

VerifyUserSession verifies a user session and returns the associated user

type UserServiceConfig

type UserServiceConfig struct {
	Repository    domain.UserRepository
	AuthService   domain.AuthService
	EmailSender   EmailSender
	SessionExpiry time.Duration
	Logger        logger.Logger
	IsProduction  bool
	Tracer        tracing.Tracer
	RateLimiter   *ratelimiter.RateLimiter // Global rate limiter
	SecretKey     string
	RootEmail     string
}

type WebhookDeliveryWorker

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

WebhookDeliveryWorker processes pending webhook deliveries

func NewWebhookDeliveryWorker

func NewWebhookDeliveryWorker(
	subscriptionRepo domain.WebhookSubscriptionRepository,
	deliveryRepo domain.WebhookDeliveryRepository,
	workspaceRepo domain.WorkspaceRepository,
	logger logger.Logger,
	httpClient *http.Client,
) *WebhookDeliveryWorker

NewWebhookDeliveryWorker creates a new webhook delivery worker

func (*WebhookDeliveryWorker) SendTestWebhook

func (w *WebhookDeliveryWorker) SendTestWebhook(ctx context.Context, workspaceID string, sub *domain.WebhookSubscription, eventType string) (int, string, error)

SendTestWebhook sends a test webhook to verify the endpoint

func (*WebhookDeliveryWorker) Start

func (w *WebhookDeliveryWorker) Start(ctx context.Context)

Start starts the webhook delivery worker

type WebhookNodeExecutor

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

WebhookNodeExecutor executes webhook nodes

func NewWebhookNodeExecutor

func NewWebhookNodeExecutor(log logger.Logger) *WebhookNodeExecutor

NewWebhookNodeExecutor creates a new webhook node executor

func (*WebhookNodeExecutor) Execute

Execute processes a webhook node

func (*WebhookNodeExecutor) NodeType

func (e *WebhookNodeExecutor) NodeType() domain.NodeType

NodeType returns the node type this executor handles

type WebhookRegistrationService

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

WebhookRegistrationService implements the domain.WebhookRegistrationService interface

func NewWebhookRegistrationService

func NewWebhookRegistrationService(
	workspaceRepo domain.WorkspaceRepository,
	authService domain.AuthService,
	postmarkService domain.PostmarkServiceInterface,
	mailgunService domain.MailgunServiceInterface,
	mailjetService domain.MailjetServiceInterface,
	sparkPostService domain.SparkPostServiceInterface,
	sesService domain.SESServiceInterface,
	logger logger.Logger,
	apiEndpoint string,
) *WebhookRegistrationService

NewWebhookRegistrationService creates a new webhook registration service

func (*WebhookRegistrationService) GetWebhookStatus

func (s *WebhookRegistrationService) GetWebhookStatus(
	ctx context.Context,
	workspaceID string,
	integrationID string,
) (*domain.WebhookRegistrationStatus, error)

GetWebhookStatus gets the status of webhooks for an email provider

func (*WebhookRegistrationService) RegisterWebhooks

RegisterWebhooks registers webhook URLs with the email provider

func (*WebhookRegistrationService) UnregisterWebhooks

func (s *WebhookRegistrationService) UnregisterWebhooks(
	ctx context.Context,
	workspaceID string,
	integrationID string,
) error

UnregisterWebhooks removes all webhook URLs associated with the integration

type WebhookSubscriptionService

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

WebhookSubscriptionService handles webhook subscription business logic

func NewWebhookSubscriptionService

func NewWebhookSubscriptionService(
	repo domain.WebhookSubscriptionRepository,
	deliveryRepo domain.WebhookDeliveryRepository,
	authService *AuthService,
	logger logger.Logger,
) *WebhookSubscriptionService

NewWebhookSubscriptionService creates a new webhook subscription service

func (*WebhookSubscriptionService) Create

func (s *WebhookSubscriptionService) Create(ctx context.Context, workspaceID string, name, webhookURL string, eventTypes []string, customEventFilters *domain.CustomEventFilters) (*domain.WebhookSubscription, error)

Create creates a new webhook subscription

func (*WebhookSubscriptionService) Delete

func (s *WebhookSubscriptionService) Delete(ctx context.Context, workspaceID, id string) error

Delete deletes a webhook subscription

func (*WebhookSubscriptionService) GetByID

func (s *WebhookSubscriptionService) GetByID(ctx context.Context, workspaceID, id string) (*domain.WebhookSubscription, error)

GetByID retrieves a webhook subscription by ID

func (*WebhookSubscriptionService) GetDeliveries

func (s *WebhookSubscriptionService) GetDeliveries(ctx context.Context, workspaceID string, subscriptionID *string, limit, offset int) ([]*domain.WebhookDelivery, int, error)

GetDeliveries retrieves delivery history, optionally filtered by subscription

func (*WebhookSubscriptionService) GetEventTypes

func (s *WebhookSubscriptionService) GetEventTypes() []string

GetEventTypes returns the list of available event types

func (*WebhookSubscriptionService) List

List retrieves all webhook subscriptions for a workspace

func (*WebhookSubscriptionService) RegenerateSecret

func (s *WebhookSubscriptionService) RegenerateSecret(ctx context.Context, workspaceID, id string) (*domain.WebhookSubscription, error)

RegenerateSecret generates a new secret for a webhook subscription

func (*WebhookSubscriptionService) Toggle

func (s *WebhookSubscriptionService) Toggle(ctx context.Context, workspaceID, id string, enabled bool) (*domain.WebhookSubscription, error)

Toggle enables or disables a webhook subscription

func (*WebhookSubscriptionService) Update

func (s *WebhookSubscriptionService) Update(ctx context.Context, workspaceID string, id, name, webhookURL string, eventTypes []string, customEventFilters *domain.CustomEventFilters, enabled bool) (*domain.WebhookSubscription, error)

Update updates an existing webhook subscription

type WorkspaceService

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

func NewWorkspaceService

func NewWorkspaceService(
	repo domain.WorkspaceRepository,
	userRepo domain.UserRepository,
	taskRepo domain.TaskRepository,
	logger logger.Logger,
	userService domain.UserServiceInterface,
	authService domain.AuthService,
	mailerInstance mailer.Mailer,
	config *config.Config,
	contactService domain.ContactService,
	listService domain.ListService,
	contactListService domain.ContactListService,
	templateService domain.TemplateService,
	webhookRegService domain.WebhookRegistrationService,
	secretKey string,
	supabaseService *SupabaseService,
	dnsVerificationService *DNSVerificationService,
	blogService *BlogService,
) *WorkspaceService

func (*WorkspaceService) AcceptInvitation

func (s *WorkspaceService) AcceptInvitation(ctx context.Context, invitationID, workspaceID, email string) (*domain.AuthResponse, error)

AcceptInvitation processes an invitation acceptance by creating a user if needed and adding them to the workspace

func (*WorkspaceService) AddUserToWorkspace

func (s *WorkspaceService) AddUserToWorkspace(ctx context.Context, workspaceID string, userID string, role string, permissions domain.UserPermissions) error

AddUserToWorkspace adds a user to a workspace if the requester is an owner

func (*WorkspaceService) CreateAPIKey

func (s *WorkspaceService) CreateAPIKey(ctx context.Context, workspaceID string, emailPrefix string) (string, string, error)

CreateAPIKey creates an API key for a workspace

func (*WorkspaceService) CreateIntegration

func (s *WorkspaceService) CreateIntegration(ctx context.Context, req domain.CreateIntegrationRequest) (string, error)

CreateIntegration creates a new integration for a workspace

func (*WorkspaceService) CreateWorkspace

func (s *WorkspaceService) CreateWorkspace(ctx context.Context, id string, name string, websiteURL string, logoURL string, coverURL string, timezone string, fileManager domain.FileManagerSettings) (*domain.Workspace, error)

CreateWorkspace creates a new workspace and adds the creator as owner

func (*WorkspaceService) DeleteIntegration

func (s *WorkspaceService) DeleteIntegration(ctx context.Context, workspaceID, integrationID string) error

DeleteIntegration deletes an integration from a workspace

func (*WorkspaceService) DeleteInvitation

func (s *WorkspaceService) DeleteInvitation(ctx context.Context, invitationID string) error

DeleteInvitation deletes a workspace invitation by its ID

func (*WorkspaceService) DeleteWorkspace

func (s *WorkspaceService) DeleteWorkspace(ctx context.Context, id string) error

DeleteWorkspace deletes a workspace if the user is an owner

func (*WorkspaceService) GetInvitationByID

func (s *WorkspaceService) GetInvitationByID(ctx context.Context, invitationID string) (*domain.WorkspaceInvitation, error)

GetInvitationByID retrieves a workspace invitation by its ID

func (*WorkspaceService) GetWorkspace

func (s *WorkspaceService) GetWorkspace(ctx context.Context, id string) (*domain.Workspace, error)

GetWorkspace returns a workspace by ID if the user has access

func (*WorkspaceService) GetWorkspaceMembersWithEmail

func (s *WorkspaceService) GetWorkspaceMembersWithEmail(ctx context.Context, id string) ([]*domain.UserWorkspaceWithEmail, error)

GetWorkspaceMembersWithEmail returns all users with emails for a workspace, verifying the requester has access

func (*WorkspaceService) InviteMember

func (s *WorkspaceService) InviteMember(ctx context.Context, workspaceID, email string, permissions domain.UserPermissions) (*domain.WorkspaceInvitation, string, error)

InviteMember creates an invitation for a user to join a workspace

func (*WorkspaceService) ListWorkspaces

func (s *WorkspaceService) ListWorkspaces(ctx context.Context) ([]*domain.Workspace, error)

ListWorkspaces returns all workspaces for a user

func (*WorkspaceService) RemoveMember

func (s *WorkspaceService) RemoveMember(ctx context.Context, workspaceID string, userIDToRemove string) error

RemoveMember removes a member from a workspace and deletes the user if it's an API key

func (*WorkspaceService) RemoveUserFromWorkspace

func (s *WorkspaceService) RemoveUserFromWorkspace(ctx context.Context, workspaceID string, userID string) error

RemoveUserFromWorkspace removes a user from a workspace if the requester is an owner

func (*WorkspaceService) SetUserPermissions

func (s *WorkspaceService) SetUserPermissions(ctx context.Context, workspaceID, userID string, permissions domain.UserPermissions) error

SetUserPermissions sets the permissions for a user in a workspace

func (*WorkspaceService) TransferOwnership

func (s *WorkspaceService) TransferOwnership(ctx context.Context, workspaceID string, newOwnerID string, currentOwnerID string) error

TransferOwnership transfers the ownership of a workspace from the current owner to a member

func (*WorkspaceService) UpdateIntegration

func (s *WorkspaceService) UpdateIntegration(ctx context.Context, req domain.UpdateIntegrationRequest) error

UpdateIntegration updates an existing integration in a workspace

func (*WorkspaceService) UpdateWorkspace

func (s *WorkspaceService) UpdateWorkspace(ctx context.Context, id string, name string, settings domain.WorkspaceSettings) (*domain.Workspace, error)

UpdateWorkspace updates a workspace if the user is an owner

Directories

Path Synopsis
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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