fix(account): seed a fresh guest's interface language from the client locale

A guest was provisioned with only its detected time zone; its PreferredLanguage
fell to the 'en' column default. The client already sends its locale in the guest
login (GuestLoginRequest.locale), but the gateway dropped it and ProvisionGuest
took no language — so a Russian user's brand-new native guest got English
language-dependent server content (the ad banner, bot messages) until the client's
later language reconcile. Read the locale in the gateway guest handler, thread it
through GuestAuth -> ProvisionGuest, and seed PreferredLanguage from it (validated;
an unsupported/absent value keeps the 'en' default). Wire field already present —
no schema change.
This commit is contained in:
Ilia Denisov
2026-07-15 00:06:23 +02:00
parent b5fe61279b
commit f8aeec8008
9 changed files with 48 additions and 19 deletions
+4 -3
View File
@@ -312,11 +312,12 @@ func (c *Client) ChatAccessByUser(ctx context.Context, userID string) (ChatAcces
}
// GuestAuth provisions a guest account and mints a session, seeding its time zone
// from browserTz (the client's detected "±HH:MM" UTC offset).
func (c *Client) GuestAuth(ctx context.Context, browserTz, subtype string) (SessionResp, error) {
// from browserTz (the client's detected "±HH:MM" UTC offset) and its interface
// language from language (the client's detected locale; best-effort).
func (c *Client) GuestAuth(ctx context.Context, browserTz, subtype, language string) (SessionResp, error) {
var out SessionResp
err := c.do(ctx, http.MethodPost, "/api/v1/internal/sessions/guest", "", "",
map[string]string{"browser_tz": browserTz, "subtype": subtype}, &out)
map[string]string{"browser_tz": browserTz, "subtype": subtype, "language": language}, &out)
return out, err
}
+3 -2
View File
@@ -270,13 +270,14 @@ func authGuestHandler(backend *backendclient.Client) Handler {
// The guest bootstrap historically carried no payload; the detected zone is
// optional, so an absent or empty one simply yields no time-zone seed (rather
// than panicking in GetRootAs* on a zero-length buffer).
var browserTz, subtype string
var browserTz, subtype, locale string
if len(req.Payload) > 0 {
g := fb.GetRootAsGuestLoginRequest(req.Payload, 0)
browserTz = string(g.BrowserTz())
subtype = string(g.Subtype())
locale = string(g.Locale())
}
sess, err := backend.GuestAuth(ctx, browserTz, subtype)
sess, err := backend.GuestAuth(ctx, browserTz, subtype, locale)
if err != nil {
return nil, err
}