generated from iansan5653/gas-ts-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use display format for team members when viewing calendars
- Loading branch information
1 parent
1799391
commit 68401e2
Showing
3 changed files
with
27 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { NameFormat } from "../models/TeamCalendar"; | ||
|
||
export function getTeamMemberDisplayName(email: string, format: NameFormat) { | ||
switch (format) { | ||
case "email": | ||
return email; | ||
case "username": | ||
return email.split("@")[0]; | ||
case "name": | ||
// fall back to querying the directory to get full name from contacts (only works in Workspace accounts) | ||
return ( | ||
// not-yet-typed, see https://developers.google.com/people/api/rest/v1/people/searchDirectoryPeople | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
(People.People! as any).searchDirectoryPeople({ | ||
query: email, | ||
readMask: "names", | ||
sources: ["DIRECTORY_SOURCE_TYPE_DOMAIN_PROFILE", "DIRECTORY_SOURCE_TYPE_DOMAIN_CONTACT"], | ||
pageSize: 1, | ||
}).people?.[0]?.names?.[0]?.displayName ?? email | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters