From b919bfbfc85ac4b409eb1a9847e2000fe9164578 Mon Sep 17 00:00:00 2001 From: alfred-mk Date: Mon, 25 Nov 2024 11:59:51 +0300 Subject: [PATCH] use the formatted number when checking if it is registered --- internal/handlers/ussd/menuhandler.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/internal/handlers/ussd/menuhandler.go b/internal/handlers/ussd/menuhandler.go index f4edb5d..8d3b928 100644 --- a/internal/handlers/ussd/menuhandler.go +++ b/internal/handlers/ussd/menuhandler.go @@ -927,8 +927,15 @@ func (h *Handlers) ValidateRecipient(ctx context.Context, sym string, input []by switch recipientType { case "phone number": + // format the phone number + formattedNumber, err := common.FormatPhoneNumber(recipient) + if err != nil { + logg.ErrorCtxf(ctx, "Failed to format the phone number: %s", recipient, "error", err) + return res, err + } + // Check if the phone number is registered - publicKey, err := store.ReadEntry(ctx, recipient, common.DATA_PUBLIC_KEY) + publicKey, err := store.ReadEntry(ctx, formattedNumber, common.DATA_PUBLIC_KEY) if err != nil { if db.IsNotFound(err) { logg.InfoCtxf(ctx, "Unregistered phone number: %s", recipient)