fix: More instances of wrong avatar URL fixed (#10519)

* Fix user.avatar

* Fix avtars in admin users listing

* Handle unpublished org
This commit is contained in:
Hariom Balhara authored and GitHub committed 2023-08-03 15:32:38 +00:00
1 parent 5491821baf
commit bf45dcf139
5 files changed
+27 -15

No files matched your search

@@ -1,5 +1,7 @@
import { ALLOWED_HOSTNAMES, RESERVED_SUBDOMAINS, WEBAPP_URL } from "@calcom/lib/constants";
import type { Prisma } from ".prisma/client";
/**
* return the org slug
* @param hostname
@@ -60,5 +62,5 @@ export function getSlugOrRequestedSlug(slug: string) {
},
},
],
};
} satisfies Prisma.TeamWhereInput;
}
@@ -135,7 +135,7 @@ function UsersTableBare() {
size="md"
alt={`Avatar of ${user.username || "Nameless"}`}
gravatarFallbackMd5=""
imageSrc={`${WEBAPP_URL}/${user.username}/avatar.png`}
imageSrc={`${WEBAPP_URL}/${user.username}/avatar.png?orgId=${user.organizationId}`}
/>
<div className="text-subtle ml-4 font-medium">
@@ -104,7 +104,9 @@ export async function getUserFromSession(ctx: TRPCContextInner, session: Maybe<S
const orgMetadata = teamMetadataSchema.parse(user.organization?.metadata || {});
const rawAvatar = user.avatar;
// This helps to prevent reaching the 4MB payload limit by avoiding base64 and instead passing the avatar url
user.avatar = rawAvatar ? `${WEBAPP_URL}/${user.username}/avatar.png` : defaultAvatarSrc({ email });
user.avatar = rawAvatar
? `${WEBAPP_URL}/${user.username}/avatar.png?orgId=${user.organizationId}`
: defaultAvatarSrc({ email });
const locale = user?.locale || ctx.locale;
const isOrgAdmin = !!user.organization?.members.length;
@@ -49,6 +49,7 @@ export const listPaginatedHandler = async ({ ctx, input }: GetOptions) => {
name: true,
timeZone: true,
role: true,
organizationId: true,
},
});