From fe3eaee3fbb046e67e663df2bd1dbf653629e718 Mon Sep 17 00:00:00 2001 From: Abhinav Raut Date: Sat, 25 Jul 2026 14:45:11 +0530 Subject: [PATCH] use one country list and renumber the whatsapp migration to v2.8.0 The WhatsApp migration was numbered v3.0.0, but help center added v2.5.0 through v2.7.0 and ships first. Renamed it to v2.8.0 so the upgrade path stays in order. Country data had two copies after the merge. The frontend kept its own hand written list in shared-ui, and the WhatsApp branch added an API backed store reading the same data from Go. Both lists were identical. Now countries.json in internal/countries is the only source. The shared-ui constant imports it through a new @countries Vite alias, so PhoneNumberInput, phone.js and ContactForm keep working as before. The sidebar and the WhatsApp form read the constant directly instead of fetching on mount. Static wins over the API here because the widget uses PhoneNumberInput and cannot call an authenticated endpoint, and phone.js builds its zod schema synchronously. So the countries store, api.getCountries, the /api/v1/countries route and countries.JSON() are gone. DialCodeForISO stays, it still builds the WhatsApp wa_id. --- cmd/config.go | 7 - cmd/handlers.go | 1 - cmd/upgrade.go | 2 +- frontend/apps/main/src/api/index.js | 2 - .../conversation/WhatsAppConversationForm.vue | 8 +- .../sidebar/ConversationSideBarContact.vue | 8 +- frontend/apps/main/src/stores/countries.js | 48 ---- frontend/shared-ui/constants/countries.js | 243 +----------------- frontend/vite.config.js | 6 +- internal/countries/countries.go | 5 - internal/migrations/{v3.0.0.go => v2.8.0.go} | 2 +- 11 files changed, 13 insertions(+), 319 deletions(-) delete mode 100644 frontend/apps/main/src/stores/countries.js rename internal/migrations/{v3.0.0.go => v2.8.0.go} (98%) diff --git a/cmd/config.go b/cmd/config.go index ba258900..8a04a219 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -3,7 +3,6 @@ package main import ( "encoding/json" - "github.com/abhinavxd/libredesk/internal/countries" "github.com/abhinavxd/libredesk/internal/envelope" "github.com/zerodha/fastglue" ) @@ -62,9 +61,3 @@ func handleGetConfig(r *fastglue.Request) error { return r.SendEnvelope(publicSettings) } - -// handleGetCountries returns the static country reference list (dial code, name, emoji, ISO-2) used by phone inputs. -func handleGetCountries(r *fastglue.Request) error { - r.RequestCtx.Response.Header.Set("Cache-Control", "private, max-age=86400") - return r.SendEnvelope(json.RawMessage(countries.JSON())) -} diff --git a/cmd/handlers.go b/cmd/handlers.go index 42c318af..0e9f4068 100644 --- a/cmd/handlers.go +++ b/cmd/handlers.go @@ -32,7 +32,6 @@ func initHandlers(g *fastglue.Fastglue, hub *ws.Hub) { g.GET("/api/v1/config", handleGetConfig) // Static country reference list for phone inputs. - g.GET("/api/v1/countries", auth(handleGetCountries)) // Media - supports both authenticated access and signed URLs. g.GET("/uploads/{uuid}", authOrSignedURL(handleServeMedia)) diff --git a/cmd/upgrade.go b/cmd/upgrade.go index a1fdfb72..38a48f3b 100644 --- a/cmd/upgrade.go +++ b/cmd/upgrade.go @@ -47,7 +47,7 @@ var migList = []migFunc{ {"v2.5.0", migrations.V2_5_0}, {"v2.6.0", migrations.V2_6_0}, {"v2.7.0", migrations.V2_7_0}, - {"v3.0.0", migrations.V3_0_0}, + {"v2.8.0", migrations.V2_8_0}, } // upgrade upgrades the database to the current version by running SQL migration files diff --git a/frontend/apps/main/src/api/index.js b/frontend/apps/main/src/api/index.js index cb80349f..23549107 100644 --- a/frontend/apps/main/src/api/index.js +++ b/frontend/apps/main/src/api/index.js @@ -132,7 +132,6 @@ const createOIDC = (data) => } }) const getConfig = () => http.get('/api/v1/config') -const getCountries = () => http.get('/api/v1/countries') const getAllOIDC = () => http.get('/api/v1/oidc') const getOIDC = (id) => http.get(`/api/v1/oidc/${id}`) const updateOIDC = (id, data) => @@ -706,7 +705,6 @@ export default { createOIDC, getAllOIDC, getConfig, - getCountries, getOIDC, updateOIDC, deleteOIDC, diff --git a/frontend/apps/main/src/features/conversation/WhatsAppConversationForm.vue b/frontend/apps/main/src/features/conversation/WhatsAppConversationForm.vue index 7611c881..28bbf4b2 100644 --- a/frontend/apps/main/src/features/conversation/WhatsAppConversationForm.vue +++ b/frontend/apps/main/src/features/conversation/WhatsAppConversationForm.vue @@ -169,9 +169,8 @@