add support for plugin generated pages (interactions). add disallow vpn command
This commit is contained in:
@ -27,6 +27,7 @@ namespace WebfrontCore.Controllers
|
||||
private readonly IMetaServiceV2 _metaService;
|
||||
private readonly IInteractionRegistration _interactionRegistration;
|
||||
private readonly IRemoteCommandService _remoteCommandService;
|
||||
private readonly ITranslationLookup _translationLookup;
|
||||
private readonly string _banCommandName;
|
||||
private readonly string _tempbanCommandName;
|
||||
private readonly string _unbanCommandName;
|
||||
@ -41,12 +42,14 @@ namespace WebfrontCore.Controllers
|
||||
|
||||
public ActionController(IManager manager, IEnumerable<IManagerCommand> registeredCommands,
|
||||
ApplicationConfiguration appConfig, IMetaServiceV2 metaService,
|
||||
IInteractionRegistration interactionRegistration, IRemoteCommandService remoteCommandService) : base(manager)
|
||||
IInteractionRegistration interactionRegistration, IRemoteCommandService remoteCommandService,
|
||||
ITranslationLookup translationLookup) : base(manager)
|
||||
{
|
||||
_appConfig = appConfig;
|
||||
_metaService = metaService;
|
||||
_interactionRegistration = interactionRegistration;
|
||||
_remoteCommandService = remoteCommandService;
|
||||
_translationLookup = translationLookup;
|
||||
|
||||
foreach (var cmd in registeredCommands)
|
||||
{
|
||||
@ -94,7 +97,18 @@ namespace WebfrontCore.Controllers
|
||||
|
||||
public IActionResult DynamicActionForm(int? id, string meta)
|
||||
{
|
||||
var metaDict = JsonSerializer.Deserialize<Dictionary<string, string>>(meta);
|
||||
if (Client.ClientId < 1)
|
||||
{
|
||||
return Ok(new[]
|
||||
{
|
||||
new CommandResponseInfo
|
||||
{
|
||||
Response = _translationLookup["SERVER_COMMANDS_INTERCEPTED"]
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var metaDict = JsonSerializer.Deserialize<Dictionary<string, string>>(meta.TrimEnd('"').TrimStart('"'));
|
||||
|
||||
if (metaDict is null)
|
||||
{
|
||||
@ -170,6 +184,17 @@ namespace WebfrontCore.Controllers
|
||||
|
||||
public async Task<IActionResult> DynamicActionAsync(CancellationToken token = default)
|
||||
{
|
||||
if (Client.ClientId < 1)
|
||||
{
|
||||
return Ok(new[]
|
||||
{
|
||||
new CommandResponseInfo
|
||||
{
|
||||
Response = _translationLookup["SERVER_COMMANDS_INTERCEPTED"]
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
HttpContext.Request.Query.TryGetValue("InteractionId", out var interactionId);
|
||||
HttpContext.Request.Query.TryGetValue("CustomInputKeys", out var inputKeys);
|
||||
HttpContext.Request.Query.TryGetValue("Data", out var data);
|
||||
|
@ -77,7 +77,8 @@ namespace WebfrontCore.Controllers
|
||||
note.OriginEntityName = await _clientService.GetClientNameById(note.OriginEntityId);
|
||||
}
|
||||
|
||||
var interactions = await _interactionRegistration.GetInteractions(id, client.GameName, token);
|
||||
var interactions =
|
||||
await _interactionRegistration.GetInteractions("Webfront::Profile", id, client.GameName, token);
|
||||
|
||||
// even though we haven't set their level to "banned" yet
|
||||
// (ie they haven't reconnected with the infringing player identifier)
|
||||
|
37
WebfrontCore/Controllers/InteractionController.cs
Normal file
37
WebfrontCore/Controllers/InteractionController.cs
Normal file
@ -0,0 +1,37 @@
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SharedLibraryCore;
|
||||
using SharedLibraryCore.Interfaces;
|
||||
|
||||
namespace WebfrontCore.Controllers;
|
||||
|
||||
public class InteractionController : BaseController
|
||||
{
|
||||
private readonly IInteractionRegistration _interactionRegistration;
|
||||
|
||||
public InteractionController(IManager manager, IInteractionRegistration interactionRegistration) : base(manager)
|
||||
{
|
||||
_interactionRegistration = interactionRegistration;
|
||||
}
|
||||
|
||||
[HttpGet("[controller]/[action]/{interactionName}")]
|
||||
public async Task<IActionResult> Render([FromRoute]string interactionName, CancellationToken token)
|
||||
{
|
||||
var interactionData = (await _interactionRegistration.GetInteractions(interactionName, token: token)).FirstOrDefault();
|
||||
|
||||
if (interactionData is null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
ViewBag.Title = interactionData.Description;
|
||||
|
||||
var result = await _interactionRegistration.ProcessInteraction(interactionName, Client.ClientId, token: token);
|
||||
|
||||
return interactionData.InteractionType == InteractionType.TemplateContent
|
||||
? View("Render", result ?? "")
|
||||
: Ok(result);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user