* 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
34 lines
517 B
TypeScript
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`;
|
|
};
|