feat: cant enable channels on self-hosted mode

This commit is contained in:
Nevo David 2025-02-06 12:22:18 +07:00
parent cffd7e663f
commit 807f7078f3
3 changed files with 39 additions and 2 deletions

View File

@ -60,7 +60,7 @@ export class UsersController {
...user,
orgId: organization.id,
// @ts-ignore
totalChannels: organization?.subscription?.totalChannels || pricing.FREE.channel,
totalChannels: !process.env.STRIPE_PUBLISHABLE_KEY ? 10000 : organization?.subscription?.totalChannels || pricing.FREE.channel,
// @ts-ignore
tier: organization?.subscription?.subscriptionTier ||
(!process.env.STRIPE_PUBLISHABLE_KEY ? 'ULTIMATE' : 'FREE'),

View File

@ -16,6 +16,9 @@ import { useRouter } from 'next/navigation';
import { useVariables } from '@gitroom/react/helpers/variable.context';
import { useToaster } from '@gitroom/react/toaster/toaster';
import { Integration } from '@prisma/client';
import { web3List } from '@gitroom/frontend/components/launches/web3/web3.list';
import { timer } from '@gitroom/helpers/utils/timer';
import { deleteDialog } from '@gitroom/react/helpers/delete.dialog';
export const ConnectChannels: FC = () => {
const fetch = useFetch();
@ -43,6 +46,33 @@ export const ConnectChannels: FC = () => {
// []
// );
const openWeb3 = async (id: string) => {
const { component: Web3Providers } = web3List.find(
(item) => item.identifier === id
)!;
const { url } = await (await fetch(`/integrations/social/${id}`)).json();
setShowCustom(
<Web3Providers
onComplete={async (code, newState) => {
if (await deleteDialog('Connection found, should we continue?', 'Continue')) {
window.open(
`/integrations/social/${id}?code=${code}&state=${newState}`,
'Social Connect',
'width=700,height=700'
);
return ;
}
setShowCustom(undefined);
}}
nonce={url}
/>
);
return;
};
const refreshChannel = useCallback(
(integration: Integration & { identifier: string }) => async () => {
const { url } = await (
@ -82,6 +112,7 @@ export const ConnectChannels: FC = () => {
(
identifier: string,
isExternal: boolean,
isWeb3: boolean,
customFields?: Array<{
key: string;
label: string;
@ -124,6 +155,11 @@ export const ConnectChannels: FC = () => {
// return;
// }
if (isWeb3) {
openWeb3(identifier);
return;
}
if (customFields) {
setShowCustom(
<CustomVariables
@ -252,6 +288,7 @@ export const ConnectChannels: FC = () => {
onClick={getSocialLink(
social.identifier,
social.isExternal,
social.isWeb3,
social.customFields
)}
className="h-[96px] bg-input flex flex-col justify-center items-center gap-[10px] cursor-pointer"

View File

@ -210,7 +210,7 @@ export class IntegrationService {
const integrations = (
await this._integrationRepository.getIntegrationsList(org)
).filter((f) => !f.disabled);
if (integrations.length >= totalChannels) {
if (!!process.env.STRIPE_PUBLISHABLE_KEY && integrations.length >= totalChannels) {
throw new Error('You have reached the maximum number of channels');
}