* chore: Remove deprecated logo/avatar/away fields * Use right variables for accounts-step-card * Remove more deprecated logo/avatar usage * Dont drop the fields until all usages are gone * Remove the avatar/logo drops for staggered release * fix: Typescript blindspot (unvalidated include fields) * fix: Further updates (mostly to API) typescript missed --------- Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com> Co-authored-by: Bailey Pumfleet <bailey@pumfleet.co.uk> Co-authored-by: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com> Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: Keith Williams <keithwillcode@gmail.com>
64 lines
1.1 KiB
TypeScript
64 lines
1.1 KiB
TypeScript
import { v4 as uuidv4 } from "uuid";
|
|
|
|
import { prisma } from "@calcom/prisma";
|
|
|
|
export const uploadAvatar = async ({ userId, avatar: data }: { userId: number; avatar: string }) => {
|
|
const objectKey = uuidv4();
|
|
|
|
await prisma.avatar.upsert({
|
|
where: {
|
|
teamId_userId_isBanner: {
|
|
teamId: 0,
|
|
userId,
|
|
isBanner: false,
|
|
},
|
|
},
|
|
create: {
|
|
userId: userId,
|
|
data,
|
|
objectKey,
|
|
isBanner: false,
|
|
},
|
|
update: {
|
|
data,
|
|
objectKey,
|
|
},
|
|
});
|
|
|
|
return `/api/avatar/${objectKey}.png`;
|
|
};
|
|
|
|
export const uploadLogo = async ({
|
|
teamId,
|
|
logo: data,
|
|
isBanner = false,
|
|
}: {
|
|
teamId: number;
|
|
logo: string;
|
|
isBanner?: boolean;
|
|
}): Promise<string> => {
|
|
const objectKey = uuidv4();
|
|
|
|
await prisma.avatar.upsert({
|
|
where: {
|
|
teamId_userId_isBanner: {
|
|
teamId,
|
|
userId: 0,
|
|
isBanner,
|
|
},
|
|
},
|
|
create: {
|
|
teamId,
|
|
data,
|
|
objectKey,
|
|
isBanner,
|
|
},
|
|
update: {
|
|
data,
|
|
objectKey,
|
|
},
|
|
});
|
|
|
|
return `/api/avatar/${objectKey}.png`;
|
|
};
|