Files
calendar/packages/lib/server/uploadLogo.ts
T
Alex van AndelandGitHub c08365f09c feat: Implement orgs/teams logoUrls (#13699)
* feat: Implement orgs/teams logoUrls

* Use getAvatarUrl in team/[slug]

* Extract uploadLogo to standalone file for reuse

* Allow removing the team/organisation logo

* fix: API build fail due to server-only, removed
2024-02-16 10:35:53 -03:00

34 lines
517 B
TypeScript

import { v4 as uuidv4 } from "uuid";
import { prisma } from "@calcom/prisma";
export const uploadLogo = async ({
teamId,
logo: data,
}: {
teamId: number;
logo: string;
}): Promise<string> => {
const objectKey = uuidv4();
await prisma.avatar.upsert({
where: {
teamId_userId: {
teamId,
userId: 0,
},
},
create: {
teamId,
data,
objectKey,
},
update: {
data,
objectKey,
},
});
return `/api/avatar/${objectKey}.png`;
};