Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(sdk-go): name the status fonts after the protocol
Yudhi Armyndharisbbbb7d6da7e0
diff --git a/sdk/go/client_test.go b/sdk/go/client_test.goindex 6455b1925..5aa6eb155 100644--- a/sdk/go/client_test.go+++ b/sdk/go/client_test.go@@ -1952,3 +1952,54 @@ func TestRetryKeepsIdempotencyKey(t *testing.T) {}}}++// The status font ids are the wire values of the Baileys protocol's ExtendedTextMessage.FontType. The+// constants carry the protocol's names; the first-release names for the same ids stay as deprecated+// aliases so existing code keeps compiling and sending the same numbers.+func TestStatusFontConstants(t *testing.T) {+ cases := []struct {+ name string+ got StatusFont+ want int+ }{+ {"SYSTEM", StatusFontDefault, 0},+ {"SYSTEM_TEXT", StatusFontSystemText, 1},+ {"FB_SCRIPT", StatusFontFBScript, 2},+ {"SYSTEM_BOLD", StatusFontBold, 6},+ {"MORNINGBREEZE_REGULAR", StatusFontMorningBreezeRegular, 7},+ {"CALISTOGA_REGULAR", StatusFontCalistogaRegular, 8},+ {"EXO2_EXTRABOLD", StatusFontExo2ExtraBold, 9},+ {"COURIERPRIME_BOLD", StatusFontCourierPrimeBold, 10},+ }+ for _, c := range cases {+ if int(c.got) != c.want {+ t.Errorf("%s = %d, want %d", c.name, c.got, c.want)+ }+ }++ aliases := []struct {+ name string+ old StatusFont+ want StatusFont+ }{+ {"StatusFontSerif", StatusFontSerif, StatusFontSystemText},+ {"StatusFontNorican", StatusFontNorican, StatusFontFBScript},+ {"StatusFontOswald", StatusFontOswald, StatusFontMorningBreezeRegular},+ {"StatusFontDamion", StatusFontDamion, StatusFontCalistogaRegular},+ {"StatusFontMorningbreeze", StatusFontMorningbreeze, StatusFontExo2ExtraBold},+ {"StatusFontBryndan", StatusFontBryndan, StatusFontCourierPrimeBold},+ }+ for _, a := range aliases {+ if a.old != a.want {+ t.Errorf("%s = %d, want the wire value %d it always had", a.name, a.old, a.want)+ }+ }++ body, err := json.Marshal(SendTextStatusRequest{Text: "hi", Font: Ptr(StatusFontCourierPrimeBold)})+ if err != nil {+ t.Fatalf("marshal: %v", err)+ }+ if !strings.Contains(string(body), `"font":10`) {+ t.Errorf("font did not marshal as a bare number: %s", body)+ }+}diff --git a/sdk/go/types_status.go b/sdk/go/types_status.goindex cb244aec3..7e2aa022a 100644--- a/sdk/go/types_status.go+++ b/sdk/go/types_status.go@@ -47,19 +47,39 @@ type StatusMedia struct {ContentType string}-// StatusFont is a WhatsApp status font family. whatsapp-web.js honors only 0 to 7 and posts 8, 9 and-// 10 in the default font.+// StatusFont is a WhatsApp status font family: the wire value of the protocol's+// ExtendedTextMessage.FontType, and the constants carry the protocol's names for the ids. 3 to 5 are not+// part of the enum and the gateway rejects them. whatsapp-web.js honors only 0 to 7 and posts 8, 9 and 10+// in the default font.type StatusFont intconst (- StatusFontDefault StatusFont = 0- StatusFontSerif StatusFont = 1- StatusFontNorican StatusFont = 2- StatusFontBold StatusFont = 6- StatusFontOswald StatusFont = 7- StatusFontDamion StatusFont = 8- StatusFontMorningbreeze StatusFont = 9- StatusFontBryndan StatusFont = 10+ StatusFontDefault StatusFont = 0 // SYSTEM+ StatusFontSystemText StatusFont = 1 // SYSTEM_TEXT+ StatusFontFBScript StatusFont = 2 // FB_SCRIPT+ StatusFontBold StatusFont = 6 // SYSTEM_BOLD+ StatusFontMorningBreezeRegular StatusFont = 7 // MORNINGBREEZE_REGULAR+ StatusFontCalistogaRegular StatusFont = 8 // CALISTOGA_REGULAR+ StatusFontExo2ExtraBold StatusFont = 9 // EXO2_EXTRABOLD+ StatusFontCourierPrimeBold StatusFont = 10 // COURIERPRIME_BOLD+)++// The names below came with the first release of these constants. They do not match the protocol's names+// for the same ids (7 is MORNINGBREEZE_REGULAR there, not Oswald; 9 is EXO2_EXTRABOLD, not Morning Breeze),+// so they are kept only for code that already uses them. Each carries the wire value it always had.+const (+ // Deprecated: use StatusFontSystemText.+ StatusFontSerif StatusFont = StatusFontSystemText+ // Deprecated: use StatusFontFBScript.+ StatusFontNorican StatusFont = StatusFontFBScript+ // Deprecated: use StatusFontMorningBreezeRegular.+ StatusFontOswald StatusFont = StatusFontMorningBreezeRegular+ // Deprecated: use StatusFontCalistogaRegular.+ StatusFontDamion StatusFont = StatusFontCalistogaRegular+ // Deprecated: use StatusFontExo2ExtraBold.+ StatusFontMorningbreeze StatusFont = StatusFontExo2ExtraBold+ // Deprecated: use StatusFontCourierPrimeBold.+ StatusFontBryndan StatusFont = StatusFontCourierPrimeBold)// SendTextStatusRequest posts a text status. Recipients is required on the Baileys