Add team roles and content management updates
This commit is contained in:
@@ -21,12 +21,12 @@ public static partial class PublicEndpoints
|
||||
|
||||
if (submittedNominations.Length is 0 or > 3)
|
||||
{
|
||||
return Results.BadRequest(new { message = "A nomination request must include between 1 and 3 nominees." });
|
||||
return Results.BadRequest(new { message = "A nomination request must include between 1 and 3 stream links." });
|
||||
}
|
||||
|
||||
if (submittedNominations.Any(item => item.Name.Length > 120))
|
||||
if (submittedNominations.Any(item => item.Name is { Length: > 120 }))
|
||||
{
|
||||
return Results.BadRequest(new { message = "Nominee names must stay below 120 characters." });
|
||||
return Results.BadRequest(new { message = "Legacy nominee names must stay below 120 characters." });
|
||||
}
|
||||
|
||||
if (submittedNominations.Any(item => item.StreamUrl.Length > 300))
|
||||
@@ -34,19 +34,14 @@ public static partial class PublicEndpoints
|
||||
return Results.BadRequest(new { message = "Stream links must stay below 300 characters." });
|
||||
}
|
||||
|
||||
if (request.Nominations is { Length: > 0 } && submittedNominations.Any(item => string.IsNullOrWhiteSpace(item.StreamUrl)))
|
||||
{
|
||||
return Results.BadRequest(new { message = "A stream link is required for every nomination." });
|
||||
}
|
||||
|
||||
var distinctNomineeNames = submittedNominations
|
||||
.Select(item => item.Name)
|
||||
var distinctStreamUrls = submittedNominations
|
||||
.Select(item => item.StreamUrl)
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
.ToArray();
|
||||
|
||||
if (distinctNomineeNames.Length != submittedNominations.Length)
|
||||
if (distinctStreamUrls.Length != submittedNominations.Length)
|
||||
{
|
||||
return Results.BadRequest(new { message = "Duplicate nominees are not allowed inside one category." });
|
||||
return Results.BadRequest(new { message = "Duplicate stream links are not allowed inside one category." });
|
||||
}
|
||||
|
||||
var invalidStreamUrl = submittedNominations
|
||||
@@ -93,12 +88,10 @@ public static partial class PublicEndpoints
|
||||
SeasonId = category.SeasonId,
|
||||
CategoryId = category.Id,
|
||||
SubmittedByTwitchId = submitterId,
|
||||
CandidateText = nomination.Name,
|
||||
CandidateText = string.IsNullOrWhiteSpace(nomination.Name) ? null : nomination.Name,
|
||||
StreamUrl = string.IsNullOrWhiteSpace(nomination.StreamUrl) ? null : nomination.StreamUrl,
|
||||
Status = "pending",
|
||||
ReviewNote = string.IsNullOrWhiteSpace(nomination.StreamUrl)
|
||||
? null
|
||||
: $"Stream-Link: {nomination.StreamUrl}",
|
||||
ReviewNote = $"Stream-Link: {nomination.StreamUrl}",
|
||||
CreatedAt = DateTimeOffset.UtcNow,
|
||||
}).ToArray();
|
||||
|
||||
@@ -151,7 +144,7 @@ public static partial class PublicEndpoints
|
||||
return Results.Ok(new { saved = submittedNominations.Length, category = category.Name, collectedSignal = existingNominationCount > 0 });
|
||||
}
|
||||
|
||||
private readonly record struct SubmittedNomination(string Name, string StreamUrl);
|
||||
private readonly record struct SubmittedNomination(string? Name, string StreamUrl);
|
||||
|
||||
private static SubmittedNomination[] NormalizeSubmittedNominations(CreateNominationRequest request)
|
||||
{
|
||||
@@ -167,15 +160,24 @@ public static partial class PublicEndpoints
|
||||
streamUrl = normalizedUrl;
|
||||
}
|
||||
|
||||
return new SubmittedNomination(name, streamUrl);
|
||||
return new SubmittedNomination(string.IsNullOrWhiteSpace(name) ? null : name, streamUrl);
|
||||
})
|
||||
.Where(item => !string.IsNullOrWhiteSpace(item.Name))
|
||||
.Where(item => !string.IsNullOrWhiteSpace(item.StreamUrl))
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
return (request.Nominees ?? [])
|
||||
.Select(item => new SubmittedNomination(item.Trim(), string.Empty))
|
||||
.Where(item => !string.IsNullOrWhiteSpace(item.Name))
|
||||
.Select(item =>
|
||||
{
|
||||
var streamUrl = item.Trim();
|
||||
if (!string.IsNullOrWhiteSpace(streamUrl) && TryNormalizeExternalUrl(streamUrl, out var normalizedUrl))
|
||||
{
|
||||
streamUrl = normalizedUrl;
|
||||
}
|
||||
|
||||
return new SubmittedNomination(null, streamUrl);
|
||||
})
|
||||
.Where(item => !string.IsNullOrWhiteSpace(item.StreamUrl))
|
||||
.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user