change penalty expiration datetime to null for perm bans

add tempban max time
allow searching for GUID
stats returns ranking as well
fix for promotion/demotion text
This commit is contained in:
RaidMax
2018-10-15 19:51:04 -05:00
parent a58726d872
commit d50e6c8030
21 changed files with 1050 additions and 216 deletions

View File

@ -255,27 +255,30 @@ namespace SharedLibraryCore.Services
}
}
public async Task<IList<EFClient>> GetClientByName(string name)
public async Task<IList<EFClient>> FindClientsByIdentifier(string identifier)
{
if (name.Length < 3)
if (identifier.Length < 3)
{
return new List<EFClient>();
}
name = name.ToLower();
identifier = identifier.ToLower();
using (var context = new DatabaseContext(disableTracking: true))
{
int asIP = name.ConvertToIP();
// hack: so IW4MAdmin and bots don't show up in search results
asIP = asIP == 0 ? int.MaxValue : asIP;
long networkId = identifier.ConvertLong();
int ipAddress = identifier.ConvertToIP();
var iqLinkIds = (from alias in context.Aliases
where asIP != int.MaxValue ? alias.IPAddress == asIP : alias.Name.ToLower().Contains(name)
select alias.LinkId);
where alias.IPAddress == ipAddress ||
alias.Name.ToLower().Contains(identifier)
select alias.LinkId).Distinct();
var linkIds = iqLinkIds.ToList();
var iqClients = context.Clients
.Where(c => linkIds.Contains(c.AliasLinkId))
.Where(c => linkIds.Contains(c.AliasLinkId) ||
networkId == c.NetworkId)
.Include(c => c.CurrentAlias)
.Include(c => c.AliasLink.Children);

View File

@ -30,9 +30,6 @@ namespace SharedLibraryCore.Services
AutomatedOffense = newEntity.AutomatedOffense
};
if (addedEntity.Expires == DateTime.MaxValue)
addedEntity.Expires = DateTime.Parse(System.Data.SqlTypes.SqlDateTime.MaxValue.ToString());
// make bans propogate to all aliases
if (addedEntity.Type == Objects.Penalty.PenaltyType.Ban)
{
@ -225,7 +222,7 @@ namespace SharedLibraryCore.Services
.Where(p => p.LinkId == linkId ||
p.Link.Children.Any(a => a.IPAddress == ip))
.Where(p => p.Active)
.Where(p => p.Expires > now);
.Where(p => p.Expires == null || p.Expires > now);
#if DEBUG == true
@ -246,7 +243,7 @@ namespace SharedLibraryCore.Services
var penalties = await context.Penalties
.Include(p => p.Link.Children)
.Where(p => p.LinkId == aliasLinkId)
.Where(p => p.Expires > now)
.Where(p => p.Expires > now || p.Expires == null)
.ToListAsync();
penalties.ForEach(async p =>