Skip to content

Commit

Permalink
sync
Browse files Browse the repository at this point in the history
  • Loading branch information
mythz committed Sep 6, 2023
1 parent c54c8dd commit 6e2d3e8
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
21 changes: 20 additions & 1 deletion BlazorDiffusion.ServiceInterface/CreativeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using Microsoft.AspNetCore.Mvc.RazorPages;
using ServiceStack;
using ServiceStack.Auth;
using ServiceStack.Html;
using ServiceStack.IO;
using ServiceStack.Logging;
using ServiceStack.OrmLite;
Expand Down Expand Up @@ -70,6 +69,26 @@ public async Task<object> Post(CreateCreative request)
{
var session = await SessionAsAsync<CustomUserSession>();
var userId = session.GetUserId();
var userAuth = (AppUser)await AuthRepositoryAsync.GetUserAuthAsync(session.UserAuthId);

var requestLower = request.UserPrompt.ToLower();
foreach (var banWord in AppConfig.Instance.BanWords)
{
if (requestLower.Contains(banWord))
{
if (userAuth.LockedDate == null)
{
userAuth.LockedDate = DateTime.UtcNow;
await AuthRepositoryAsync.SaveUserAuthAsync(userAuth);
}
break;
}
}
if (userAuth.LockedDate != null)
{
throw HttpError.Forbidden("Account is locked");
}

var userRoles = await session.GetRolesAsync(AuthRepositoryAsync);

var modifiers = await Db.SelectAsync<Modifier>(x => Sql.In(x.Id, request.ModifierIds));
Expand Down
7 changes: 7 additions & 0 deletions BlazorDiffusion.ServiceModel/AppConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ public class AppConfig
public string R2Account { get; set; }
public string AssetsBasePath { get; set; }
public string FallbackAssetsBasePath { get; set; }
public HashSet<string> BanWords { get; set; } = new(StringComparer.OrdinalIgnoreCase)
{
"panties",
"breasts",
"hispanic",
};

/// <summary>
/// Ignore saving creatives + pre-rendering pages to avoid Hot Reload reloading page
/// </summary>
Expand Down
9 changes: 9 additions & 0 deletions BlazorDiffusion.ServiceModel/Creatives.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.Serialization;
using ServiceStack;
using ServiceStack.DataAnnotations;

Expand Down Expand Up @@ -65,6 +66,14 @@ public class QueryCreatives : QueryDb<Creative>
public int? OwnerId { get; set; }
}

[Route("/creatives")]
[DataContract]
public class Creatives : IReturn<Creatives>
{
[DataMember]
public List<Creative> Items { get; set; }
}

[Tag(Tag.Creatives)]
public class GetCreative : IGet, IReturn<GetCreativeResponse>
{
Expand Down

0 comments on commit 6e2d3e8

Please sign in to comment.