chore: Cleanup full raw avatar responses from tRPC endpoints (#8901)

* [CAL-1383] Cleanup full raw avatar responses from tRPC endpoints

* Cleanup additional handlers where base64 images were sent through the response

* Add 'image' correctly to the profiles array

---------

Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com>
Co-authored-by: alannnc <alannnc@gmail.com>
Co-authored-by: Peer Richelsen <peeroke@gmail.com>
Co-authored-by: Keith Williams <keithwillcode@gmail.com>
Co-authored-by: Alex van Andel <me@alexvanandel.com>
gh-readonly-queue/main/pr-8955-7c46d1b34847501759158be6ad8da80c441eeb34
Anwar Sadath 2023-05-30 22:00:19 +05:30 committed by GitHub
parent a6330c0fc8
commit 7c46d1b348
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 5 deletions

View File

@ -172,13 +172,16 @@ export const getByViewerHandler = async ({ ctx }: GetByViewerOptions) => {
const mergedEventTypes = Object.values(eventTypesHashMap) const mergedEventTypes = Object.values(eventTypesHashMap)
.map((eventType) => eventType) .map((eventType) => eventType)
.filter((evType) => evType.schedulingType !== SchedulingType.MANAGED); .filter((evType) => evType.schedulingType !== SchedulingType.MANAGED);
const image = user?.username ? `${CAL_URL}/${user.username}/avatar.png` : undefined;
eventTypeGroups.push({ eventTypeGroups.push({
teamId: null, teamId: null,
membershipRole: null, membershipRole: null,
profile: { profile: {
slug: user.username, slug: user.username,
name: user.name, name: user.name,
image: user.avatar || undefined, image,
}, },
eventTypes: orderBy(mergedEventTypes, ["position", "id"], ["desc", "asc"]), eventTypes: orderBy(mergedEventTypes, ["position", "id"], ["desc", "asc"]),
metadata: { metadata: {
@ -214,10 +217,11 @@ export const getByViewerHandler = async ({ ctx }: GetByViewerOptions) => {
eventTypeGroups: eventTypeGroups.filter((groupBy) => !!groupBy.eventTypes?.length), eventTypeGroups: eventTypeGroups.filter((groupBy) => !!groupBy.eventTypes?.length),
// so we can show a dropdown when the user has teams // so we can show a dropdown when the user has teams
profiles: eventTypeGroups.map((group) => ({ profiles: eventTypeGroups.map((group) => ({
teamId: group.teamId,
membershipRole: group.membershipRole,
...group.profile, ...group.profile,
...group.metadata, ...group.metadata,
teamId: group.teamId,
membershipRole: group.membershipRole,
image: `${CAL_URL}/${group.profile.slug}/avatar.png`,
})), })),
}; };
}; };

View File

@ -77,12 +77,13 @@ export const getByViewerHandler = async ({ ctx }: GetByViewerOptions) => {
const userWebhooks = user.webhooks; const userWebhooks = user.webhooks;
let webhookGroups: WebhookGroup[] = []; let webhookGroups: WebhookGroup[] = [];
const image = user?.username ? `${CAL_URL}/${user.username}/avatar.png` : undefined;
webhookGroups.push({ webhookGroups.push({
teamId: null, teamId: null,
profile: { profile: {
slug: user.username, slug: user.username,
name: user.name, name: user.name,
image: user.avatar || undefined, image,
}, },
webhooks: userWebhooks, webhooks: userWebhooks,
metadata: { metadata: {

View File

@ -80,12 +80,13 @@ export const getByViewerHandler = async ({ ctx }: GetByViewerOptions) => {
let workflowGroups: WorkflowGroup[] = []; let workflowGroups: WorkflowGroup[] = [];
const image = user?.username ? `${CAL_URL}/${user.username}/avatar.png` : undefined;
workflowGroups.push({ workflowGroups.push({
teamId: null, teamId: null,
profile: { profile: {
slug: user.username, slug: user.username,
name: user.name, name: user.name,
image: user.avatar || undefined, image,
}, },
workflows: userWorkflows, workflows: userWorkflows,
metadata: { metadata: {