feat(onprem): mails come from the installation, not from us #144
No files matched your search
@@ -53,7 +53,9 @@ Env vars (override at the shell):
|
||||
| `SMTP_TLS` | `tls` on port 465, else `starttls` | `starttls`, `tls` or `none` (a plain relay inside the customer's network; refused together with `SMTP_USER`) |
|
||||
| `PRODUCTS` | empty (the catalog's own enabled flags) | Comma list of the products this installation offers; a listed product is offered even if its row is disabled |
|
||||
| `PRODUCT_LAUNCH_URLS` / `PRODUCT_PROVISION_URLS` | empty (the URLs seeded per environment) | `key=url,key=url` overrides; a provision URL carries `{id}`. Checked at start |
|
||||
| `MAIL_FROM` / `MAIL_FROM_NAME` | `noreply@breakpilot.com` / `BreakPilot` | Sender of platform mail |
|
||||
| `MAIL_FROM` / `MAIL_FROM_NAME` | `noreply@breakpilot.com` / `Breakpilot` | Sender of platform mail |
|
||||
| `LEGAL_IMPRINT_URL` / `LEGAL_PRIVACY_URL` | our imprint and privacy notice (cloud); none (on-prem) | Legal links under every mail |
|
||||
| `MAIL_CONTACT` | empty | On-prem: whom to ask (their IT), shown in every mail; the cloud signature names our contact |
|
||||
| `PORTAL_URL` | `https://app.breakpilot.com` | Portal origin for links in mail |
|
||||
| `INVITE_CLIENT_ID` / `INVITE_REDIRECT_URI` | `dev-portal` / `https://breakpilot.com/onboard` | Keycloak invite mail client + landing URL (stage: `portal-stage`, `https://app-stage.breakpilot.com/start?invited=1`) |
|
||||
| `ERP_BASE_URL` / `ERP_API_KEY` / `ERP_API_SECRET` | empty (outbox idle) | ERPNext / erpmock base URL + `token key:secret` credentials |
|
||||
@@ -121,7 +123,8 @@ State-changing endpoints emit audit events automatically. The OpenAPI contract t
|
||||
- No sign-up and no sales requests: the trial-offer, trial-terms, catalog request, trial request and admin trial routes answer 404 `not_available`.
|
||||
- Products and URLs only from `PRODUCTS` and `PRODUCT_*_URLS`. The seeded `stage`/`prod` URLs are never used, so provisioning never reaches a Breakpilot host (the test install in `platform/onprem` checks all outbound traffic). Each listed product needs a launch URL; an unknown key stops the start. The catalog offers no trials.
|
||||
- Accounts only from the customer's directory (Keycloak federates their AD; the package's `keycloak/realm-policy.sh` keeps passwords in AD). The workspace's first admin (`admin_email`) and every invited member must be an existing directory user: they are added to the organization with their role, get no set-password mail and sign in with their directory password. An unknown address answers `not_in_directory`; there is no invitation to resend (`no_invite_mail`).
|
||||
- No cloud defaults: the registry refuses to start without `AUTH_ENABLED=true`, `AUTHZ_RULES`, `LICENCE_SIGNING_KEY`, `DATABASE_URL`, the Keycloak admin settings, `PORTAL_URL`, `INVITE_CLIENT_ID`, `INVITE_REDIRECT_URI`, `MAIL_FROM` and `PRODUCTS`, and without `LITELLM_BASE_URL` when `LITELLM_MASTER_KEY` is set. Contract documents stay off.
|
||||
- No cloud defaults: the registry refuses to start without `AUTH_ENABLED=true`, `AUTHZ_RULES`, `LICENCE_SIGNING_KEY`, `DATABASE_URL`, the Keycloak admin settings, `PORTAL_URL`, `INVITE_CLIENT_ID`, `INVITE_REDIRECT_URI`, `MAIL_FROM` and `PRODUCTS`, and without `LITELLM_BASE_URL` when `LITELLM_MASTER_KEY` is set. Contract documents stay off. `MAIL_FROM`, `PORTAL_URL`, `INVITE_REDIRECT_URI` and `LEGAL_*` must not point at `breakpilot.com`.
|
||||
- Mail is the installation's, not ours: no company signature (address, register entry, our contact), instead a short note that the installation sent it, `MAIL_CONTACT` if set, and the customer's `LEGAL_IMPRINT_URL` / `LEGAL_PRIVACY_URL`, each left out when empty.
|
||||
|
||||
## ERP link (M-MIG-7)
|
||||
|
||||
|
||||
@@ -99,6 +99,13 @@ type Config struct {
|
||||
SMTPPassword string
|
||||
MailFrom string
|
||||
MailFromName string
|
||||
// Legal pages and whom to ask, under every mail. Cloud: empty means our
|
||||
// imprint and privacy notice (mail.CloudImprint/CloudPrivacy). On-prem:
|
||||
// the customer's own pages, each left out when empty; MailContact names
|
||||
// their IT (on-prem only, the cloud signature carries our contact).
|
||||
LegalImprintURL string
|
||||
LegalPrivacyURL string
|
||||
MailContact string
|
||||
// PortalURL is the portal's public origin, for links in mail.
|
||||
PortalURL string
|
||||
// PruefwerkPlatformURL / PruefwerkURL override where the registry reads a
|
||||
@@ -214,7 +221,10 @@ func Load() (*Config, error) {
|
||||
SMTPUser: os.Getenv("SMTP_USER"),
|
||||
SMTPPassword: os.Getenv("SMTP_PASSWORD"),
|
||||
MailFrom: getenv("MAIL_FROM", "noreply@breakpilot.com"),
|
||||
MailFromName: getenv("MAIL_FROM_NAME", "BreakPilot"),
|
||||
MailFromName: getenv("MAIL_FROM_NAME", "Breakpilot"),
|
||||
LegalImprintURL: os.Getenv("LEGAL_IMPRINT_URL"),
|
||||
LegalPrivacyURL: os.Getenv("LEGAL_PRIVACY_URL"),
|
||||
MailContact: os.Getenv("MAIL_CONTACT"),
|
||||
PortalURL: getenv("PORTAL_URL", "https://app.breakpilot.com"),
|
||||
PruefwerkPlatformURL: os.Getenv("PRUEFWERK_PLATFORM_URL"),
|
||||
PruefwerkURL: os.Getenv("PRUEFWERK_URL"),
|
||||
@@ -282,6 +292,12 @@ func (c *Config) checkOnPrem() error {
|
||||
if c.ContractDocuments {
|
||||
return fmt.Errorf("APP_ENV=onprem has no contract documents: unset CONTRACT_DOCUMENTS")
|
||||
}
|
||||
// Links and the sender in mail and invitations are the customer's.
|
||||
for _, k := range []string{"MAIL_FROM", "PORTAL_URL", "INVITE_REDIRECT_URI", "LEGAL_IMPRINT_URL", "LEGAL_PRIVACY_URL"} {
|
||||
if strings.Contains(strings.ToLower(os.Getenv(k)), "breakpilot.com") {
|
||||
return fmt.Errorf("APP_ENV=onprem: %s points at breakpilot.com; use the installation's own", k)
|
||||
}
|
||||
}
|
||||
for _, k := range c.Products {
|
||||
if c.LaunchURLs[k] == "" {
|
||||
return fmt.Errorf("APP_ENV=onprem: product %q has no entry in PRODUCT_LAUNCH_URLS", k)
|
||||
|
||||
@@ -32,7 +32,8 @@ func onPremEnv(t *testing.T) {
|
||||
} {
|
||||
t.Setenv(k, v)
|
||||
}
|
||||
for _, k := range []string{"ERP_BASE_URL", "ERP_WEBHOOK_SECRET", "CONTRACT_DOCUMENTS", "LITELLM_MASTER_KEY", "LITELLM_BASE_URL", "SMTP_USER"} {
|
||||
for _, k := range []string{"ERP_BASE_URL", "ERP_WEBHOOK_SECRET", "CONTRACT_DOCUMENTS", "LITELLM_MASTER_KEY", "LITELLM_BASE_URL", "SMTP_USER",
|
||||
"LEGAL_IMPRINT_URL", "LEGAL_PRIVACY_URL", "MAIL_CONTACT", "MAIL_FROM_NAME"} {
|
||||
t.Setenv(k, "")
|
||||
}
|
||||
}
|
||||
@@ -46,6 +47,9 @@ func TestLoad_onPremComplete(t *testing.T) {
|
||||
if !c.OnPrem() || c.CatalogEnv() != "onprem" {
|
||||
t.Errorf("OnPrem=%v CatalogEnv=%q", c.OnPrem(), c.CatalogEnv())
|
||||
}
|
||||
if c.LegalImprintURL != "" || c.LegalPrivacyURL != "" || c.MailContact != "" || c.MailFromName != "Breakpilot" {
|
||||
t.Errorf("mail site: %q %q %q %q", c.LegalImprintURL, c.LegalPrivacyURL, c.MailContact, c.MailFromName)
|
||||
}
|
||||
if c.SMTPTLS != "none" || c.SMTPPort != 25 {
|
||||
t.Errorf("smtp = %s:%d", c.SMTPTLS, c.SMTPPort)
|
||||
}
|
||||
@@ -70,6 +74,10 @@ func TestLoad_onPremRefusesCloudDefaults(t *testing.T) {
|
||||
{"contract documents", "CONTRACT_DOCUMENTS", "on", "contract documents"},
|
||||
{"LLM key without gateway", "LITELLM_MASTER_KEY", "x", "LITELLM_BASE_URL"},
|
||||
{"product without tile", "PRODUCTS", "pruefwerk,firmwerk", `"firmwerk"`},
|
||||
{"our sender", "MAIL_FROM", "noreply@breakpilot.com", "MAIL_FROM points at breakpilot.com"},
|
||||
{"our portal", "PORTAL_URL", "https://app.breakpilot.com", "PORTAL_URL points"},
|
||||
{"our imprint", "LEGAL_IMPRINT_URL", "https://Breakpilot.com/impressum", "LEGAL_IMPRINT_URL points"},
|
||||
{"our privacy notice", "LEGAL_PRIVACY_URL", "https://app.breakpilot.com/datenschutz", "LEGAL_PRIVACY_URL points"},
|
||||
} {
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
onPremEnv(t)
|
||||
|
||||
@@ -129,8 +129,8 @@ func TestSMTP_dialFailure(t *testing.T) {
|
||||
func TestRender_signature(t *testing.T) {
|
||||
for _, kind := range []string{KindDocumentPublished, KindFindingsNew} {
|
||||
for _, c := range []struct{ lang, greeting, team string }{
|
||||
{"de", "Mit freundlichen Grüßen", "Ihr BreakPilot-Team"},
|
||||
{"en", "Kind regards", "Your BreakPilot team"},
|
||||
{"de", "Mit freundlichen Grüßen", "Ihr Breakpilot-Team"},
|
||||
{"en", "Kind regards", "Your Breakpilot team"},
|
||||
} {
|
||||
m, err := Render(kind, c.lang, View{Tenant: "acme", URL: "https://app/acme",
|
||||
D: map[string]any{"title": "T", "target_name": "fw", "new_count": 2}})
|
||||
@@ -153,6 +153,68 @@ func TestRender_signature(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// The cloud's legal line: our imprint and privacy notice, overridable.
|
||||
func TestRender_cloudLegalLinks(t *testing.T) {
|
||||
m, _ := Render(KindFindingsNew, "de", View{URL: "https://x", D: map[string]any{"target_name": "fw", "new_count": 2}})
|
||||
if !strings.Contains(m.Text, "Breakpilot GmbH · "+CloudImprint) || !strings.Contains(m.HTML, `href="`+CloudImprint+`"`) || !strings.Contains(m.HTML, `href="`+CloudPrivacy+`"`) {
|
||||
t.Fatalf("cloud defaults:\n%s", m.Text)
|
||||
}
|
||||
m, _ = Render(KindTrialReceived, "de", View{Site: Site{Imprint: "https://i.test", Privacy: "https://p.test"}})
|
||||
if !strings.Contains(m.Text, "Breakpilot GmbH · https://i.test · https://p.test") || strings.Contains(m.HTML, CloudImprint) {
|
||||
t.Fatalf("override:\n%s", m.Text)
|
||||
}
|
||||
}
|
||||
|
||||
// On a customer's installation no mail carries our company data, address,
|
||||
// contact or legal pages; it names their pages and contact when given.
|
||||
func TestRender_onPrem(t *testing.T) {
|
||||
d := map[string]any{"title": "T", "target_name": "fw", "new_count": 2}
|
||||
ours := []string{"breakpilot.com", "Breakpilot GmbH", "Bodman", "DE464808363", "HRB 736403", "Parnerkar", "Mit freundlichen", "Kind regards"}
|
||||
for _, kind := range []string{KindDocumentPublished, KindFindingsNew} {
|
||||
for _, c := range []struct{ lang, note, ask, imprint, privacy string }{
|
||||
{"de", "die Installation in Ihrem", "Fragen", "Impressum", "Datenschutz"},
|
||||
{"en", "the installation in your company", "Questions", "Imprint", "Privacy"},
|
||||
} {
|
||||
full, err := Render(kind, c.lang, View{Tenant: "werk", URL: "https://bp.onprem.test/werk",
|
||||
D: d, Site: Site{OnPrem: true, Imprint: "https://intranet.onprem.test/impressum", Privacy: "https://intranet.onprem.test/datenschutz", Contact: "IT <it@onprem.test>"}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, body := range []string{full.Text, full.HTML} {
|
||||
for _, bad := range ours {
|
||||
if strings.Contains(body, bad) {
|
||||
t.Errorf("%s/%s: %q in an on-prem mail", kind, c.lang, bad)
|
||||
}
|
||||
}
|
||||
for _, want := range []string{c.note, c.ask, "https://intranet.onprem.test/impressum", "https://intranet.onprem.test/datenschutz"} {
|
||||
if !strings.Contains(body, want) {
|
||||
t.Errorf("%s/%s: %q missing", kind, c.lang, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
if !strings.Contains(full.Text, "IT <it@onprem.test>") || !strings.Contains(full.HTML, "IT <it@onprem.test>") {
|
||||
t.Errorf("%s/%s: contact not shown (escaped in HTML)", kind, c.lang)
|
||||
}
|
||||
if strings.Index(full.Text, c.note) > strings.Index(full.Text, "\n--\n") {
|
||||
t.Errorf("%s/%s: note after the footer", kind, c.lang)
|
||||
}
|
||||
// Nothing named: no legal line, no contact, no empty link.
|
||||
bare, _ := Render(kind, c.lang, View{Tenant: "werk", URL: "https://bp.onprem.test/werk", D: d, Site: Site{OnPrem: true}})
|
||||
for _, body := range []string{bare.Text, bare.HTML} {
|
||||
for _, bad := range append(ours, c.imprint+":", c.ask+":", `href=""`) {
|
||||
if strings.Contains(body, bad) {
|
||||
t.Errorf("%s/%s bare: %q", kind, c.lang, bad)
|
||||
}
|
||||
}
|
||||
}
|
||||
if !strings.HasSuffix(bare.Text, "werk verwalten.\n") && !strings.HasSuffix(bare.Text, "einsehen dürfen.\n") &&
|
||||
!strings.HasSuffix(bare.Text, ".\n") {
|
||||
t.Errorf("%s/%s bare: text ends %q", kind, c.lang, bare.Text[max(0, len(bare.Text)-40):])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuild_attachmentsAreAMixedMultipart(t *testing.T) {
|
||||
pdf := bytes.Repeat([]byte("%PDF-1.7 Testbedingungen \x00\xff"), 20)
|
||||
raw := Build(Message{To: "a@b.de", Subject: "Aktiviert", Text: "Text ä", HTML: "<p>ä</p>",
|
||||
|
||||
@@ -37,8 +37,31 @@ type View struct {
|
||||
URL string
|
||||
Subject string
|
||||
D map[string]any
|
||||
// Site is who sends the mail; the zero value is the cloud.
|
||||
Site Site
|
||||
}
|
||||
|
||||
// Site decides the signature and the legal links of every mail.
|
||||
//
|
||||
// In the cloud the mail comes from Breakpilot GmbH: the company signature
|
||||
// (no-reply sender, address, register entry) and our imprint and privacy
|
||||
// notice. On a customer's own installation (APP_ENV=onprem) it comes from
|
||||
// their system, through their relay and from their address: no company
|
||||
// signature of ours, their imprint and privacy notice if they name one, and
|
||||
// whom to ask (their IT) instead of our contact address.
|
||||
type Site struct {
|
||||
OnPrem bool
|
||||
Imprint string // legal notice URL; on-prem empty = left out
|
||||
Privacy string // privacy notice URL; on-prem empty = left out
|
||||
Contact string // on-prem: whom to ask (an address or a short text); empty = left out
|
||||
}
|
||||
|
||||
// Cloud legal pages, used when a cloud Site leaves them empty.
|
||||
const (
|
||||
CloudImprint = "https://breakpilot.com/impressum"
|
||||
CloudPrivacy = "https://app.breakpilot.com/datenschutz"
|
||||
)
|
||||
|
||||
// Render builds the subject, text and HTML body of kind in locale ("de"
|
||||
// unless "en"). HTML values are escaped by html/template; the text body and
|
||||
// subject are plain.
|
||||
@@ -50,6 +73,14 @@ func Render(kind, locale string, v View) (Message, error) {
|
||||
locale = "de"
|
||||
}
|
||||
v.Lang = locale
|
||||
if !v.Site.OnPrem {
|
||||
if v.Site.Imprint == "" {
|
||||
v.Site.Imprint = CloudImprint
|
||||
}
|
||||
if v.Site.Privacy == "" {
|
||||
v.Site.Privacy = CloudPrivacy
|
||||
}
|
||||
}
|
||||
if v.D == nil {
|
||||
v.D = map[string]any{}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
{{define "button"}}Dokument öffnen{{end}}
|
||||
{{define "footer"}}Sie erhalten diese E-Mail, weil Sie im Arbeitsbereich {{.Tenant}} Unterlagen einsehen dürfen.{{end}}
|
||||
{{define "html"}}<p style="margin:0 0 12px 0;font-size:18px;font-weight:bold;">Ein neues Dokument liegt für Sie bereit</p>
|
||||
<p style="margin:0 0 12px 0;">BreakPilot hat im Arbeitsbereich <strong>{{.Tenant}}</strong> ein Dokument veröffentlicht:</p>
|
||||
<p style="margin:0 0 12px 0;">Breakpilot hat im Arbeitsbereich <strong>{{.Tenant}}</strong> ein Dokument veröffentlicht:</p>
|
||||
<p style="margin:0 0 4px 0;font-weight:bold;">{{.D.title}}</p>
|
||||
{{if .D.description}}<p style="margin:0 0 12px 0;color:#414669;">{{.D.description}}</p>{{end}}
|
||||
<p style="margin:0 0 12px 0;">Sie finden es im Portal unter <em>Dokumente</em>. Jeder Download wird im Audit-Log festgehalten.</p>{{end}}
|
||||
{{define "text"}}Ein neues Dokument liegt für Sie bereit
|
||||
|
||||
BreakPilot hat im Arbeitsbereich {{.Tenant}} ein Dokument veröffentlicht:
|
||||
Breakpilot hat im Arbeitsbereich {{.Tenant}} ein Dokument veröffentlicht:
|
||||
|
||||
{{.D.title}}
|
||||
{{if .D.description}} {{.D.description}}
|
||||
@@ -20,4 +20,4 @@ Sie finden es im Portal unter "Dokumente":
|
||||
|
||||
--
|
||||
Sie erhalten diese E-Mail, weil Sie im Arbeitsbereich {{.Tenant}} Unterlagen einsehen dürfen.
|
||||
BreakPilot GmbH · https://breakpilot.com/impressum{{end}}
|
||||
{{template "legal_text" .}}{{end}}
|
||||
@@ -28,4 +28,4 @@ Befunde ansehen:
|
||||
|
||||
--
|
||||
Sie erhalten diese E-Mail, weil Sie den Arbeitsbereich {{.Tenant}} verwalten.
|
||||
Breakpilot GmbH · https://breakpilot.com/impressum{{end}}
|
||||
{{template "legal_text" .}}{{end}}
|
||||
@@ -37,4 +37,4 @@ Die Vertragsbedingungen im Anhang sind die für Ihren Vertrag geltende Fassung.
|
||||
|
||||
--
|
||||
Sie erhalten diese E-Mail, weil Sie einen kostenlosen Breakpilot-Testzugang für {{.D.company_name}} angefordert und Ihre E-Mail-Adresse bestätigt haben.
|
||||
Breakpilot GmbH · https://breakpilot.com/impressum · https://app.breakpilot.com/datenschutz{{end}}
|
||||
{{template "legal_text_full" .}}{{end}}
|
||||
@@ -33,4 +33,4 @@ Der Bestätigungslink ist {{.D.valid_hours}} Stunden gültig und kann einmal ver
|
||||
|
||||
--
|
||||
Sie erhalten diese E-Mail, weil mit dieser Adresse ein kostenloser Breakpilot-Testzugang angefordert wurde. Waren Sie das nicht, ignorieren Sie diese E-Mail: Ohne Bestätigung wird nichts freigeschaltet.
|
||||
Breakpilot GmbH · https://breakpilot.com/impressum · https://app.breakpilot.com/datenschutz{{end}}
|
||||
{{template "legal_text_full" .}}{{end}}
|
||||
@@ -2,13 +2,13 @@
|
||||
{{define "button"}}Open the document{{end}}
|
||||
{{define "footer"}}You receive this email because you may view documents in the {{.Tenant}} workspace.{{end}}
|
||||
{{define "html"}}<p style="margin:0 0 12px 0;font-size:18px;font-weight:bold;">A new document is ready for you</p>
|
||||
<p style="margin:0 0 12px 0;">BreakPilot published a document in the <strong>{{.Tenant}}</strong> workspace:</p>
|
||||
<p style="margin:0 0 12px 0;">Breakpilot published a document in the <strong>{{.Tenant}}</strong> workspace:</p>
|
||||
<p style="margin:0 0 4px 0;font-weight:bold;">{{.D.title}}</p>
|
||||
{{if .D.description}}<p style="margin:0 0 12px 0;color:#414669;">{{.D.description}}</p>{{end}}
|
||||
<p style="margin:0 0 12px 0;">You find it in the portal under <em>Documents</em>. Every download is recorded in the audit log.</p>{{end}}
|
||||
{{define "text"}}A new document is ready for you
|
||||
|
||||
BreakPilot published a document in the {{.Tenant}} workspace:
|
||||
Breakpilot published a document in the {{.Tenant}} workspace:
|
||||
|
||||
{{.D.title}}
|
||||
{{if .D.description}} {{.D.description}}
|
||||
@@ -20,4 +20,4 @@ You find it in the portal under "Documents":
|
||||
|
||||
--
|
||||
You receive this email because you may view documents in the {{.Tenant}} workspace.
|
||||
BreakPilot GmbH · https://breakpilot.com/impressum{{end}}
|
||||
{{template "legal_text" .}}{{end}}
|
||||
@@ -28,4 +28,4 @@ View the findings:
|
||||
|
||||
--
|
||||
You receive this email because you administer the {{.Tenant}} workspace.
|
||||
Breakpilot GmbH · https://breakpilot.com/impressum{{end}}
|
||||
{{template "legal_text" .}}{{end}}
|
||||
@@ -20,8 +20,7 @@
|
||||
{{template "signature_html" .}}
|
||||
</td></tr>
|
||||
<tr><td style="padding:18px 28px;border-top:1px solid #EFF0F6;font-size:11.5px;line-height:1.6;color:#5E6384;">
|
||||
{{template "footer" .}}<br>
|
||||
Breakpilot GmbH · <a href="https://breakpilot.com/impressum" style="color:#5E6384;">{{if eq .Lang "de"}}Impressum{{else}}Imprint{{end}}</a> · <a href="https://app.breakpilot.com/datenschutz" style="color:#5E6384;">{{if eq .Lang "de"}}Datenschutz{{else}}Privacy{{end}}</a>
|
||||
{{template "footer" .}}{{template "legal_html" .}}
|
||||
</td></tr>
|
||||
</table>
|
||||
</td></tr>
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
{{/* The company signature of every mail, modelled on the founders' signature
|
||||
(Brand_Assets/Email_Signature) but for the no-reply sender. Company data
|
||||
as in the website's Impressum. */}}
|
||||
{{define "signature_html"}}<table role="presentation" cellpadding="0" cellspacing="0" style="font-size:13px;line-height:1.5;color:#14162B;border-collapse:collapse;">
|
||||
as in the website's Impressum. On a customer's own installation
|
||||
(.Site.OnPrem) the mail comes from their system instead: a short note,
|
||||
whom to ask there, no company data of ours. */}}
|
||||
{{define "signature_html"}}{{if .Site.OnPrem}}{{template "signature_onprem_html" .}}{{else}}<table role="presentation" cellpadding="0" cellspacing="0" style="font-size:13px;line-height:1.5;color:#14162B;border-collapse:collapse;">
|
||||
<tr><td style="vertical-align:top;">
|
||||
<div style="font-size:12px;color:#71769B;">{{if eq .Lang "de"}}Mit freundlichen Grüßen{{else}}Kind regards{{end}}</div>
|
||||
<div style="font-size:16px;font-weight:800;letter-spacing:-0.02em;color:#14162B;margin:1px 0 10px;">{{if eq .Lang "de"}}Ihr BreakPilot-Team{{else}}Your BreakPilot team{{end}}</div>
|
||||
<div style="font-size:16px;font-weight:800;letter-spacing:-0.02em;color:#14162B;margin:1px 0 10px;">{{if eq .Lang "de"}}Ihr Breakpilot-Team{{else}}Your Breakpilot team{{end}}</div>
|
||||
<div style="font-weight:700;color:#14162B;">Breakpilot GmbH</div>
|
||||
<div style="color:#43466A;">In Steinäckern 16</div>
|
||||
<div style="color:#43466A;">78351 Bodman-Ludwigshafen</div>
|
||||
@@ -15,10 +17,10 @@
|
||||
<div style="font-size:11px;color:#8b8fae;">USt.-ID: DE464808363</div>
|
||||
<div style="font-size:11px;color:#8b8fae;">Amtsgericht Freiburg, HRB 736403</div>
|
||||
<div style="font-size:11px;color:#8b8fae;">{{if eq .Lang "de"}}Geschäftsführer{{else}}Managing directors{{end}}: Benjamin Bönisch {{if eq .Lang "de"}}und{{else}}and{{end}} Sharang Deepak Parnerkar</div>
|
||||
</td></tr></table>{{end}}
|
||||
{{define "signature_text"}}{{if eq .Lang "de"}}Mit freundlichen Grüßen
|
||||
Ihr BreakPilot-Team{{else}}Kind regards
|
||||
Your BreakPilot team{{end}}
|
||||
</td></tr></table>{{end}}{{end}}
|
||||
{{define "signature_text"}}{{if .Site.OnPrem}}{{template "signature_onprem_text" .}}{{else}}{{if eq .Lang "de"}}Mit freundlichen Grüßen
|
||||
Ihr Breakpilot-Team{{else}}Kind regards
|
||||
Your Breakpilot team{{end}}
|
||||
|
||||
Breakpilot GmbH
|
||||
In Steinäckern 16
|
||||
@@ -30,4 +32,22 @@ Web: www.breakpilot.com
|
||||
|
||||
USt.-ID: DE464808363
|
||||
Amtsgericht Freiburg, HRB 736403
|
||||
{{if eq .Lang "de"}}Geschäftsführer{{else}}Managing directors{{end}}: Benjamin Bönisch {{if eq .Lang "de"}}und{{else}}and{{end}} Sharang Deepak Parnerkar{{end}}
|
||||
{{if eq .Lang "de"}}Geschäftsführer{{else}}Managing directors{{end}}: Benjamin Bönisch {{if eq .Lang "de"}}und{{else}}and{{end}} Sharang Deepak Parnerkar{{end}}{{end}}
|
||||
{{define "signature_onprem_html"}}<div style="font-size:12.5px;line-height:1.55;color:#43466A;">
|
||||
{{if eq .Lang "de"}}Diese Nachricht hat Breakpilot verschickt, die Installation in Ihrem Unternehmen. Antworten an diese Adresse werden nicht gelesen.{{else}}This message was sent by Breakpilot, the installation in your company. Replies to this address are not read.{{end}}
|
||||
{{with .Site.Contact}}<br><span style="color:#9a9db8;">{{if eq $.Lang "de"}}Fragen{{else}}Questions{{end}}:</span> {{.}}{{end}}
|
||||
</div>{{end}}
|
||||
{{define "signature_onprem_text"}}{{if eq .Lang "de"}}Diese Nachricht hat Breakpilot verschickt, die Installation in Ihrem
|
||||
Unternehmen. Antworten an diese Adresse werden nicht gelesen.{{else}}This message was sent by Breakpilot, the installation in your company.
|
||||
Replies to this address are not read.{{end}}{{with .Site.Contact}}
|
||||
{{if eq $.Lang "de"}}Fragen{{else}}Questions{{end}}: {{.}}{{end}}{{end}}
|
||||
|
||||
{{/* The legal line under the footer. Cloud: our company with imprint (and,
|
||||
in the trial mails, the privacy notice). On-prem: the customer's pages,
|
||||
each only if named. */}}
|
||||
{{define "legal_text"}}{{if .Site.OnPrem}}{{template "legal_onprem_text" .}}{{else}}Breakpilot GmbH · {{.Site.Imprint}}{{end}}{{end}}
|
||||
{{define "legal_text_full"}}{{if .Site.OnPrem}}{{template "legal_onprem_text" .}}{{else}}Breakpilot GmbH · {{.Site.Imprint}} · {{.Site.Privacy}}{{end}}{{end}}
|
||||
{{define "legal_onprem_text"}}{{with .Site.Imprint}}{{if eq $.Lang "de"}}Impressum{{else}}Imprint{{end}}: {{.}}{{end}}{{if and .Site.Imprint .Site.Privacy}} · {{end}}{{with .Site.Privacy}}{{if eq $.Lang "de"}}Datenschutz{{else}}Privacy{{end}}: {{.}}{{end}}{{end}}
|
||||
{{define "legal_html"}}{{if .Site.OnPrem}}{{if or .Site.Imprint .Site.Privacy}}<br>
|
||||
{{with .Site.Imprint}}<a href="{{.}}" style="color:#5E6384;">{{if eq $.Lang "de"}}Impressum{{else}}Imprint{{end}}</a>{{end}}{{if and .Site.Imprint .Site.Privacy}} · {{end}}{{with .Site.Privacy}}<a href="{{.}}" style="color:#5E6384;">{{if eq $.Lang "de"}}Datenschutz{{else}}Privacy{{end}}</a>{{end}}{{end}}{{else}}<br>
|
||||
Breakpilot GmbH · <a href="{{.Site.Imprint}}" style="color:#5E6384;">{{if eq .Lang "de"}}Impressum{{else}}Imprint{{end}}</a> · <a href="{{.Site.Privacy}}" style="color:#5E6384;">{{if eq .Lang "de"}}Datenschutz{{else}}Privacy{{end}}</a>{{end}}{{end}}
|
||||
@@ -37,6 +37,13 @@ func (s *Server) portalURL() string {
|
||||
return u
|
||||
}
|
||||
|
||||
// mailSite is who the registry's mails come from (mail.Site): the cloud
|
||||
// company, or the customer's installation with their legal pages and contact.
|
||||
func (s *Server) mailSite() mail.Site {
|
||||
c := s.cfg()
|
||||
return mail.Site{OnPrem: c.OnPrem(), Imprint: c.LegalImprintURL, Privacy: c.LegalPrivacyURL, Contact: c.MailContact}
|
||||
}
|
||||
|
||||
// notifyTenant queues kind for every enabled member of t whose bundle grants
|
||||
// the kind's capability. Demo tenants get nothing. Returns how many rows were
|
||||
// queued (0 for a repeat of the same key).
|
||||
@@ -231,7 +238,7 @@ func (s *Server) DrainMail(ctx context.Context) (int, error) {
|
||||
func (s *Server) sendMail(ctx context.Context, it store.MailItem) error {
|
||||
tenant, _ := it.Data["tenant_name"].(string)
|
||||
url, _ := it.Data["url"].(string)
|
||||
msg, err := mail.Render(it.Kind, it.Locale, mail.View{Tenant: tenant, URL: url, D: it.Data})
|
||||
msg, err := mail.Render(it.Kind, it.Locale, mail.View{Tenant: tenant, URL: url, D: it.Data, Site: s.mailSite()})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"time"
|
||||
|
||||
"git.breakpilot.com/platform/tenant-registry/internal/config"
|
||||
"git.breakpilot.com/platform/tenant-registry/internal/mail"
|
||||
"git.breakpilot.com/platform/tenant-registry/internal/store"
|
||||
)
|
||||
|
||||
@@ -384,3 +385,39 @@ func TestTenantStatusForTheAdminOnlyOnPrem(t *testing.T) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// A notification on-prem is the installation's mail: no company signature or
|
||||
// legal pages of ours, the customer's contact and pages from the values.
|
||||
func TestOnPrem_notificationMailIsTheInstallations(t *testing.T) {
|
||||
eachStore(t, func(t *testing.T, h *testHarness) {
|
||||
onPremHarness(h, nil)
|
||||
h.app.Cfg.PortalURL = "https://bp.onprem.test"
|
||||
h.app.Cfg.MailContact = "it@onprem.test"
|
||||
h.app.Cfg.LegalPrivacyURL = "https://intranet.onprem.test/datenschutz"
|
||||
rec := &mail.Recorder{}
|
||||
h.app.Mail = rec
|
||||
seedMembers(h, "acme")
|
||||
body := map[string]any{"tenant_id": h.tenant.ID, "kind": "findings.new", "idempotency_key": "scan-1",
|
||||
"data": map[string]any{"target_name": "Presse", "new_count": 1, "url": "https://pruefwerk.onprem.test/targets/t1"}}
|
||||
if resp, raw := h.do("POST", "/v1/notifications", body); resp.StatusCode != 202 {
|
||||
t.Fatalf("queue: %d %s", resp.StatusCode, raw)
|
||||
}
|
||||
if _, err := h.app.DrainMail(context.Background()); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
msgs := rec.Messages()
|
||||
if len(msgs) == 0 {
|
||||
t.Fatal("no mail")
|
||||
}
|
||||
for _, m := range msgs {
|
||||
for _, b := range []string{m.Text, m.HTML} {
|
||||
if strings.Contains(b, "breakpilot.com") || strings.Contains(b, "Breakpilot GmbH") {
|
||||
t.Fatalf("cloud data in an on-prem mail:\n%s", b)
|
||||
}
|
||||
if !strings.Contains(b, "it@onprem.test") || !strings.Contains(b, "https://intranet.onprem.test/datenschutz") {
|
||||
t.Fatalf("contact or privacy link missing:\n%s", b)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -249,6 +249,7 @@ func (s *Server) sendReceipt(ctx context.Context, o *store.TrialOffer, token str
|
||||
return false
|
||||
}
|
||||
msg, err := bpmail.Render(bpmail.KindTrialReceived, "de", bpmail.View{
|
||||
Site: s.mailSite(),
|
||||
Tenant: o.CompanyName,
|
||||
URL: s.portalURL() + "/start/bestaetigen?token=" + token,
|
||||
D: map[string]any{
|
||||
@@ -494,6 +495,7 @@ func (s *Server) sendActivation(ctx context.Context, o *store.TrialOffer, t *sto
|
||||
}
|
||||
workspace := s.portalURL() + "/" + t.Slug
|
||||
msg, err := bpmail.Render(bpmail.KindTrialActivated, "de", bpmail.View{
|
||||
Site: s.mailSite(),
|
||||
Tenant: o.CompanyName,
|
||||
URL: workspace + "/dashboard",
|
||||
D: map[string]any{
|
||||
|
||||
Reference in new issue
Block a user