Merge branch 'main' into testE2E-timezone

This commit is contained in:
GitStart-Cal.com 2023-11-24 00:22:49 +05:45 committed by GitHub
commit de2d40b129
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 9 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@calcom/web", "name": "@calcom/web",
"version": "3.5.1", "version": "3.5.2",
"private": true, "private": true,
"scripts": { "scripts": {
"analyze": "ANALYZE=true next build", "analyze": "ANALYZE=true next build",

View File

@ -61,6 +61,8 @@ export const updateProfileHandler = async ({ ctx, input }: UpdateProfileOptions)
const userMetadata = handleUserMetadata({ ctx, input }); const userMetadata = handleUserMetadata({ ctx, input });
const data: Prisma.UserUpdateInput = { const data: Prisma.UserUpdateInput = {
...input, ...input,
// DO NOT OVERWRITE AVATAR.
avatar: undefined,
metadata: userMetadata, metadata: userMetadata,
}; };
@ -138,14 +140,21 @@ export const updateProfileHandler = async ({ ctx, input }: UpdateProfileOptions)
// when the email changes, the user needs to sign in again. // when the email changes, the user needs to sign in again.
signOutUser = true; signOutUser = true;
} }
// don't do anything if avatar is undefined. // if defined AND a base 64 string, upload and set the avatar URL
if (typeof input.avatar !== "undefined") { if (input.avatar && input.avatar.startsWith("data:image/png;base64,")) {
data.avatarUrl = input.avatar const avatar = await resizeBase64Image(input.avatar);
? await uploadAvatar({ data.avatarUrl = await uploadAvatar({
avatar: await resizeBase64Image(input.avatar), avatar,
userId: user.id, userId: user.id,
}) });
: null; // as this is still used in the backwards compatible endpoint, we also write it here
// to ensure no data loss.
data.avatar = avatar;
}
// Unset avatar url if avatar is empty string.
if ("" === input.avatar) {
data.avatarUrl = null;
data.avatar = null;
} }
const updatedUser = await prisma.user.update({ const updatedUser = await prisma.user.update({