Add subscription info refresh endpoint and UI stats
This commit is contained in:
@@ -136,7 +136,7 @@ export function parseSubscriptionBody(body) {
|
||||
return { config: parsedConfig, servers };
|
||||
}
|
||||
|
||||
export async function fetchSubscription(url) {
|
||||
async function requestSubscription(url) {
|
||||
let parsedUrl;
|
||||
try {
|
||||
parsedUrl = new URL(url);
|
||||
@@ -157,6 +157,21 @@ export async function fetchSubscription(url) {
|
||||
throw new Error(`Subscription request failed: HTTP ${response.status}`);
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
export async function fetchSubscriptionInfo(url) {
|
||||
const response = await requestSubscription(url);
|
||||
await response.body?.cancel();
|
||||
return {
|
||||
userInfo: parseUserInfo(response.headers.get('subscription-userinfo')),
|
||||
fetchedAt: new Date().toISOString(),
|
||||
};
|
||||
}
|
||||
|
||||
export async function fetchSubscription(url) {
|
||||
const response = await requestSubscription(url);
|
||||
|
||||
const body = await response.text();
|
||||
const userInfo = parseUserInfo(response.headers.get('subscription-userinfo'));
|
||||
const parsed = parseSubscriptionBody(body);
|
||||
|
||||
Reference in New Issue
Block a user