Fixes SMS actions and cal.com branding for premium plan (#7306)
* enable sms actions with premium user name * allow hide branding when user has premium user name --------- Co-authored-by: CarinaWolli <wollencarina@gmail.com>
This commit is contained in:
co-authored by
CarinaWolli
parent
3206e4ea12
commit
ba86e7f540
@@ -1,3 +1,3 @@
|
||||
export function isBrandingHidden(hideBrandingSetting: boolean, belongsToActiveTeam: boolean) {
|
||||
return belongsToActiveTeam && hideBrandingSetting;
|
||||
export function isBrandingHidden(hideBrandingSetting: boolean, hasPaidPlan: boolean) {
|
||||
return hasPaidPlan && hideBrandingSetting;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import { z } from "zod";
|
||||
|
||||
import type { LocationObject } from "@calcom/app-store/locations";
|
||||
import { IS_TEAM_BILLING_ENABLED, WEBAPP_URL } from "@calcom/lib/constants";
|
||||
import hasKeyInMetadata from "@calcom/lib/hasKeyInMetadata";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import type { User } from "@calcom/prisma/client";
|
||||
|
||||
@@ -82,6 +83,7 @@ async function getUserPageProps(context: GetStaticPropsContext) {
|
||||
weekStart: true,
|
||||
brandColor: true,
|
||||
darkBrandColor: true,
|
||||
metadata: true,
|
||||
eventTypes: {
|
||||
where: {
|
||||
// Many-to-many relationship causes inclusion of the team events - cool -
|
||||
@@ -157,7 +159,7 @@ async function getUserPageProps(context: GetStaticPropsContext) {
|
||||
locations: privacyFilteredLocations(locations),
|
||||
descriptionAsSafeHTML: eventType.description ? md.render(eventType.description) : null,
|
||||
});
|
||||
// Check if the user you are logging into has any active teams
|
||||
// Check if the user you are logging into has any active teams or premium user name
|
||||
const hasActiveTeam =
|
||||
user.teams.filter((m) => {
|
||||
if (!IS_TEAM_BILLING_ENABLED) return true;
|
||||
@@ -166,6 +168,8 @@ async function getUserPageProps(context: GetStaticPropsContext) {
|
||||
return false;
|
||||
}).length > 0;
|
||||
|
||||
const hasPremiumUserName = hasKeyInMetadata(user, "isPremium");
|
||||
|
||||
return {
|
||||
props: {
|
||||
eventType: eventTypeObject,
|
||||
@@ -182,7 +186,7 @@ async function getUserPageProps(context: GetStaticPropsContext) {
|
||||
away: user?.away,
|
||||
isDynamic: false,
|
||||
trpcState: ssg.dehydrate(),
|
||||
isBrandingHidden: isBrandingHidden(user.hideBranding, hasActiveTeam),
|
||||
isBrandingHidden: isBrandingHidden(user.hideBranding, hasActiveTeam || hasPremiumUserName),
|
||||
},
|
||||
revalidate: 10, // seconds
|
||||
};
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import type { PrismaPromise } from "@prisma/client";
|
||||
import {
|
||||
PrismaPromise,
|
||||
WorkflowTemplates,
|
||||
WorkflowActions,
|
||||
WorkflowTriggerEvents,
|
||||
BookingStatus,
|
||||
WorkflowMethods,
|
||||
TimeUnit,
|
||||
Prisma
|
||||
} from "@prisma/client";
|
||||
import { z } from "zod";
|
||||
|
||||
@@ -33,6 +32,7 @@ import {
|
||||
} from "@calcom/features/ee/workflows/lib/reminders/verifyPhoneNumber";
|
||||
import { IS_SELF_HOSTED, SENDER_ID } from "@calcom/lib/constants";
|
||||
import { SENDER_NAME } from "@calcom/lib/constants";
|
||||
import hasKeyInMetadata from "@calcom/lib/hasKeyInMetadata";
|
||||
// import { getErrorFromUnknown } from "@calcom/lib/errors";
|
||||
import { getTranslation } from "@calcom/lib/server/i18n";
|
||||
import type { WorkflowStep } from "@calcom/prisma/client";
|
||||
@@ -947,7 +947,7 @@ evt = {
|
||||
attendees: [{ name: "John Doe", email: "john.doe@example.com", timeZone: "Europe/London" }],
|
||||
organizer: {
|
||||
language: {
|
||||
locale: ctx.user.locale,
|
||||
locale: ctx.user.locale,
|
||||
},
|
||||
name: ctx.user.name || "",
|
||||
email: ctx.user.email,
|
||||
@@ -1102,8 +1102,16 @@ action === WorkflowActions.EMAIL_ADDRESS*/
|
||||
return verifiedNumbers;
|
||||
}),
|
||||
getWorkflowActionOptions: authedProcedure.query(async ({ ctx }) => {
|
||||
const { hasTeamPlan } = await viewerTeamsRouter.createCaller(ctx).hasTeamPlan();
|
||||
const { user } = ctx;
|
||||
|
||||
const isCurrentUsernamePremium = user && user.metadata && hasKeyInMetadata(user, "isPremium");
|
||||
|
||||
let isTeamsPlan = false;
|
||||
if (!isCurrentUsernamePremium) {
|
||||
const { hasTeamPlan } = await viewerTeamsRouter.createCaller(ctx).hasTeamPlan();
|
||||
isTeamsPlan = !!hasTeamPlan;
|
||||
}
|
||||
const t = await getTranslation(ctx.user.locale, "common");
|
||||
return getWorkflowActionOptions(t, IS_SELF_HOSTED || !!hasTeamPlan);
|
||||
return getWorkflowActionOptions(t, IS_SELF_HOSTED || isCurrentUsernamePremium || isTeamsPlan);
|
||||
}),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user