mirror of
https://github.com/Sea-Haven-Industries/google-user-sync.git
synced 2026-05-18 20:20:17 +00:00
Guard against phone entries missing value property
This commit is contained in:
parent
eae9655c74
commit
31f1ba15ef
1 changed files with 3 additions and 5 deletions
|
|
@ -146,11 +146,9 @@ function extractUserFields(googleUser) {
|
|||
|
||||
let phone = "";
|
||||
if (googleUser.phones && googleUser.phones.length > 0) {
|
||||
const workPhone = googleUser.phones.find((p) => p.type === "work");
|
||||
const primaryPhone = googleUser.phones.find((p) => p.primary) || googleUser.phones[0];
|
||||
phone = workPhone
|
||||
? workPhone.value
|
||||
: primaryPhone.value || "";
|
||||
const workPhone = googleUser.phones.find((p) => p.type === "work" && p.value);
|
||||
const primaryPhone = googleUser.phones.find((p) => p.primary && p.value) || googleUser.phones.find((p) => p.value);
|
||||
phone = (workPhone || primaryPhone || {}).value || "";
|
||||
}
|
||||
|
||||
return { email, jobTitle, phone };
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue