diff --git a/backend/package.json b/backend/package.json index 6405d7c..c0d80ec 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.14.248", + "version": "2.14.249", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.", "main": "src/main.js", "scripts": { diff --git a/backend/src/restful/download.js b/backend/src/restful/download.js index 7ba2d25..2fce1a7 100644 --- a/backend/src/restful/download.js +++ b/backend/src/restful/download.js @@ -124,6 +124,9 @@ async function downloadSubscription(req, res) { ); } } + if (sub.subUserinfo) { + res.set('subscription-userinfo', sub.subUserinfo); + } if (platform === 'JSON') { res.set('Content-Type', 'application/json;charset=utf-8').send( @@ -253,6 +256,9 @@ async function downloadCollection(req, res) { ); } } + if (sub.subUserinfo) { + res.set('subscription-userinfo', sub.subUserinfo); + } } if (platform === 'JSON') { diff --git a/backend/src/restful/subscriptions.js b/backend/src/restful/subscriptions.js index 001e441..af3d367 100644 --- a/backend/src/restful/subscriptions.js +++ b/backend/src/restful/subscriptions.js @@ -51,14 +51,20 @@ async function getFlowInfo(req, res) { sub.source === 'local' && !['localFirst', 'remoteFirst'].includes(sub.mergeSources) ) { - failed( - res, - new RequestInvalidError( - 'NO_FLOW_INFO', - 'N/A', - `Local subscription ${name} has no flow information!`, - ), - ); + if (sub.subUserinfo) { + success(res, { + ...parseFlowHeaders(sub.subUserinfo), + }); + } else { + failed( + res, + new RequestInvalidError( + 'NO_FLOW_INFO', + 'N/A', + `Local subscription ${name} has no flow information!`, + ), + ); + } return; } try { @@ -97,26 +103,37 @@ async function getFlowInfo(req, res) { ); return; } - const flowHeaders = await getFlowHeaders(url); - if (!flowHeaders) { - failed( - res, - new InternalServerError( - 'NO_FLOW_INFO', - 'No flow info', - `Failed to fetch flow headers`, - ), - ); - return; + if (sub.subUserinfo) { + success(res, { + ...parseFlowHeaders(sub.subUserinfo), + remainingDays: getRmainingDays({ + resetDay: $arguments.resetDay, + startDate: $arguments.startDate, + cycleDays: $arguments.cycleDays, + }), + }); + } else { + const flowHeaders = await getFlowHeaders(url); + if (!flowHeaders) { + failed( + res, + new InternalServerError( + 'NO_FLOW_INFO', + 'No flow info', + `Failed to fetch flow headers`, + ), + ); + return; + } + success(res, { + ...parseFlowHeaders(flowHeaders), + remainingDays: getRmainingDays({ + resetDay: $arguments.resetDay, + startDate: $arguments.startDate, + cycleDays: $arguments.cycleDays, + }), + }); } - success(res, { - ...parseFlowHeaders(flowHeaders), - remainingDays: getRmainingDays({ - resetDay: $arguments.resetDay, - startDate: $arguments.startDate, - cycleDays: $arguments.cycleDays, - }), - }); } catch (err) { failed( res,