From 70c767c10ccedc01ed8d4d0f39cb9d9eb3a971da Mon Sep 17 00:00:00 2001 From: rainzm Date: Thu, 28 Jan 2021 19:31:53 +0800 Subject: [PATCH] feat(notify): add default area code for mobile --- pkg/apis/notify/receiver.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/apis/notify/receiver.go b/pkg/apis/notify/receiver.go index 0d58a8af47..38c48baa59 100644 --- a/pkg/apis/notify/receiver.go +++ b/pkg/apis/notify/receiver.go @@ -54,13 +54,17 @@ type SInternationalMobile struct { AreaCode string `json:"area_code"` } -var pareser = regexp.MustCompile(`\+(\d*) (.*)`) +var ( + defaultAreaCode = "86" + pareser = regexp.MustCompile(`\+(\d*) (.*)`) +) func ParseInternationalMobile(mobile string) SInternationalMobile { matchs := pareser.FindStringSubmatch(mobile) if len(matchs) == 0 { return SInternationalMobile{ - Mobile: mobile, + AreaCode: defaultAreaCode, + Mobile: mobile, } } return SInternationalMobile{