mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-10 15:20:48 -05:00
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);
|
||||
}
|
||||
}
|
8
WebfrontCore/Views/Interaction/Render.cshtml
Normal file
8
WebfrontCore/Views/Interaction/Render.cshtml
Normal file
@ -0,0 +1,8 @@
|
||||
@model string
|
||||
|
||||
<div class="content text-wrap mt-20">
|
||||
<h2 class="content-title">
|
||||
<color-code value="@ViewBag.Title"></color-code>
|
||||
</h2>
|
||||
@Html.Raw(Model)
|
||||
</div>
|
@ -1,6 +1,7 @@
|
||||
@using SharedLibraryCore.Configuration
|
||||
@using SharedLibraryCore.Dtos
|
||||
@using Data.Models.Client
|
||||
@using SharedLibraryCore.Interfaces
|
||||
|
||||
<!-- left side navigation -->
|
||||
<div class="sidebar-overlay" onclick="halfmoon.toggleSidebar()"></div>
|
||||
@ -43,6 +44,23 @@
|
||||
<span class="name">@ViewBag.Localization["WEBFRONT_NAV_HELP"]</span>
|
||||
</a>
|
||||
</has-permission>
|
||||
|
||||
@foreach (IInteractionData interactionData in ViewBag.Interactions)
|
||||
{
|
||||
if (!interactionData.InteractionId.StartsWith("Webfront::Nav::Main"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ViewBag.User.Level >= interactionData.MinimumPermission)
|
||||
{
|
||||
<a asp-controller="Interaction" asp-action="Render" asp-route-interactionName="@interactionData.InteractionId" class="sidebar-link">
|
||||
<i class="oi @interactionData.DisplayMeta mr-5"></i>
|
||||
<span class="name">@interactionData.Name</span>
|
||||
</a>
|
||||
}
|
||||
}
|
||||
|
||||
<!-- profile -->
|
||||
<has-permission entity="ProfilePage" required-permission="Read">
|
||||
<a asp-controller="Client" asp-action="Profile" asp-route-id="@ViewBag.User.ClientId" class="sidebar-link">
|
||||
@ -104,6 +122,23 @@
|
||||
</div>
|
||||
</a>
|
||||
}
|
||||
|
||||
@foreach (IInteractionData interactionData in ViewBag.Interactions)
|
||||
{
|
||||
if (!interactionData.InteractionId.StartsWith("Webfront::Nav::Social"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ViewBag.User.Level >= interactionData.MinimumPermission)
|
||||
{
|
||||
<a asp-controller="Interaction" asp-action="Render" asp-route-interactionName="@interactionData.InteractionId" class="sidebar-link">
|
||||
<i class="oi @interactionData.DisplayMeta mr-5"></i>
|
||||
<span class="name">@interactionData.Name</span>
|
||||
</a>
|
||||
}
|
||||
}
|
||||
|
||||
<br/>
|
||||
|
||||
<!-- admin -->
|
||||
@ -142,6 +177,22 @@
|
||||
<span class="name">@ViewBag.Localization["WEBFRONT_ACTION_RECENT_CLIENTS"]</span>
|
||||
</a>
|
||||
</has-permission>
|
||||
|
||||
@foreach (IInteractionData interactionData in ViewBag.Interactions)
|
||||
{
|
||||
if (!interactionData.InteractionId.StartsWith("Webfront::Nav::Admin"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ViewBag.User.Level >= interactionData.MinimumPermission)
|
||||
{
|
||||
<a asp-controller="Interaction" asp-action="Render" asp-route-interactionName="@interactionData.InteractionId" class="sidebar-link">
|
||||
<i class="oi @interactionData.DisplayMeta mr-5"></i>
|
||||
<span class="name">@interactionData.Name</span>
|
||||
</a>
|
||||
}
|
||||
}
|
||||
|
||||
@if (ViewBag.Authorized)
|
||||
{
|
||||
|
Reference in New Issue
Block a user