Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions SS14.Auth.Shared/Config/PatreonConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using System.Collections.Generic;

namespace SS14.Auth.Shared.Config;
namespace SS14.Auth.Shared.Config;

public sealed class PatreonConfiguration
{
public string ClientId { get; set; }
public string ClientSecret { get; set; }
public Dictionary<string, string> TierMap { get; set; }
public Dictionary<string, string> TierNames { get; set; }
public string WebhookSecret { get; set; }
public bool LogWebhooks { get; set; } = true;
}

/// <summary>
/// Public base URL of the auth API, used to tell Patreon where to send webhook messages
/// </summary>
public string WebhookBaseUrl { get; set; }
}
43 changes: 43 additions & 0 deletions SS14.Auth.Shared/Data/ApplicationDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,47 @@ protected override void OnModelCreating(ModelBuilder builder)
.HasIndex(p => p.SpaceUserId)
.IsUnique();

builder.Entity<PatreonCampaign>()
.HasIndex(c => c.Key)
.IsUnique();

builder.Entity<PatreonCampaign>()
.HasIndex(c => c.PatreonCampaignId)
.IsUnique();

builder.Entity<PatreonCampaign>()
.HasOne<SpaceUser>()
.WithMany()
.HasForeignKey(c => c.OwnerUserId)
.OnDelete(DeleteBehavior.SetNull);

// At most one campaign per owner, campaigns without an owner don't count.
builder.Entity<PatreonCampaign>()
.HasIndex(c => c.OwnerUserId)
.IsUnique();

builder.Entity<PatreonCampaign>()
.HasIndex(c => c.ServerTokenHash)
.IsUnique();

builder.Entity<PatreonCampaign>()
.HasIndex(c => c.IsFirstParty)
.IsUnique()
.HasFilter("\"IsFirstParty\"");

builder.Entity<PatreonMembership>()
.HasIndex(m => new { m.CampaignId, m.PatreonUserId })
.IsUnique();

builder.Entity<PatreonMembership>()
.HasIndex(m => m.PatreonUserId);

builder.Entity<PatreonWebhookLog>()
.HasOne<PatreonCampaign>()
.WithMany()
.HasForeignKey(l => l.CampaignId)
.OnDelete(DeleteBehavior.SetNull);

builder.Entity<UserOAuthClient>()
.HasIndex(p => new { p.ClientId })
.IsUnique();
Expand Down Expand Up @@ -124,6 +165,8 @@ protected override void OnModelCreating(ModelBuilder builder)
public DbSet<WhitelistEmail> WhitelistEmails { get; set; }
public DbSet<Patron> Patrons { get; set; }
public DbSet<PatreonWebhookLog> PatreonWebhookLogs { get; set; }
public DbSet<PatreonCampaign> PatreonCampaigns { get; set; }
public DbSet<PatreonMembership> PatreonMemberships { get; set; }
public DbSet<UserOAuthClient> UserOAuthClients { get; set; }
public DbSet<PastAccountName> PastAccountNames { get; set; }
public DbSet<AccountLog> AccountLogs { get; set; }
Expand Down
Loading
Loading