Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

add: support for multiple plans

Blue Mouse9347249f0e53
diff --git a/src/user/user.controller.ts b/src/user/user.controller.ts
index 42fbf41ac..2dd85a842 100644
--- a/src/user/user.controller.ts
+++ b/src/user/user.controller.ts
@@ -24,6 +24,7 @@ import * as _map from 'lodash/map'
import * as _join from 'lodash/join'
import * as _isNull from 'lodash/isNull'
import * as _isEmpty from 'lodash/isEmpty'
+import * as _includes from 'lodash/includes'
import * as _isString from 'lodash/isString'
import * as _omit from 'lodash/omit'
import { v4 as uuidv4 } from 'uuid'
@@ -68,6 +69,8 @@ dayjs.extend(utc)
export type TelegrafContext = Scenes.SceneContext
+const UNPAID_PLANS = [PlanCode.free, PlanCode.trial, PlanCode.none]
+
@ApiTags('User')
@Controller('user')
@UseGuards(JwtAccessTokenGuard, RolesGuard)
@@ -235,7 +238,7 @@ export class UserController {
throw new BadRequestException(`User with id ${id} does not exist`)
}
- if (user.planCode !== PlanCode.free && user.planCode !== PlanCode.trial) {
+ if (!_includes(UNPAID_PLANS, user.planCode)) {
throw new BadRequestException('cancelSubFirst')
}
@@ -273,7 +276,7 @@ export class UserController {
select: ['id', 'planCode'],
})
- if (user.planCode !== PlanCode.free && user.planCode !== PlanCode.trial) {
+ if (!_includes(UNPAID_PLANS, user.planCode)) {
throw new BadRequestException('cancelSubFirst')
}