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 {
planToId,
SubscriptionPlan,
SubscriptionType,
SubscriptionStatus,
User
} from "../types.js";
import hosts from "../utils/constants.js";
@@ -241,12 +241,8 @@ export default class Subscriptions {
}
function isLegacySubscription(user: User) {
const type = user.subscription.type;
return (
type !== undefined &&
(type === SubscriptionType.BETA ||
type === SubscriptionType.PREMIUM ||
type === SubscriptionType.PREMIUM_CANCELED ||
type === SubscriptionType.TRIAL)
user.subscription.plan === SubscriptionPlan.LEGACY_PRO &&
user.subscription.status !== SubscriptionStatus.EXPIRED
);
}

View File

@@ -356,7 +356,8 @@ class UserManager {
const oldUser = await this.getUser();
if (
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)
) {
await this.tokenManager._refreshToken(true);

View File

@@ -562,7 +562,8 @@ export enum SubscriptionPlan {
ESSENTIAL = 1,
PRO = 2,
BELIEVER = 3,
EDUCATION = 4
EDUCATION = 4,
LEGACY_PRO = 5
}
export enum SubscriptionStatus {
@@ -580,16 +581,6 @@ export enum SubscriptionProvider {
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 = {
id: string;
email: string;
@@ -615,7 +606,6 @@ export type User = {
productId: string;
provider: SubscriptionProvider;
start: number;
type: SubscriptionType;
plan: SubscriptionPlan;
status: SubscriptionStatus;
trialsAvailed?: SubscriptionPlan[];