Compare commits

..

No commits in common. "b919bfbfc85ac4b409eb1a9847e2000fe9164578" and "267132b9567d09bad8e20a5f968a594104995670" have entirely different histories.

3 changed files with 2 additions and 31 deletions

View File

@ -20,7 +20,6 @@ import (
"git.defalsify.org/vise.git/logging"
"git.defalsify.org/vise.git/resource"
"git.grassecon.net/urdt/ussd/common"
"git.grassecon.net/urdt/ussd/config"
"git.grassecon.net/urdt/ussd/initializers"
"git.grassecon.net/urdt/ussd/internal/handlers"
@ -77,13 +76,7 @@ func (arp *atRequestParser) GetSessionId(rq any) (string, error) {
return "", fmt.Errorf("no phone number found")
}
formattedNumber, err := common.FormatPhoneNumber(phoneNumber)
if err != nil {
fmt.Printf("Error: %v\n", err)
return "", fmt.Errorf("failed to format number")
}
return formattedNumber, nil
return phoneNumber, nil
}
func (arp *atRequestParser) GetInput(rq any) ([]byte, error) {

View File

@ -3,7 +3,6 @@ package common
import (
"fmt"
"regexp"
"strings"
)
// Define the regex patterns as constants
@ -47,17 +46,3 @@ func CheckRecipient(recipient string) (string, error) {
return "", fmt.Errorf("invalid recipient: must be a phone number, address or alias")
}
// FormatPhoneNumber formats a Kenyan phone number to "254xxxxxxxx".
func FormatPhoneNumber(phone string) (string, error) {
// Remove any leading "+" and spaces
phone = strings.TrimPrefix(phone, "+")
phone = strings.ReplaceAll(phone, " ", "")
// Replace leading "0" with "254" if present
if strings.HasPrefix(phone, "0") {
phone = "254" + phone[1:]
}
return phone, nil
}

View File

@ -927,15 +927,8 @@ 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, formattedNumber, common.DATA_PUBLIC_KEY)
publicKey, err := store.ReadEntry(ctx, recipient, common.DATA_PUBLIC_KEY)
if err != nil {
if db.IsNotFound(err) {
logg.InfoCtxf(ctx, "Unregistered phone number: %s", recipient)