Changed Sqlite to microsoft sqlite implementation

This commit is contained in:
2025-01-28 13:36:49 +02:00
parent d26c84480a
commit 20165af15a
13 changed files with 227 additions and 34 deletions

View File

@@ -0,0 +1,12 @@
using DiscordBotCore.Online;
namespace DiscordBotCore.API.Endpoints;
public class ApiEndpointBase
{
internal IPluginManager PluginManager { get; }
public ApiEndpointBase(IPluginManager pluginManager)
{
PluginManager = pluginManager;
}
}

View File

@@ -24,7 +24,7 @@ public class ApiManager
AddEndpoint(new HomeEndpoint());
AddEndpoint(new PluginListEndpoint());
AddEndpoint(new PluginListInstalledEndpoint());
AddEndpoint(new PluginInstallEndpoint());
AddEndpoint(new PluginInstallEndpoint(Application.CurrentApplication.PluginManager));
AddEndpoint(new SettingsChangeEndpoint());
AddEndpoint(new SettingsGetEndpoint());

View File

@@ -2,28 +2,34 @@ using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using DiscordBotCore.Interfaces.API;
using DiscordBotCore.Online;
using DiscordBotCore.Others;
using DiscordBotCore.Plugin;
namespace DiscordBotCore.API.Endpoints.PluginManagement;
public class PluginInstallEndpoint : IEndpoint
public class PluginInstallEndpoint : ApiEndpointBase, IEndpoint
{
public PluginInstallEndpoint(IPluginManager pluginManager) : base(pluginManager)
{
}
public string Path => "/api/plugin/install";
public EndpointType HttpMethod => EndpointType.Post;
public async Task<ApiResponse> HandleRequest(string? jsonRequest)
{
Dictionary<string, string> jsonDict = await JsonManager.ConvertFromJson<Dictionary<string, string>>(jsonRequest);
string pluginName = jsonDict["pluginName"];
OnlinePlugin? pluginInfo = await Application.CurrentApplication.PluginManager.GetPluginDataByName(pluginName);
OnlinePlugin? pluginInfo = await PluginManager.GetPluginDataByName(pluginName);
if (pluginInfo == null)
{
return ApiResponse.Fail("Plugin not found.");
}
Application.CurrentApplication.PluginManager.InstallPluginNoProgress(pluginInfo);
PluginManager.InstallPluginNoProgress(pluginInfo);
return ApiResponse.Ok();
}
}