Remove the discord socket client dependency from the webapi

This commit is contained in:
Daan Boerlage 2021-10-31 20:22:42 +01:00
parent 29a2e5c4a2
commit 177c773451
Signed by: daan
GPG key ID: FCE070E1E4956606
3 changed files with 5 additions and 8 deletions

View file

@ -227,7 +227,7 @@ namespace Geekbot.Bot
private void StartWebApi()
{
var highscoreManager = new HighscoreManager(_databaseInitializer.Initialize(), _userRepository);
WebApiStartup.StartWebApi(_servicesProvider, _logger, _runParameters, _commands, _databaseInitializer.Initialize(), _client, _globalSettings, highscoreManager);
WebApiStartup.StartWebApi(_servicesProvider, _logger, _runParameters, _commands, _databaseInitializer.Initialize(), _globalSettings, highscoreManager);
}
private void RegisterSentry()

View file

@ -12,12 +12,10 @@ namespace Geekbot.Web.Controllers.Callback
{
public class CallbackController : Controller
{
private readonly DiscordSocketClient _client;
private readonly IGlobalSettings _globalSettings;
public CallbackController(DiscordSocketClient client, IGlobalSettings globalSettings)
public CallbackController(IGlobalSettings globalSettings)
{
_client = client;
_globalSettings = globalSettings;
}
@ -28,13 +26,13 @@ namespace Geekbot.Web.Controllers.Callback
using (var client = new HttpClient())
{
client.BaseAddress = new Uri("https://discordapp.com");
var appInfo = await _client.GetApplicationInfoAsync();
var appId = _globalSettings.GetKey("DiscordApplicationId");
var accessToken = _globalSettings.GetKey("OAuthToken");
var callbackUrl = _globalSettings.GetKey("OAuthCallbackUrl");
var form = new Dictionary<string, string>
{
{"client_id", appInfo.Id.ToString()},
{"client_id", appId},
{"client_secret", accessToken},
{"grant_type", "authorization_code"},
{"code", code},

View file

@ -24,7 +24,7 @@ namespace Geekbot.Web
public static void Main() {}
public static void StartWebApi(IServiceProvider commandProvider, IGeekbotLogger logger, RunParameters runParameters, CommandService commandService,
DatabaseContext databaseContext, DiscordSocketClient client, IGlobalSettings globalSettings, IHighscoreManager highscoreManager)
DatabaseContext databaseContext, IGlobalSettings globalSettings, IHighscoreManager highscoreManager)
{
WebHost.CreateDefaultBuilder()
.UseKestrel(options =>
@ -54,7 +54,6 @@ namespace Geekbot.Web
if (runParameters.DisableGateway) return;
services.AddSingleton(commandService);
services.AddSingleton(client);
})
.Configure(app =>
{