Skip to content

πŸ“¨ The ultimate agentic social media scheduling tool πŸ€–

feat: prevent posts for disabled accounts

Nevo David44a0a77615b4
diff --git a/apps/backend/src/api/routes/users.controller.ts b/apps/backend/src/api/routes/users.controller.ts
index 04493e6b3..37f04a6a6 100644
--- a/apps/backend/src/api/routes/users.controller.ts
+++ b/apps/backend/src/api/routes/users.controller.ts
@@ -95,7 +95,7 @@ export class UsersController {
@Get('/organizations')
async getOrgs(@GetUserFromRequest() user: User) {
- return this._orgService.getOrgsByUserId(user.id);
+ return (await this._orgService.getOrgsByUserId(user.id)).filter(f => !f.users[0].disabled);
}
@Post('/change-org')
diff --git a/apps/backend/src/services/auth/auth.middleware.ts b/apps/backend/src/services/auth/auth.middleware.ts
index 726eb24af..d97f93965 100644
--- a/apps/backend/src/services/auth/auth.middleware.ts
+++ b/apps/backend/src/services/auth/auth.middleware.ts
@@ -24,7 +24,7 @@ export class AuthMiddleware implements NestMiddleware {
}
delete user.password;
- const organization = await this._organizationService.getOrgsByUserId(user.id);
+ const organization = (await this._organizationService.getOrgsByUserId(user.id)).filter(f => !f.users[0].disabled);
const setOrg = organization.find((org) => org.id === orgHeader) || organization[0];
diff --git a/apps/frontend/src/components/billing/no.billing.component.tsx b/apps/frontend/src/components/billing/no.billing.component.tsx
index d31d0451f..02cf4974e 100644
--- a/apps/frontend/src/components/billing/no.billing.component.tsx
+++ b/apps/frontend/src/components/billing/no.billing.component.tsx
@@ -222,11 +222,29 @@ export const NoBillingComponent: FC<{
const moveToCheckout = useCallback(
(billing: 'STANDARD' | 'PRO' | 'FREE') => async () => {
+ const messages = [];
+ const beforeTotalChannels = pricing[billing].channel || initialChannels;
+
+ if (totalChannels < beforeTotalChannels) {
+ messages.push(
+ `Some of the channels will be disabled`
+ );
+ }
+
+ if (
+ !pricing[billing].team_members &&
+ pricing[subscription?.subscriptionTier!]?.team_members
+ ) {
+ messages.push(
+ `Your team members will be removed from your organization`
+ );
+ }
+
if (billing === 'FREE') {
if (
subscription?.cancelAt ||
(await deleteDialog(
- 'Are you sure you want to cancel your subscription?',
+ `Are you sure you want to cancel your subscription? ${messages.join(', ')}`,
'Yes, cancel',
'Cancel Subscription'
))
@@ -247,6 +265,11 @@ export const NoBillingComponent: FC<{
}
return;
}
+
+ if (messages.length && !await deleteDialog(messages.join(', '), 'Yes, continue')) {
+ return ;
+ }
+
setLoading(true);
const { url, portal } = await (
await fetch('/billing/subscribe', {
@@ -299,7 +322,7 @@ export const NoBillingComponent: FC<{
setLoading(false);
},
- [monthlyOrYearly, totalChannels]
+ [monthlyOrYearly, totalChannels, subscription, user]
);
return (
diff --git a/libraries/nestjs-libraries/src/database/prisma/organizations/organization.repository.ts b/libraries/nestjs-libraries/src/database/prisma/organizations/organization.repository.ts
index f3628e496..fd07844ae 100644
--- a/libraries/nestjs-libraries/src/database/prisma/organizations/organization.repository.ts
+++ b/libraries/nestjs-libraries/src/database/prisma/organizations/organization.repository.ts
@@ -27,6 +27,7 @@ export class OrganizationRepository {
userId,
},
select: {
+ disabled: true,
role: true,
},
},
diff --git a/libraries/nestjs-libraries/src/database/prisma/posts/posts.service.ts b/libraries/nestjs-libraries/src/database/prisma/posts/posts.service.ts
index d035353a0..8cf073622 100644
--- a/libraries/nestjs-libraries/src/database/prisma/posts/posts.service.ts
+++ b/libraries/nestjs-libraries/src/database/prisma/posts/posts.service.ts
@@ -67,6 +67,16 @@ export class PostsService {
return;
}
+ if (firstPost.integration?.disabled) {
+ await this._notificationService.inAppNotification(
+ firstPost.organizationId,
+ `We couldn't post to ${firstPost.integration?.providerIdentifier} for ${firstPost?.integration?.name}`,
+ `We couldn't post to ${firstPost.integration?.providerIdentifier} for ${firstPost?.integration?.name} because it's disabled. Please enable it and try again.`,
+ true
+ );
+ return;
+ }
+
try {
if (firstPost.integration?.type === 'article') {
await this.postArticle(firstPost.integration!, [
@@ -74,7 +84,7 @@ export class PostsService {
...morePosts,
]);
- return ;
+ return;
}
await this.postSocial(firstPost.integration!, [firstPost, ...morePosts]);