feat: prevent posts for disabled accounts
This commit is contained in:
parent
5114ea88f7
commit
44a0a77615
|
|
@ -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')
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ export class OrganizationRepository {
|
|||
userId,
|
||||
},
|
||||
select: {
|
||||
disabled: true,
|
||||
role: true,
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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]);
|
||||
|
|
|
|||
Loading…
Reference in New Issue