auto mail generation
This commit is contained in:
@@ -3,6 +3,7 @@ package facade
|
||||
import (
|
||||
"log"
|
||||
|
||||
"nearle/config"
|
||||
"nearle/controllers"
|
||||
"nearle/repositories"
|
||||
"nearle/services"
|
||||
@@ -48,11 +49,29 @@ type Facade struct {
|
||||
// it may be nil if catalogue env vars are not configured, in which case
|
||||
// catalogue endpoints will error at query time rather than at startup.
|
||||
// embedder may be nil too: scan-to-order then matches on words alone.
|
||||
func NewFacade(db *gorm.DB, catalogueDB *gorm.DB, embedder utils.Embedder, chat utils.Chat, agentsDir, assistantWhy string) *Facade {
|
||||
func NewFacade(db *gorm.DB, catalogueDB *gorm.DB, embedder utils.Embedder, chat utils.Chat, agentsDir, assistantWhy string, mailer utils.Mailer, mailCfg config.MailConfig) *Facade {
|
||||
|
||||
// The invitation, built first because two modules need it.
|
||||
//
|
||||
// Every back-office account on this platform is created with NO password —
|
||||
// the onboarded merchant, every person added to the directory, and the login
|
||||
// each branch spawns — and since the sign-in screen stopped offering to set
|
||||
// one, the emailed link is the only way in. So whichever module creates an
|
||||
// account has to be able to send it.
|
||||
//
|
||||
// `mailer` may be nil: a deployment with no mail configured still creates
|
||||
// everything, and each response says the invitation was not sent and names
|
||||
// the variable, rather than failing the create.
|
||||
//
|
||||
// The tenant repository supplies the business name for the mail's first line
|
||||
// (`services.TenantNamer`), which is why it is built here rather than in the
|
||||
// tenant module below.
|
||||
tenantRepo := repositories.NewTenantRepository(db)
|
||||
inviteService := services.NewInviteService(mailer, mailCfg, tenantRepo)
|
||||
|
||||
// User Module
|
||||
userRepo := repositories.NewUserRepository(db)
|
||||
userService := services.NewUserService(userRepo)
|
||||
userService := services.NewUserService(userRepo, inviteService)
|
||||
userController := controllers.NewUserController(userService)
|
||||
|
||||
// Catalogue Module (separate pgvector DB — never the main `db`). Built
|
||||
@@ -83,8 +102,11 @@ func NewFacade(db *gorm.DB, catalogueDB *gorm.DB, embedder utils.Embedder, chat
|
||||
utilsController := controllers.NewUtilsController(utilsService)
|
||||
|
||||
//Tenant Module
|
||||
tenantRepo := repositories.NewTenantRepository(db)
|
||||
tenantService := services.NewTenantService(tenantRepo)
|
||||
//
|
||||
// Onboarding, adding a person and commissioning a branch all create an
|
||||
// account with no password, so all three send an invitation. `tenantRepo` and
|
||||
// `inviteService` are built above, where the reasoning is.
|
||||
tenantService := services.NewTenantService(tenantRepo, inviteService)
|
||||
tenantController := controllers.NewTenantController(tenantService)
|
||||
|
||||
//Partner Module
|
||||
|
||||
Reference in New Issue
Block a user