fix
This commit is contained in:
1 parent
8b540d22bc
commit
c92ee93482
24 files changed
+1495
-327
No files matched your search
@@ -1877,7 +1877,7 @@ func localizedFallbackFeaturesHeading(lang string) string {
|
||||
labels := map[string]string{
|
||||
"sl": "Ključne lastnosti", "hr": "Ključne značajke", "de": "Wichtige Merkmale", "fr": "Caractéristiques principales", "es": "Características principales", "it": "Caratteristiche principali", "nl": "Belangrijkste kenmerken", "pt": "Principais características", "pl": "Najważniejsze cechy", "cs": "Hlavní vlastnosti", "sk": "Hlavné vlastnosti", "hu": "Főbb jellemzők", "ro": "Caracteristici principale", "bg": "Основни характеристики", "sv": "Viktiga egenskaper", "da": "Vigtige egenskaber", "fi": "Tärkeimmät ominaisuudet", "el": "Κύρια χαρακτηριστικά", "et": "Peamised omadused", "lv": "Galvenās īpašības", "lt": "Pagrindinės savybės", "mt": "Karatteristiċi ewlenin", "ga": "Príomhghnéithe", "ja": "主な特長",
|
||||
}
|
||||
if value := labels[language]; value != "" {
|
||||
if value := labels[lang]; value != "" {
|
||||
return value
|
||||
}
|
||||
return "Key features"
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/descrybe/descrybe-v2/apps/api/internal/billing"
|
||||
"github.com/descrybe/descrybe-v2/apps/api/internal/catalog"
|
||||
"github.com/descrybe/descrybe-v2/apps/api/internal/company"
|
||||
"github.com/descrybe/descrybe-v2/apps/api/internal/eprel"
|
||||
@@ -488,40 +487,16 @@ func nullIfEmptyPtr(s *string) any {
|
||||
return *s
|
||||
}
|
||||
|
||||
// Known v2 companies.id values that omit SEO meta on V1 process payloads.
|
||||
// A1 Slovenija is also matched via billing.A1LegacyCompanyID (legacy_company_id / PK).
|
||||
const (
|
||||
a1V2CompanyID = "604f23a8-b66e-4b21-8b45-0d72b68f4790"
|
||||
platformDemoV2CompanyID = "2b3159b0-fc08-415b-b248-35ed02a6baab"
|
||||
)
|
||||
// Only the Platform Demo company explicitly suppresses generated SEO meta.
|
||||
// A1 now uses its category Meta formula like all production companies.
|
||||
const platformDemoV2CompanyID = "2b3159b0-fc08-415b-b248-35ed02a6baab"
|
||||
|
||||
// CompanyOmitsSEOMetaID is true for A1 Slovenija and Platform Demo by companies.id
|
||||
// (or the migrated MySQL company id). Does not grant Legacy plan privileges.
|
||||
func CompanyOmitsSEOMetaID(companyID uuid.UUID) bool {
|
||||
if companyID == uuid.Nil {
|
||||
return false
|
||||
}
|
||||
id := strings.ToLower(companyID.String())
|
||||
switch id {
|
||||
case a1V2CompanyID, platformDemoV2CompanyID, strings.ToLower(billing.A1LegacyCompanyID):
|
||||
return true
|
||||
}
|
||||
return false
|
||||
return companyID != uuid.Nil && strings.EqualFold(companyID.String(), platformDemoV2CompanyID)
|
||||
}
|
||||
|
||||
// CompanyOmitsSEOMetaLookup is the shared A1/Demo SEO-omit decision used by V1 process
|
||||
// and catalog list/get/update. Matches hardcoded companies.id, A1 cohort (legacy id),
|
||||
// or Platform Demo by name. Role-sectioned category prompts (--- Title --- / --- Meta ---)
|
||||
// are the platform-wide canonical prompt shape now, so they no longer imply the A1
|
||||
// cohort — sniffing them here made any tenant using the prompt editor lose SEO meta.
|
||||
func CompanyOmitsSEOMetaLookup(companyID uuid.UUID, legacyID, name string) bool {
|
||||
if CompanyOmitsSEOMetaID(companyID) {
|
||||
return true
|
||||
}
|
||||
if billing.IsA1CohortCompany(legacyID, "") {
|
||||
return true
|
||||
}
|
||||
return strings.EqualFold(strings.TrimSpace(name), "Platform Demo")
|
||||
return CompanyOmitsSEOMetaID(companyID) || strings.EqualFold(strings.TrimSpace(name), "Platform Demo")
|
||||
}
|
||||
|
||||
// CompanyOmitsSEOMeta is true when catalog/V1 process must omit meta_title /
|
||||
|
||||
@@ -262,10 +262,10 @@ func TestCompanyOmitsSEOMetaLookup(t *testing.T) {
|
||||
wantOmit bool
|
||||
}{
|
||||
{name: "ordinary", id: other, coName: "Acme", wantOmit: false},
|
||||
{name: "a1_uuid", id: a1, wantOmit: true},
|
||||
{name: "a1_uuid", id: a1, wantOmit: false},
|
||||
{name: "demo_by_name", id: other, coName: "Platform Demo", wantOmit: true},
|
||||
{name: "demo_by_name_case", id: other, coName: " platform DEMO ", wantOmit: true},
|
||||
{name: "a1_legacy_id", id: other, legacy: "97e1a309-3d23-4aa2-b518-8e8d7afdfec7", wantOmit: true},
|
||||
{name: "a1_legacy_id", id: other, legacy: "97e1a309-3d23-4aa2-b518-8e8d7afdfec7", wantOmit: false},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/descrybe/descrybe-v2/apps/api/internal/billing"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
@@ -349,42 +348,29 @@ func TestCompanyOmitsSEOMetaID(t *testing.T) {
|
||||
t.Parallel()
|
||||
a1 := uuid.MustParse("604f23a8-b66e-4b21-8b45-0d72b68f4790")
|
||||
demo := uuid.MustParse("2b3159b0-fc08-415b-b248-35ed02a6baab")
|
||||
legacy := uuid.MustParse(billing.A1LegacyCompanyID)
|
||||
other := uuid.MustParse("11111111-1111-1111-1111-111111111111")
|
||||
if !CompanyOmitsSEOMetaID(a1) || !CompanyOmitsSEOMetaID(demo) || !CompanyOmitsSEOMetaID(legacy) {
|
||||
t.Fatal("A1, Demo, and legacy A1 ids must omit SEO meta")
|
||||
if CompanyOmitsSEOMetaID(a1) || !CompanyOmitsSEOMetaID(demo) {
|
||||
t.Fatal("A1 must emit SEO meta; Demo remains suppressed")
|
||||
}
|
||||
if CompanyOmitsSEOMetaID(other) || CompanyOmitsSEOMetaID(uuid.Nil) {
|
||||
t.Fatal("unrelated company ids must keep SEO meta")
|
||||
if CompanyOmitsSEOMetaLookup(a1, "", "A1 Slovenija") {
|
||||
t.Fatal("A1 production company must not suppress SEO meta")
|
||||
}
|
||||
}
|
||||
|
||||
func TestApplyV1SEOMetaPolicy_omitsOnlyA1(t *testing.T) {
|
||||
func TestApplyV1SEOMetaPolicy_keepsA1AndOmitsDemo(t *testing.T) {
|
||||
t.Parallel()
|
||||
item := V1ProcessJobItem{
|
||||
"ean": "1",
|
||||
"status": "processed",
|
||||
"meta_title": "T",
|
||||
"meta_description": "D",
|
||||
}
|
||||
item := V1ProcessJobItem{"ean": "1", "meta_title": "T", "meta_description": "D"}
|
||||
a1 := uuid.MustParse("604f23a8-b66e-4b21-8b45-0d72b68f4790")
|
||||
out := ApplyV1SEOMetaPolicy(a1, []V1ProcessJobItem{item})
|
||||
if _, ok := out[0]["meta_title"]; ok {
|
||||
t.Fatal("A1 must omit meta_title")
|
||||
}
|
||||
if _, ok := out[0]["meta_description"]; ok {
|
||||
t.Fatal("A1 must omit meta_description")
|
||||
}
|
||||
keep := V1ProcessJobItem{
|
||||
"ean": "1",
|
||||
"status": "processed",
|
||||
"meta_title": "T",
|
||||
"meta_description": "D",
|
||||
}
|
||||
other := uuid.MustParse("11111111-1111-1111-1111-111111111111")
|
||||
kept := ApplyV1SEOMetaPolicy(other, []V1ProcessJobItem{keep})
|
||||
kept := ApplyV1SEOMetaPolicy(a1, []V1ProcessJobItem{item})
|
||||
if kept[0]["meta_title"] != "T" || kept[0]["meta_description"] != "D" {
|
||||
t.Fatalf("non-A1 must keep SEO meta: %v", kept[0])
|
||||
t.Fatal("A1 SEO metadata must be retained")
|
||||
}
|
||||
demo := uuid.MustParse("2b3159b0-fc08-415b-b248-35ed02a6baab")
|
||||
stripped := ApplyV1SEOMetaPolicy(demo, []V1ProcessJobItem{item})
|
||||
if _, ok := stripped[0]["meta_title"]; ok {
|
||||
t.Fatal("Demo meta title must be omitted")
|
||||
}
|
||||
if _, ok := stripped[0]["meta_description"]; ok {
|
||||
t.Fatal("Demo meta description must be omitted")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user