Skip to content

Commit

Permalink
feat(hook): support local vip in latest PC clients
Browse files Browse the repository at this point in the history
Signed-off-by: Tianling Shen <[email protected]>
  • Loading branch information
1715173329 committed Jul 20, 2023
1 parent eb8546a commit ad7f2d1
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/hook.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ hook.target.path = new Set([
'/api/usertool/sound/mobile/all',
'/api/usertool/sound/mobile/detail',
'/api/vipauth/app/auth/query',
'/api/music-vip-membership/client/vip/info',
]);

const domainList = [
Expand Down Expand Up @@ -283,14 +284,16 @@ hook.request.after = (ctx) => {
}

if (ENABLE_LOCAL_VIP) {
const vipPath = '/api/music-vip-membership/client/vip/info';
if (
netease.path === '/batch' ||
netease.path === '/api/batch'
netease.path === '/api/batch' ||
netease.path === vipPath
) {
const info =
netease.jsonBody[
'/api/music-vip-membership/client/vip/info'
];
netease.path === vipPath
? netease.jsonBody
: netease.jsonBody[vipPath];
const defaultPackage = {
iconUrl: null,
dynamicIconUrl: null,
Expand All @@ -299,30 +302,30 @@ hook.request.after = (ctx) => {
isSignDeduct: false,
isSignIapDeduct: false,
};
const nVipLevel = 5; // ? months
const vipLevel = 7; // ? months
if (
info &&
(LOCAL_VIP_UID.length === 0 ||
LOCAL_VIP_UID.includes(info.data.userId))
) {
try {
const expireTime = info.data.now + 31622400000;
info.data.redVipLevel = 7;
info.data.redVipLevel = vipLevel;
info.data.redVipAnnualCount = 1;

info.data.musicPackage = {
...defaultPackage,
...info.data.musicPackage,
vipCode: 230,
vipLevel: nVipLevel,
vipLevel,
expireTime,
};

info.data.associator = {
...defaultPackage,
...info.data.associator,
vipCode: 100,
vipLevel: nVipLevel,
vipLevel,
expireTime,
};

Expand All @@ -331,7 +334,7 @@ hook.request.after = (ctx) => {
...defaultPackage,
...info.data.redplus,
vipCode: 300,
vipLevel: nVipLevel,
vipLevel,
expireTime,
};

Expand All @@ -344,9 +347,9 @@ hook.request.after = (ctx) => {
};
}

netease.jsonBody[
'/api/music-vip-membership/client/vip/info'
] = info;
if (netease.path === vipPath)
netease.jsonBody = info;
else netease.jsonBody[vipPath] = info;
} catch (error) {
logger.debug(
{ err: error },
Expand Down

0 comments on commit ad7f2d1

Please sign in to comment.