fix /message
This commit is contained in:
@@ -23,7 +23,7 @@ public class ClientMessageController : Controller
|
|||||||
|
|
||||||
[Route("sendMessage")]
|
[Route("sendMessage")]
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<IActionResult> SendMessage(ClientMessage msg)
|
public async Task<IActionResult> SendMessage([FromBody] ClientMessage msg)
|
||||||
{
|
{
|
||||||
bool hasUid = !string.IsNullOrEmpty(msg.UID);
|
bool hasUid = !string.IsNullOrEmpty(msg.UID);
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ using MareSynchronosShared.Utils;
|
|||||||
using MareSynchronosShared.Services;
|
using MareSynchronosShared.Services;
|
||||||
using StackExchange.Redis;
|
using StackExchange.Redis;
|
||||||
using MareSynchronos.API.Data.Enum;
|
using MareSynchronos.API.Data.Enum;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
|
|
||||||
namespace MareSynchronosServices.Discord;
|
namespace MareSynchronosServices.Discord;
|
||||||
|
|
||||||
@@ -30,12 +31,13 @@ public class MareModule : InteractionModuleBase
|
|||||||
private readonly IConfigurationService<ServerConfiguration> _mareClientConfigurationService;
|
private readonly IConfigurationService<ServerConfiguration> _mareClientConfigurationService;
|
||||||
private readonly IConfigurationService<ServicesConfiguration> _mareServicesConfiguration;
|
private readonly IConfigurationService<ServicesConfiguration> _mareServicesConfiguration;
|
||||||
private readonly IConnectionMultiplexer _connectionMultiplexer;
|
private readonly IConnectionMultiplexer _connectionMultiplexer;
|
||||||
|
private readonly ServerTokenGenerator _serverTokenGenerator;
|
||||||
private Random random = new();
|
private Random random = new();
|
||||||
|
|
||||||
public MareModule(ILogger<MareModule> logger, IServiceProvider services, DiscordBotServices botServices,
|
public MareModule(ILogger<MareModule> logger, IServiceProvider services, DiscordBotServices botServices,
|
||||||
IConfigurationService<ServerConfiguration> mareClientConfigurationService,
|
IConfigurationService<ServerConfiguration> mareClientConfigurationService,
|
||||||
IConfigurationService<ServicesConfiguration> mareServicesConfiguration,
|
IConfigurationService<ServicesConfiguration> mareServicesConfiguration,
|
||||||
IConnectionMultiplexer connectionMultiplexer)
|
IConnectionMultiplexer connectionMultiplexer, ServerTokenGenerator serverTokenGenerator)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_services = services;
|
_services = services;
|
||||||
@@ -43,6 +45,7 @@ public class MareModule : InteractionModuleBase
|
|||||||
_mareClientConfigurationService = mareClientConfigurationService;
|
_mareClientConfigurationService = mareClientConfigurationService;
|
||||||
_mareServicesConfiguration = mareServicesConfiguration;
|
_mareServicesConfiguration = mareServicesConfiguration;
|
||||||
_connectionMultiplexer = connectionMultiplexer;
|
_connectionMultiplexer = connectionMultiplexer;
|
||||||
|
_serverTokenGenerator = serverTokenGenerator;
|
||||||
}
|
}
|
||||||
|
|
||||||
//[SlashCommand("register", "Starts the registration process")]
|
//[SlashCommand("register", "Starts the registration process")]
|
||||||
@@ -372,6 +375,7 @@ public class MareModule : InteractionModuleBase
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
using HttpClient c = new HttpClient();
|
using HttpClient c = new HttpClient();
|
||||||
|
c.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _serverTokenGenerator.Token);
|
||||||
await c.PostAsJsonAsync(new Uri(_mareServicesConfiguration.GetValue<Uri>
|
await c.PostAsJsonAsync(new Uri(_mareServicesConfiguration.GetValue<Uri>
|
||||||
(nameof(ServicesConfiguration.MainServerAddress)), "/msgc/sendMessage"), new ClientMessage(messageType, message, uid ?? string.Empty))
|
(nameof(ServicesConfiguration.MainServerAddress)), "/msgc/sendMessage"), new ClientMessage(messageType, message, uid ?? string.Empty))
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user