core: get rid of subscription.type (all subs now use .plan)

This commit is contained in:
Abdullah Atta
2025-09-10 11:59:19 +05:00
parent cfe0cded15
commit d88b30b538
3 changed files with 7 additions and 20 deletions

View File

@@ -20,7 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { import {
planToId, planToId,
SubscriptionPlan, SubscriptionPlan,
SubscriptionType, SubscriptionStatus,
User User
} from "../types.js"; } from "../types.js";
import hosts from "../utils/constants.js"; import hosts from "../utils/constants.js";
@@ -241,12 +241,8 @@ export default class Subscriptions {
} }
function isLegacySubscription(user: User) { function isLegacySubscription(user: User) {
const type = user.subscription.type;
return ( return (
type !== undefined && user.subscription.plan === SubscriptionPlan.LEGACY_PRO &&
(type === SubscriptionType.BETA || user.subscription.status !== SubscriptionStatus.EXPIRED
type === SubscriptionType.PREMIUM ||
type === SubscriptionType.PREMIUM_CANCELED ||
type === SubscriptionType.TRIAL)
); );
} }

View File

@@ -356,7 +356,8 @@ class UserManager {
const oldUser = await this.getUser(); const oldUser = await this.getUser();
if ( if (
oldUser && oldUser &&
(oldUser.subscription.type !== user.subscription.type || (oldUser.subscription.plan !== user.subscription.plan ||
oldUser.subscription.status !== user.subscription.status ||
oldUser.subscription.provider !== user.subscription.provider) oldUser.subscription.provider !== user.subscription.provider)
) { ) {
await this.tokenManager._refreshToken(true); await this.tokenManager._refreshToken(true);

View File

@@ -562,7 +562,8 @@ export enum SubscriptionPlan {
ESSENTIAL = 1, ESSENTIAL = 1,
PRO = 2, PRO = 2,
BELIEVER = 3, BELIEVER = 3,
EDUCATION = 4 EDUCATION = 4,
LEGACY_PRO = 5
} }
export enum SubscriptionStatus { export enum SubscriptionStatus {
@@ -580,16 +581,6 @@ export enum SubscriptionProvider {
PADDLE = 3 PADDLE = 3
} }
export enum SubscriptionType {
BASIC = 0,
TRIAL = 1,
BETA = 2,
PREMIUM = 5,
PREMIUM_EXPIRED = 6,
PREMIUM_CANCELED = 7,
PREMIUM_PAUSED = 8
}
export type User = { export type User = {
id: string; id: string;
email: string; email: string;
@@ -615,7 +606,6 @@ export type User = {
productId: string; productId: string;
provider: SubscriptionProvider; provider: SubscriptionProvider;
start: number; start: number;
type: SubscriptionType;
plan: SubscriptionPlan; plan: SubscriptionPlan;
status: SubscriptionStatus; status: SubscriptionStatus;
trialsAvailed?: SubscriptionPlan[]; trialsAvailed?: SubscriptionPlan[];