hopefully fix issue with linked banned players

This commit is contained in:
RaidMax 2022-01-02 16:19:48 -06:00
parent 67be4f8e7f
commit f5854f8d03
11 changed files with 4472 additions and 13 deletions

View File

@ -118,7 +118,7 @@ namespace Data.Context
ent.HasIndex(a => a.Name);
ent.Property(_alias => _alias.SearchableName).HasMaxLength(24);
ent.HasIndex(_alias => _alias.SearchableName);
ent.HasIndex(_alias => new {_alias.Name, _alias.IPAddress}).IsUnique();
ent.HasIndex(_alias => new {_alias.Name, _alias.IPAddress});
});
modelBuilder.Entity<EFMeta>(ent =>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,32 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace Data.Migrations.MySql
{
public partial class RemoveUniqueAliasIndexConstraint : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_EFAlias_Name_IPAddress",
table: "EFAlias");
migrationBuilder.CreateIndex(
name: "IX_EFAlias_Name_IPAddress",
table: "EFAlias",
columns: new[] { "Name", "IPAddress" });
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_EFAlias_Name_IPAddress",
table: "EFAlias");
migrationBuilder.CreateIndex(
name: "IX_EFAlias_Name_IPAddress",
table: "EFAlias",
columns: new[] { "Name", "IPAddress" },
unique: true);
}
}
}

View File

@ -816,8 +816,7 @@ namespace Data.Migrations.MySql
b.HasIndex("SearchableName");
b.HasIndex("Name", "IPAddress")
.IsUnique();
b.HasIndex("Name", "IPAddress");
b.ToTable("EFAlias");
});

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,32 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace Data.Migrations.Postgresql
{
public partial class RemoveUniqueAliasIndexConstraint : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_EFAlias_Name_IPAddress",
table: "EFAlias");
migrationBuilder.CreateIndex(
name: "IX_EFAlias_Name_IPAddress",
table: "EFAlias",
columns: new[] { "Name", "IPAddress" });
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_EFAlias_Name_IPAddress",
table: "EFAlias");
migrationBuilder.CreateIndex(
name: "IX_EFAlias_Name_IPAddress",
table: "EFAlias",
columns: new[] { "Name", "IPAddress" },
unique: true);
}
}
}

View File

@ -836,8 +836,7 @@ namespace Data.Migrations.Postgresql
b.HasIndex("SearchableName");
b.HasIndex("Name", "IPAddress")
.IsUnique();
b.HasIndex("Name", "IPAddress");
b.ToTable("EFAlias");
});

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,15 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace Data.Migrations.Sqlite
{
public partial class RemoveUniqueAliasIndexConstraint : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
}
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@ -815,8 +815,7 @@ namespace Data.Migrations.Sqlite
b.HasIndex("SearchableName");
b.HasIndex("Name", "IPAddress")
.IsUnique();
b.HasIndex("Name", "IPAddress");
b.ToTable("EFAlias");
});

View File

@ -153,7 +153,7 @@ namespace SharedLibraryCore.Services
{
_logger.LogDebug("[{Method}] creating new Link and Alias for {Entity}", nameof(HandleNewCreate), entity.ToString());
var link = new EFAliasLink();
var alias = new EFAlias()
var alias = new EFAlias
{
Name = entity.Name,
SearchableName = entity.Name.StripColors().ToLower(),
@ -167,9 +167,18 @@ namespace SharedLibraryCore.Services
else
{
_logger.LogDebug("[{Method}] associating new GUID {Guid} with existing alias id {aliasId} for {Entity}",
nameof(HandleNewCreate), entity.GuidString, existingAlias.AliasId, entity.ToString());
client.CurrentAliasId = existingAlias.AliasId;
_logger.LogDebug("[{Method}] associating new GUID {Guid} with new exact alias match with linkId {LinkId} for {Entity}",
nameof(HandleNewCreate), entity.GuidString, existingAlias.LinkId, entity.ToString());
var alias = new EFAlias
{
Name = existingAlias.Name,
SearchableName = entity.Name.StripColors().ToLower(),
DateAdded = DateTime.UtcNow,
IPAddress = entity.IPAddress,
LinkId = existingAlias.LinkId
};
client.CurrentAlias = alias;
client.AliasLinkId = existingAlias.LinkId;
}
@ -338,7 +347,7 @@ namespace SharedLibraryCore.Services
return;
}
if (existingExactAlias != null)
if (existingExactAlias != null && entity.AliasLinkId == existingExactAlias.LinkId)
{
entity.CurrentAlias = existingExactAlias;
entity.CurrentAliasId = existingExactAlias.AliasId;