Refactor hostname to become baseurl
Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
@@ -45,7 +45,7 @@ type (
|
||||
encryptionKey cipher.EncryptionKey
|
||||
tokenSecret string
|
||||
slackSigningSecret string
|
||||
hostname string
|
||||
baseURL string
|
||||
auth *auth.Service
|
||||
html2pdfConverter *html2pdf.Converter
|
||||
fileManager *filemanager.Service
|
||||
@@ -61,7 +61,7 @@ type (
|
||||
proboSvc *probo.Service
|
||||
encryptionKey cipher.EncryptionKey
|
||||
tokenSecret string
|
||||
hostname string
|
||||
baseURL string
|
||||
auth *auth.Service
|
||||
html2pdfConverter *html2pdf.Converter
|
||||
fileManager *filemanager.Service
|
||||
@@ -85,7 +85,7 @@ func NewService(
|
||||
pgClient *pg.Client,
|
||||
s3Client *s3.Client,
|
||||
bucket string,
|
||||
hostname string,
|
||||
baseURL string,
|
||||
encryptionKey cipher.EncryptionKey,
|
||||
tokenSecret string,
|
||||
slackSigningSecret string,
|
||||
@@ -102,7 +102,7 @@ func NewService(
|
||||
encryptionKey: encryptionKey,
|
||||
tokenSecret: tokenSecret,
|
||||
slackSigningSecret: slackSigningSecret,
|
||||
hostname: hostname,
|
||||
baseURL: baseURL,
|
||||
auth: auth,
|
||||
html2pdfConverter: html2pdfConverter,
|
||||
fileManager: fileManagerService,
|
||||
@@ -120,7 +120,7 @@ func (s *Service) WithTenant(tenantID gid.TenantID) *TenantService {
|
||||
proboSvc: s.proboSvc,
|
||||
encryptionKey: s.encryptionKey,
|
||||
tokenSecret: s.tokenSecret,
|
||||
hostname: s.hostname,
|
||||
baseURL: s.baseURL,
|
||||
auth: s.auth,
|
||||
html2pdfConverter: s.html2pdfConverter,
|
||||
fileManager: s.fileManager,
|
||||
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/getprobo/probo/pkg/baseurl"
|
||||
"github.com/getprobo/probo/pkg/coredata"
|
||||
"github.com/getprobo/probo/pkg/gid"
|
||||
"github.com/getprobo/probo/pkg/slack"
|
||||
@@ -409,6 +410,11 @@ func (s *SlackMessageService) buildAccessRequestMessage(
|
||||
fileIDs = append(fileIDs, file.ID)
|
||||
}
|
||||
|
||||
base, err := baseurl.Parse(s.svc.baseURL)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot parse base URL: %w", err)
|
||||
}
|
||||
|
||||
templateData := struct {
|
||||
RequesterName string
|
||||
RequesterEmail string
|
||||
@@ -425,7 +431,7 @@ func (s *SlackMessageService) buildAccessRequestMessage(
|
||||
RequesterName: requesterName,
|
||||
RequesterEmail: requesterEmail,
|
||||
OrganizationID: organizationID.String(),
|
||||
Domain: s.svc.hostname,
|
||||
Domain: base.Host(),
|
||||
SlackMessageID: slackMessageID.String(),
|
||||
DocumentIDs: documentIDs,
|
||||
ReportIDs: reportIDs,
|
||||
|
||||
@@ -470,7 +470,13 @@ func (s *TrustCenterAccessService) sendAccessEmail(ctx context.Context, tx pg.Co
|
||||
return fmt.Errorf("cannot load organization: %w", err)
|
||||
}
|
||||
|
||||
hostname := s.svc.hostname
|
||||
baseURLParsed, err := url.Parse(s.svc.baseURL)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot parse base URL: %w", err)
|
||||
}
|
||||
|
||||
hostname := baseURLParsed.Host
|
||||
scheme := baseURLParsed.Scheme
|
||||
path := "/trust/" + trustCenter.Slug + "/access"
|
||||
|
||||
if organization.CustomDomainID != nil {
|
||||
@@ -484,11 +490,12 @@ func (s *TrustCenterAccessService) sendAccessEmail(ctx context.Context, tx pg.Co
|
||||
}
|
||||
|
||||
hostname = customDomain.Domain
|
||||
scheme = "https"
|
||||
path = "/access"
|
||||
}
|
||||
|
||||
accessURL := url.URL{
|
||||
Scheme: "https",
|
||||
Scheme: scheme,
|
||||
Host: hostname,
|
||||
Path: path,
|
||||
RawQuery: url.Values{
|
||||
@@ -517,7 +524,7 @@ func (s *TrustCenterAccessService) sendTrustCenterAccessEmail(
|
||||
accessURL string,
|
||||
) error {
|
||||
subject, textBody, htmlBody, err := emails.RenderTrustCenterAccess(
|
||||
s.svc.hostname,
|
||||
s.svc.baseURL,
|
||||
name,
|
||||
companyName,
|
||||
accessURL,
|
||||
|
||||
Reference in New Issue
Block a user