Remove the discord socket client dependency from the webapi
This commit is contained in:
parent
29a2e5c4a2
commit
177c773451
3 changed files with 5 additions and 8 deletions
|
@ -227,7 +227,7 @@ namespace Geekbot.Bot
|
||||||
private void StartWebApi()
|
private void StartWebApi()
|
||||||
{
|
{
|
||||||
var highscoreManager = new HighscoreManager(_databaseInitializer.Initialize(), _userRepository);
|
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()
|
private void RegisterSentry()
|
||||||
|
|
|
@ -12,12 +12,10 @@ namespace Geekbot.Web.Controllers.Callback
|
||||||
{
|
{
|
||||||
public class CallbackController : Controller
|
public class CallbackController : Controller
|
||||||
{
|
{
|
||||||
private readonly DiscordSocketClient _client;
|
|
||||||
private readonly IGlobalSettings _globalSettings;
|
private readonly IGlobalSettings _globalSettings;
|
||||||
|
|
||||||
public CallbackController(DiscordSocketClient client, IGlobalSettings globalSettings)
|
public CallbackController(IGlobalSettings globalSettings)
|
||||||
{
|
{
|
||||||
_client = client;
|
|
||||||
_globalSettings = globalSettings;
|
_globalSettings = globalSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,13 +26,13 @@ namespace Geekbot.Web.Controllers.Callback
|
||||||
using (var client = new HttpClient())
|
using (var client = new HttpClient())
|
||||||
{
|
{
|
||||||
client.BaseAddress = new Uri("https://discordapp.com");
|
client.BaseAddress = new Uri("https://discordapp.com");
|
||||||
var appInfo = await _client.GetApplicationInfoAsync();
|
var appId = _globalSettings.GetKey("DiscordApplicationId");
|
||||||
var accessToken = _globalSettings.GetKey("OAuthToken");
|
var accessToken = _globalSettings.GetKey("OAuthToken");
|
||||||
var callbackUrl = _globalSettings.GetKey("OAuthCallbackUrl");
|
var callbackUrl = _globalSettings.GetKey("OAuthCallbackUrl");
|
||||||
|
|
||||||
var form = new Dictionary<string, string>
|
var form = new Dictionary<string, string>
|
||||||
{
|
{
|
||||||
{"client_id", appInfo.Id.ToString()},
|
{"client_id", appId},
|
||||||
{"client_secret", accessToken},
|
{"client_secret", accessToken},
|
||||||
{"grant_type", "authorization_code"},
|
{"grant_type", "authorization_code"},
|
||||||
{"code", code},
|
{"code", code},
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace Geekbot.Web
|
||||||
public static void Main() {}
|
public static void Main() {}
|
||||||
|
|
||||||
public static void StartWebApi(IServiceProvider commandProvider, IGeekbotLogger logger, RunParameters runParameters, CommandService commandService,
|
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()
|
WebHost.CreateDefaultBuilder()
|
||||||
.UseKestrel(options =>
|
.UseKestrel(options =>
|
||||||
|
@ -54,7 +54,6 @@ namespace Geekbot.Web
|
||||||
|
|
||||||
if (runParameters.DisableGateway) return;
|
if (runParameters.DisableGateway) return;
|
||||||
services.AddSingleton(commandService);
|
services.AddSingleton(commandService);
|
||||||
services.AddSingleton(client);
|
|
||||||
})
|
})
|
||||||
.Configure(app =>
|
.Configure(app =>
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue