Skip to content

Commit

Permalink
misc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Simyon264 committed Aug 29, 2024
1 parent 5cea37e commit fe68d3d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 47 deletions.
33 changes: 0 additions & 33 deletions ReplayBrowser/Data/Migrations/ReplayDbContextModelSnapshot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -559,39 +559,6 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.ToTable("ReplayParticipants");
});

modelBuilder.Entity("ReplayBrowser.Models.Ingested.ReplayEvents.ReplayEventPlayer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");

NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));

b.Property<string[]>("AntagPrototypes")
.IsRequired()
.HasColumnType("text[]");

b.Property<string[]>("JobPrototypes")
.IsRequired()
.HasColumnType("text[]");

b.Property<Guid?>("PlayerGuid")
.IsRequired()
.HasColumnType("uuid");

b.Property<string>("PlayerIcName")
.IsRequired()
.HasColumnType("text");

b.Property<string>("PlayerOocName")
.IsRequired()
.HasColumnType("text");

b.HasKey("Id");

b.ToTable("ReplayEventPlayer");
});

modelBuilder.Entity("ReplayBrowser.Models.Ingested.ReplayEvents.EventTypes.AlertLevelChangedReplayEvent", b =>
{
b.HasBaseType("ReplayBrowser.Data.Models.ReplayDbEvent");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.ChangeTracking;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Newtonsoft.Json;
using ReplayBrowser.Data.Models;
Expand All @@ -24,7 +25,11 @@ public void Configure(EntityTypeBuilder<CargoProductsOrderedReplayEvent> builder
builder.Property(e => e.Products)
.HasConversion(
v => JsonConvert.SerializeObject(v),
v => JsonConvert.DeserializeObject<CargoReplayProduct[]>(v));
v => JsonConvert.DeserializeObject<CargoReplayProduct[]>(v))
.Metadata.SetValueComparer(new ValueComparer<CargoReplayProduct[]>(
(c1, c2) => c1.SequenceEqual(c2),
c => c.Aggregate(0, (a, v) => HashCode.Combine(a, v.GetHashCode())),
c => (CargoReplayProduct[])c.Clone()));
}
}

Expand Down
14 changes: 1 addition & 13 deletions ReplayBrowser/Models/Ingested/ReplayEvents/ReplayEventPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,8 @@ namespace ReplayBrowser.Models.Ingested.ReplayEvents;
/// <summary>
/// Represents a player in a replay event.
/// </summary>
public class ReplayEventPlayer : IEntityTypeConfiguration<ReplayEventPlayer>
public class ReplayEventPlayer
{
public int Id { get; set; }

public void Configure(EntityTypeBuilder<ReplayEventPlayer> builder)
{
builder.HasKey(e => e.Id);
builder.Property(e => e.PlayerOocName).IsRequired();
builder.Property(e => e.PlayerIcName).IsRequired();
builder.Property(e => e.PlayerGuid).IsRequired();
builder.Property(e => e.JobPrototypes).IsRequired();
builder.Property(e => e.AntagPrototypes).IsRequired();
}

/// <summary>
/// The username of the player.
/// </summary>
Expand Down
6 changes: 6 additions & 0 deletions ReplayBrowser/Services/WebhookService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ public async Task SendReplayToWebhooks(Replay parsedReplay)
{
foreach (var webhook in account.Webhooks)
{
// URL check, don't send if empty, doesn't parse as URL or points to localhost
if (string.IsNullOrWhiteSpace(webhook.Url) || !Uri.TryCreate(webhook.Url, UriKind.Absolute, out var url) || url.Host == "localhost")
{
continue;
}

var servers = webhook.Servers.Split(',');
if (!servers.Contains(parsedReplay.ServerName) && !string.IsNullOrWhiteSpace(webhook.Servers))
{
Expand Down

0 comments on commit fe68d3d

Please sign in to comment.