feat: support e164 phone number in GetUserByPhone() (#4099)

This commit is contained in:
DacongDA
2025-08-19 02:19:15 +08:00
committed by GitHub
parent 83df077a02
commit eda742a848
3 changed files with 20 additions and 1 deletions

View File

@@ -30,6 +30,7 @@ import (
"unicode"
"github.com/google/uuid"
"github.com/nyaruka/phonenumbers"
)
func ParseInt(s string) int {
@@ -278,6 +279,19 @@ func GetMaskedPhone(phone string) string {
return rePhone.ReplaceAllString(phone, "$1****$2")
}
func GetSeperatedPhone(phone string) string {
if strings.HasPrefix(phone, "+") {
phoneNumberParsed, err := phonenumbers.Parse(phone, "")
if err != nil {
return phone
}
phone = fmt.Sprintf("%d", phoneNumberParsed.GetNationalNumber())
}
return phone
}
func GetMaskedEmail(email string) string {
if email == "" {
return ""