✨ Site mode
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using DysonNetwork.Shared.Auth;
|
||||
using DysonNetwork.Shared.Data;
|
||||
using DysonNetwork.Shared.Models;
|
||||
using DysonNetwork.Shared.Registry;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
@@ -9,7 +10,8 @@ namespace DysonNetwork.Zone.Publication;
|
||||
public class PublicationSiteService(
|
||||
AppDatabase db,
|
||||
RemotePublisherService publisherService,
|
||||
RemoteAccountService remoteAccounts
|
||||
RemoteAccountService remoteAccounts,
|
||||
RemotePublisherService remotePublishers
|
||||
)
|
||||
{
|
||||
public async Task<SnPublicationSite?> GetSiteById(Guid id)
|
||||
@@ -19,9 +21,18 @@ public class PublicationSiteService(
|
||||
.FirstOrDefaultAsync(s => s.Id == id);
|
||||
}
|
||||
|
||||
public async Task<SnPublicationSite?> GetSiteBySlug(string slug)
|
||||
public async Task<SnPublicationSite?> GetSiteBySlug(string slug, string? pubName = null)
|
||||
{
|
||||
Guid? pubId = null;
|
||||
if (pubName != null)
|
||||
{
|
||||
var pub = await remotePublishers.GetPublisherByName(pubName);
|
||||
if (pub == null) throw new InvalidOperationException("Publisher not found.");
|
||||
pubId = pub.Id;
|
||||
}
|
||||
|
||||
return await db.PublicationSites
|
||||
.If(pubId.HasValue, q => q.Where(s => s.PublisherId == pubId.Value))
|
||||
.Include(s => s.Pages)
|
||||
.FirstOrDefaultAsync(s => s.Slug == slug);
|
||||
}
|
||||
@@ -39,7 +50,7 @@ public class PublicationSiteService(
|
||||
var perk = (await remoteAccounts.GetAccount(accountId)).PerkSubscription;
|
||||
var perkLevel = perk is not null ? PerkSubscriptionPrivilege.GetPrivilegeFromIdentifier(perk.Identifier) : 0;
|
||||
|
||||
var maxSite = (perkLevel) switch
|
||||
var maxSite = perkLevel switch
|
||||
{
|
||||
1 => 2,
|
||||
2 => 3,
|
||||
|
||||
Reference in New Issue
Block a user