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",
"version": "3.5.1",
"version": "3.5.2",
"private": true,
"scripts": {
"analyze": "ANALYZE=true next build",

View File

@ -61,6 +61,8 @@ export const updateProfileHandler = async ({ ctx, input }: UpdateProfileOptions)
const userMetadata = handleUserMetadata({ ctx, input });
const data: Prisma.UserUpdateInput = {
...input,
// DO NOT OVERWRITE AVATAR.
avatar: undefined,
metadata: userMetadata,
};
@ -138,14 +140,21 @@ export const updateProfileHandler = async ({ ctx, input }: UpdateProfileOptions)
// when the email changes, the user needs to sign in again.
signOutUser = true;
}
// don't do anything if avatar is undefined.
if (typeof input.avatar !== "undefined") {
data.avatarUrl = input.avatar
? await uploadAvatar({
avatar: await resizeBase64Image(input.avatar),
userId: user.id,
})
: null;
// if defined AND a base 64 string, upload and set the avatar URL
if (input.avatar && input.avatar.startsWith("data:image/png;base64,")) {
const avatar = await resizeBase64Image(input.avatar);
data.avatarUrl = await uploadAvatar({
avatar,
userId: user.id,
});
// 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({