Skip to content

Commit ae2049c

Browse files
fix: update GetUserByPhone
1 parent fcc0885 commit ae2049c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.User.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,14 @@ public partial class MongoRepository
2222
return null;
2323
}
2424

25-
phoneSecond = phone.StartsWith("+86") ? phone.Replace("+86", "") : $"+86{phone}";
25+
if (regionCode == "CN")
26+
{
27+
phoneSecond = (phone ?? "").StartsWith("+86") ? (phone ?? "").Replace("+86", "") : ($"+86{phone ?? ""}");
28+
}
29+
else
30+
{
31+
phoneSecond = (phone ?? "").Substring(regionCode == "US" ? 2 : 3);
32+
}
2633

2734
var user = _dc.Users.AsQueryable().FirstOrDefault(x => (x.Phone == phone || x.Phone == phoneSecond)
2835
&& (x.RegionCode == regionCode || string.IsNullOrWhiteSpace(x.RegionCode))

0 commit comments

Comments
 (0)