feat: Base implementation of v2 of avatars (#12369)
* feat: Base implementation of v2 of avatars * Make avatarUrl and logoUrl entirely optional * Made necessary backwards compat changes * fix: type errors * Fix: OG image * fix types * Consistency with other behaviour, ux tweak --------- Co-authored-by: Peer Richelsen <[email protected]>
This commit is contained in:
1 parent
c55b36f235
commit
4f26ca1a7b
18 files changed
+258
-69
No files matched your search
@@ -6,19 +6,28 @@ import type { User, Team } from "@calcom/prisma/client";
|
||||
* Gives an organization aware avatar url for a user
|
||||
* It ensures that the wrong avatar isn't fetched by ensuring that organizationId is always passed
|
||||
*/
|
||||
export const getUserAvatarUrl = (user: Pick<User, "username" | "organizationId">) => {
|
||||
if (!user.username) return AVATAR_FALLBACK;
|
||||
export const getUserAvatarUrl = (
|
||||
user: (Pick<User, "username" | "organizationId"> & { avatarUrl?: string | null }) | undefined
|
||||
) => {
|
||||
if (user?.avatarUrl) {
|
||||
return user.avatarUrl;
|
||||
}
|
||||
if (!user?.username) return AVATAR_FALLBACK;
|
||||
// avatar.png automatically redirects to fallback avatar if user doesn't have one
|
||||
return `${WEBAPP_URL}/${user.username}/avatar.png${
|
||||
user.organizationId ? `?orgId=${user.organizationId}` : ""
|
||||
}`;
|
||||
};
|
||||
|
||||
export const getOrgAvatarUrl = (org: {
|
||||
id: Team["id"];
|
||||
slug: Team["slug"];
|
||||
requestedSlug: string | null;
|
||||
}) => {
|
||||
export const getOrgAvatarUrl = (
|
||||
org: Pick<Team, "id" | "slug"> & {
|
||||
logoUrl?: string | null;
|
||||
requestedSlug: string | null;
|
||||
}
|
||||
) => {
|
||||
if (org.logoUrl) {
|
||||
return org.logoUrl;
|
||||
}
|
||||
const slug = org.slug ?? org.requestedSlug;
|
||||
return `${WEBAPP_URL}/org/${slug}/avatar.png`;
|
||||
};
|
||||
@@ -191,6 +191,7 @@ export const buildUser = <T extends Partial<UserPayload>>(user?: T): UserPayload
|
||||
allowDynamicBooking: true,
|
||||
availability: [],
|
||||
avatar: "",
|
||||
avatarUrl: "",
|
||||
away: false,
|
||||
backupCodes: null,
|
||||
bio: null,
|
||||
|
||||
Reference in new issue
Block a user