prevent flag icon from showing on banned profiles
implement automated penalty info for profanity determent issue #75
This commit is contained in:
parent
d11a5f862b
commit
b8a310bb07
@ -1,9 +1,11 @@
|
|||||||
using System.Linq;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using SharedLibraryCore;
|
using SharedLibraryCore;
|
||||||
using SharedLibraryCore.Configuration;
|
using SharedLibraryCore.Configuration;
|
||||||
|
using SharedLibraryCore.Database.Models;
|
||||||
using SharedLibraryCore.Interfaces;
|
using SharedLibraryCore.Interfaces;
|
||||||
|
|
||||||
namespace IW4MAdmin.Plugins.ProfanityDeterment
|
namespace IW4MAdmin.Plugins.ProfanityDeterment
|
||||||
@ -41,7 +43,15 @@ namespace IW4MAdmin.Plugins.ProfanityDeterment
|
|||||||
|
|
||||||
if (containsObjectionalWord)
|
if (containsObjectionalWord)
|
||||||
{
|
{
|
||||||
E.Origin.Kick(Settings.Configuration().ProfanityKickMessage, Utilities.IW4MAdminClient(E.Owner));
|
var sender = Utilities.IW4MAdminClient(E.Owner);
|
||||||
|
sender.AdministeredPenalties = new List<EFPenalty>()
|
||||||
|
{
|
||||||
|
new EFPenalty()
|
||||||
|
{
|
||||||
|
AutomatedOffense = E.Origin.Name
|
||||||
|
}
|
||||||
|
};
|
||||||
|
E.Origin.Kick(Settings.Configuration().ProfanityKickMessage, sender);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,7 +88,16 @@ namespace IW4MAdmin.Plugins.ProfanityDeterment
|
|||||||
else if (profanityInfringments < Settings.Configuration().KickAfterInfringementCount)
|
else if (profanityInfringments < Settings.Configuration().KickAfterInfringementCount)
|
||||||
{
|
{
|
||||||
E.Origin.SetAdditionalProperty("_profanityInfringements", profanityInfringments + 1);
|
E.Origin.SetAdditionalProperty("_profanityInfringements", profanityInfringments + 1);
|
||||||
E.Origin.Warn(Settings.Configuration().ProfanityWarningMessage, Utilities.IW4MAdminClient(E.Owner));
|
|
||||||
|
var sender = Utilities.IW4MAdminClient(E.Owner);
|
||||||
|
sender.AdministeredPenalties = new List<EFPenalty>()
|
||||||
|
{
|
||||||
|
new EFPenalty()
|
||||||
|
{
|
||||||
|
AutomatedOffense = E.Data
|
||||||
|
}
|
||||||
|
};
|
||||||
|
E.Origin.Warn(Settings.Configuration().ProfanityWarningMessage, sender);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,21 +102,16 @@ namespace IW4MAdmin.Plugins.Stats.Web.Controllers
|
|||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public async Task<IActionResult> GetAutomatedPenaltyInfoAsync(int clientId)
|
public async Task<IActionResult> GetAutomatedPenaltyInfoAsync(int penaltyId)
|
||||||
{
|
{
|
||||||
using (var ctx = new SharedLibraryCore.Database.DatabaseContext(true))
|
using (var ctx = new SharedLibraryCore.Database.DatabaseContext(true))
|
||||||
{
|
{
|
||||||
int linkId = await ctx.Clients
|
var penalty = await ctx.Penalties
|
||||||
.Where(_client => _client.ClientId == clientId)
|
.Select(_penalty => new { _penalty.OffenderId, _penalty.PenaltyId, _penalty.When, _penalty.AutomatedOffense })
|
||||||
.Select(_client => _client.AliasLinkId)
|
.FirstOrDefaultAsync(_penalty => _penalty.PenaltyId == penaltyId);
|
||||||
.FirstOrDefaultAsync();
|
|
||||||
|
|
||||||
var clientIds = await ctx.Clients.Where(_client => _client.AliasLinkId == linkId)
|
var iqSnapshotInfo = ctx.Set<Models.EFACSnapshot>()
|
||||||
.Select(_client => _client.ClientId)
|
.Where(s => s.ClientId == penalty.OffenderId)
|
||||||
.ToListAsync();
|
|
||||||
|
|
||||||
var iqPenaltyInfo = ctx.Set<Models.EFACSnapshot>()
|
|
||||||
.Where(s => clientIds.Contains(s.ClientId))
|
|
||||||
.Include(s => s.LastStrainAngle)
|
.Include(s => s.LastStrainAngle)
|
||||||
.Include(s => s.HitOrigin)
|
.Include(s => s.HitOrigin)
|
||||||
.Include(s => s.HitDestination)
|
.Include(s => s.HitDestination)
|
||||||
@ -126,13 +121,29 @@ namespace IW4MAdmin.Plugins.Stats.Web.Controllers
|
|||||||
.ThenBy(s => s.Hits);
|
.ThenBy(s => s.Hits);
|
||||||
|
|
||||||
#if DEBUG == true
|
#if DEBUG == true
|
||||||
var sql = iqPenaltyInfo.ToSql();
|
var sql = iqSnapshotInfo.ToSql();
|
||||||
#endif
|
#endif
|
||||||
|
var penaltyInfo = await iqSnapshotInfo.ToListAsync();
|
||||||
|
|
||||||
var penaltyInfo = await iqPenaltyInfo.ToListAsync();
|
if (penaltyInfo.Count > 0)
|
||||||
|
{
|
||||||
return View("_PenaltyInfo", penaltyInfo);
|
return View("_PenaltyInfo", penaltyInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// we want to show anything related to the automated offense
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return View("_MessageContext", new[]
|
||||||
|
{
|
||||||
|
new ChatInfo()
|
||||||
|
{
|
||||||
|
ClientId = penalty.OffenderId,
|
||||||
|
Message = penalty.AutomatedOffense,
|
||||||
|
Time = penalty.When
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,13 +6,12 @@
|
|||||||
string gravatarUrl = Model.Meta.FirstOrDefault(m => m.Key == "GravatarEmail")?.Value;
|
string gravatarUrl = Model.Meta.FirstOrDefault(m => m.Key == "GravatarEmail")?.Value;
|
||||||
bool isTempBanned = Model.ActivePenaltyType == "TempBan";
|
bool isTempBanned = Model.ActivePenaltyType == "TempBan";
|
||||||
bool isFlagged = Model.LevelInt == (int)SharedLibraryCore.Database.Models.EFClient.Permission.Flagged;
|
bool isFlagged = Model.LevelInt == (int)SharedLibraryCore.Database.Models.EFClient.Permission.Flagged;
|
||||||
|
bool isPermBanned = Model.LevelInt == (int)SharedLibraryCore.Database.Models.EFClient.Permission.Banned;
|
||||||
var informationMeta = Model.Meta
|
var informationMeta = Model.Meta
|
||||||
.Where(_meta => _meta.Type == SharedLibraryCore.Dtos.ProfileMeta.MetaType.Information)
|
.Where(_meta => _meta.Type == SharedLibraryCore.Dtos.ProfileMeta.MetaType.Information)
|
||||||
.OrderBy(_meta => _meta.Order)
|
.OrderBy(_meta => _meta.Order)
|
||||||
.GroupBy(_meta => _meta.Column)
|
.GroupBy(_meta => _meta.Column)
|
||||||
.OrderBy(_grouping => _grouping.Key);
|
.OrderBy(_grouping => _grouping.Key);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
<div id="profile_wrapper" class="pb-3 row d-flex flex-column flex-lg-row">
|
<div id="profile_wrapper" class="pb-3 row d-flex flex-column flex-lg-row">
|
||||||
@ -57,7 +56,10 @@
|
|||||||
@if (ViewBag.Authorized)
|
@if (ViewBag.Authorized)
|
||||||
{
|
{
|
||||||
<div class="pr-lg-0 text-center text-lg-right">
|
<div class="pr-lg-0 text-center text-lg-right">
|
||||||
|
@if (!isPermBanned)
|
||||||
|
{
|
||||||
<div class="profile-action oi oi-flag h3 ml-2 @(isFlagged ? "text-secondary" : "text-success")" data-action="@(isFlagged ? "unflag" : "flag")" aria-hidden="true"></div>
|
<div class="profile-action oi oi-flag h3 ml-2 @(isFlagged ? "text-secondary" : "text-success")" data-action="@(isFlagged ? "unflag" : "flag")" aria-hidden="true"></div>
|
||||||
|
}
|
||||||
|
|
||||||
@if (Model.LevelInt < (int)ViewBag.User.Level && !Model.HasActivePenalty)
|
@if (Model.LevelInt < (int)ViewBag.User.Level && !Model.HasActivePenalty)
|
||||||
{
|
{
|
||||||
|
@ -21,12 +21,12 @@
|
|||||||
return meta.Type == SharedLibraryCore.Dtos.ProfileMeta.MetaType.Penalized ?
|
return meta.Type == SharedLibraryCore.Dtos.ProfileMeta.MetaType.Penalized ?
|
||||||
string.Format(localizationMessage,
|
string.Format(localizationMessage,
|
||||||
$"<span class='text-highlight'><a class='link-inverse' href='{penalty.OffenderId}'>{penalty.OffenderName}</a></span>",
|
$"<span class='text-highlight'><a class='link-inverse' href='{penalty.OffenderId}'>{penalty.OffenderName}</a></span>",
|
||||||
$"<span class='{(ViewBag.Authorized ? "automated-penalty-info-detailed" : "")} text-white' data-clientid='{penalty.OffenderId}'>{penalty.Offense} {(ViewBag.Authorized ? penalty.AdditionalPenaltyInformation : "")}</span>")
|
$"<span class='{(ViewBag.Authorized ? "automated-penalty-info-detailed" : "")} text-white' data-penalty-id='{penalty.Id}'>{penalty.Offense} {(ViewBag.Authorized ? penalty.AdditionalPenaltyInformation : "")}</span>")
|
||||||
.Replace("{", "")
|
.Replace("{", "")
|
||||||
.Replace("}", "") :
|
.Replace("}", "") :
|
||||||
string.Format(localizationMessage,
|
string.Format(localizationMessage,
|
||||||
$"<span class='text-highlight'><a class='link-inverse' href='{penalty.PunisherId}'>{penalty.PunisherName}</a></span>",
|
$"<span class='text-highlight'><a class='link-inverse' href='{penalty.PunisherId}'>{penalty.PunisherName}</a></span>",
|
||||||
$"<span class='{(ViewBag.Authorized ? "automated-penalty-info-detailed" : "")} text-white' data-clientid='{penalty.OffenderId}'>{penalty.Offense} {(ViewBag.Authorized ? penalty.AdditionalPenaltyInformation : "")}</span>",
|
$"<span class='{(ViewBag.Authorized ? "automated-penalty-info-detailed" : "")} text-white' data-penalty-id='{penalty.Id}'>{penalty.Offense} {(ViewBag.Authorized ? penalty.AdditionalPenaltyInformation : "")}</span>",
|
||||||
penalty.Offense)
|
penalty.Offense)
|
||||||
.Replace("{", "")
|
.Replace("{", "")
|
||||||
.Replace("}", "");
|
.Replace("}", "");
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
showLoader();
|
showLoader();
|
||||||
const location = $(this).parent();
|
const location = $(this).parent();
|
||||||
$.get('/Stats/GetAutomatedPenaltyInfoAsync', {
|
$.get('/Stats/GetAutomatedPenaltyInfoAsync', {
|
||||||
'clientId': $(this).data('clientid')
|
'penaltyId': $(this).data('penalty-id')
|
||||||
})
|
})
|
||||||
.done(function (response) {
|
.done(function (response) {
|
||||||
$('.penalty-info-context').remove();
|
$('.penalty-info-context').remove();
|
||||||
|
Loading…
Reference in New Issue
Block a user