From 1c8bda5ded08175b216bb157ae292ac66d408deb Mon Sep 17 00:00:00 2001 From: Carlosokumu Date: Sat, 22 Mar 2025 09:49:19 +0300 Subject: [PATCH 1/6] fix(alias): remove alias requests made when a profile item is edited,show a default value when an alias is not set --- handlers/application/menuhandler.go | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/handlers/application/menuhandler.go b/handlers/application/menuhandler.go index e2d8751..9497b3d 100644 --- a/handlers/application/menuhandler.go +++ b/handlers/application/menuhandler.go @@ -1121,7 +1121,12 @@ func (h *MenuHandlers) GetCurrentProfileInfo(ctx context.Context, sym string, in logg.ErrorCtxf(ctx, "Failed to read account alias entry with", "key", "error", storedb.DATA_ACCOUNT_ALIAS, err) return res, err } - res.Content = string(profileInfo) + alias := string(profileInfo) + if alias == "" { + res.Content = defaultValue + } else { + res.Content = alias + } default: break } @@ -1167,6 +1172,8 @@ func (h *MenuHandlers) GetProfileInfo(ctx context.Context, sym string, input []b if alias != defaultValue { alias = strings.Split(alias, ".")[0] + } else if alias == "" { + alias = defaultValue } // Construct the full name @@ -1247,20 +1254,10 @@ func (h *MenuHandlers) UpdateAllProfileItems(ctx context.Context, sym string, in if !ok { return res, fmt.Errorf("missing session") } - flag_alias_set, _ := h.flagManager.GetFlag("flag_alias_set") - aliasSet := h.st.MatchFlag(flag_alias_set, true) - err := h.insertProfileItems(ctx, sessionId, &res) if err != nil { return res, err } - //Only request an alias if it has not been set yet: - if !aliasSet { - err = h.constructAccountAlias(ctx) - if err != nil { - return res, err - } - } return res, nil } -- 2.45.2 From b941cf256245f68a40888b33eb18c1d225e41f9b Mon Sep 17 00:00:00 2001 From: Carlosokumu Date: Sat, 22 Mar 2025 18:37:27 +0300 Subject: [PATCH 2/6] chore: match profile text prompt --- services/registration/my_account_alias | 2 +- services/registration/my_account_alias_swa | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/services/registration/my_account_alias b/services/registration/my_account_alias index 678037b..726f06b 100644 --- a/services/registration/my_account_alias +++ b/services/registration/my_account_alias @@ -1,2 +1,2 @@ Current alias: {{.get_current_profile_info}} -Edit my alias: \ No newline at end of file +Enter your preferred alias:: \ No newline at end of file diff --git a/services/registration/my_account_alias_swa b/services/registration/my_account_alias_swa index 6d88e89..0ea3166 100644 --- a/services/registration/my_account_alias_swa +++ b/services/registration/my_account_alias_swa @@ -1,2 +1,2 @@ Lakabu ya sasa: {{.get_current_profile_info}} -Badilisha Lakabu yangu: \ No newline at end of file +Weka lakabu unalopendelea:: \ No newline at end of file -- 2.45.2 From 87ebd0029b238500118e760912e53a0f0b3dbaac Mon Sep 17 00:00:00 2001 From: Carlosokumu Date: Sat, 22 Mar 2025 18:38:35 +0300 Subject: [PATCH 3/6] chore: show default value when profile info is not set --- handlers/application/menuhandler.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/handlers/application/menuhandler.go b/handlers/application/menuhandler.go index 9497b3d..56dc661 100644 --- a/handlers/application/menuhandler.go +++ b/handlers/application/menuhandler.go @@ -1170,9 +1170,9 @@ func (h *MenuHandlers) GetProfileInfo(ctx context.Context, sym string, input []b offerings := getEntryOrDefault(store.ReadEntry(ctx, sessionId, storedb.DATA_OFFERINGS)) alias := getEntryOrDefault(store.ReadEntry(ctx, sessionId, storedb.DATA_ACCOUNT_ALIAS)) - if alias != defaultValue { + if alias != defaultValue && alias != "" { alias = strings.Split(alias, ".")[0] - } else if alias == "" { + } else { alias = defaultValue } -- 2.45.2 From ddb8c6e748528fdcb88bfc2828b4d6814875e475 Mon Sep 17 00:00:00 2001 From: Carlosokumu Date: Sat, 22 Mar 2025 18:39:05 +0300 Subject: [PATCH 4/6] add lowercase balance text translation --- services/registration/locale/swa/default.po | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/services/registration/locale/swa/default.po b/services/registration/locale/swa/default.po index 6155063..cac4737 100644 --- a/services/registration/locale/swa/default.po +++ b/services/registration/locale/swa/default.po @@ -30,3 +30,7 @@ msgstr "Salio la Kikundi: 0.00" msgid "Symbol: %s\nBalance: %s" msgstr "Sarafu: %s\nSalio: %s" + + +msgid "%s balance: %s\n" +msgstr "%s salio: %s\n" \ No newline at end of file -- 2.45.2 From 493f64157b174aca7b1bb5b55b68dcccc8255683 Mon Sep 17 00:00:00 2001 From: Carlosokumu Date: Mon, 24 Mar 2025 15:59:13 +0300 Subject: [PATCH 5/6] sanitize alias hint before request --- handlers/application/menuhandler.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/handlers/application/menuhandler.go b/handlers/application/menuhandler.go index 56dc661..8473dcc 100644 --- a/handlers/application/menuhandler.go +++ b/handlers/application/menuhandler.go @@ -8,6 +8,7 @@ import ( "path" "strconv" "strings" + "unicode" "gopkg.in/leonelquinteros/gotext.v1" @@ -2509,7 +2510,8 @@ func (h *MenuHandlers) RequestCustomAlias(ctx context.Context, sym string, input return res, nil } } - aliasResult, err := h.accountService.RequestAlias(ctx, string(pubKey), string(input)) + sanitizedInput := sanitizeAliasHint(string(input)) + aliasResult, err := h.accountService.RequestAlias(ctx, string(pubKey), string(sanitizedInput)) if err != nil { logg.ErrorCtxf(ctx, "failed to retrieve alias", "alias", string(aliasHint), "error_alias_request", err) return res, fmt.Errorf("Failed to retrieve alias: %s", err.Error()) @@ -2526,6 +2528,17 @@ func (h *MenuHandlers) RequestCustomAlias(ctx context.Context, sym string, input return res, nil } +func sanitizeAliasHint(input string) string { + for i, r := range input { + // Check if the character is a special character (non-alphanumeric) + if !unicode.IsLetter(r) && !unicode.IsNumber(r) { + return input[:i] + } + } + // If no special character is found, return the whole input + return input +} + // GetSuggestedAlias loads and displays the suggested alias name from the temporary value func (h *MenuHandlers) GetSuggestedAlias(ctx context.Context, sym string, input []byte) (resource.Result, error) { var res resource.Result -- 2.45.2 From c81b17994adce4e97f1a80dc697783b4be2fb065 Mon Sep 17 00:00:00 2001 From: Carlosokumu Date: Mon, 24 Mar 2025 16:03:30 +0300 Subject: [PATCH 6/6] remove redundant cast on sanitized input --- handlers/application/menuhandler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/handlers/application/menuhandler.go b/handlers/application/menuhandler.go index 9dde6c3..d6d56a2 100644 --- a/handlers/application/menuhandler.go +++ b/handlers/application/menuhandler.go @@ -2533,7 +2533,7 @@ func (h *MenuHandlers) RequestCustomAlias(ctx context.Context, sym string, input } } sanitizedInput := sanitizeAliasHint(string(input)) - aliasResult, err := h.accountService.RequestAlias(ctx, string(pubKey), string(sanitizedInput)) + aliasResult, err := h.accountService.RequestAlias(ctx, string(pubKey), sanitizedInput) if err != nil { logg.ErrorCtxf(ctx, "failed to retrieve alias", "alias", string(aliasHint), "error_alias_request", err) return res, fmt.Errorf("Failed to retrieve alias: %s", err.Error()) -- 2.45.2