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
This commit is contained in:
1 parent
477e102388
commit
c08365f09c
14 files changed
+81
-37
No files matched your search
@@ -87,6 +87,7 @@ export async function getTeamWithMembers(args: {
|
||||
name: true,
|
||||
slug: true,
|
||||
...(!!includeTeamLogo ? { logo: true } : {}),
|
||||
logoUrl: true,
|
||||
bio: true,
|
||||
hideBranding: true,
|
||||
hideBookATeamMember: true,
|
||||
@@ -232,6 +233,7 @@ export async function getTeamWithMembers(args: {
|
||||
|
||||
return {
|
||||
...teamWithoutInviteTokens,
|
||||
...(teamWithoutInviteTokens.logoUrl ? { logo: teamWithoutInviteTokens.logoUrl } : {}),
|
||||
/** To prevent breaking we only return non-email attached token here, if we have one */
|
||||
inviteToken: inviteTokens.find(
|
||||
(token) =>
|
||||
|
||||
@@ -99,12 +99,6 @@ export class EventTypeRepository {
|
||||
const profileId = lookupTarget.type === LookupTarget.User ? null : lookupTarget.id;
|
||||
const select = {
|
||||
...eventTypeSelect,
|
||||
// TODO: As required by getByViewHandler - Make it configurable
|
||||
team: {
|
||||
select: {
|
||||
id: true,
|
||||
},
|
||||
},
|
||||
hashedLink: true,
|
||||
users: { select: userSelect },
|
||||
children: {
|
||||
|
||||
@@ -103,11 +103,6 @@ export class MembershipRepository {
|
||||
eventTypes: {
|
||||
select: {
|
||||
...eventTypeSelect,
|
||||
team: {
|
||||
select: {
|
||||
id: true,
|
||||
},
|
||||
},
|
||||
hashedLink: true,
|
||||
users: { select: userSelect },
|
||||
children: {
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
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`;
|
||||
};
|
||||
Reference in new issue
Block a user