36 lines
1.1 KiB
C#
36 lines
1.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using WinWARP.Core.Helper;
|
|
using WinWARP.Core.Models.Entities;
|
|
using WinWARP.Core.Services.Interfaces;
|
|
|
|
namespace WinWARP.Core.Services.Implementations;
|
|
|
|
public class SubscriptionFetcher : ISubscriptionFetcher
|
|
{
|
|
public bool IsUrlValid(string subscriptionUrl)
|
|
{
|
|
Uri? validatedUri;
|
|
if (!Uri.TryCreate(subscriptionUrl, UriKind.Absolute, out validatedUri))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return validatedUri.Scheme == Uri.UriSchemeHttp ||
|
|
validatedUri.Scheme == Uri.UriSchemeHttps;
|
|
}
|
|
|
|
public async Task<Subscription> FetchAsync(string subscriptionUrl)
|
|
{
|
|
// TODO: Implement the actual fetching logic here, e.g., using HttpClient to get the subscription data from the URL.
|
|
await Task.Delay(10); // Simulate an asynchronous operation
|
|
return new Subscription
|
|
{
|
|
DefaultTitle = "Default Subscription",
|
|
Link = subscriptionUrl,
|
|
Servers = [new() { DefaultTitle = "Default Server", Region = "NO", Title = "Not default title" }]
|
|
};
|
|
}
|
|
}
|