Skip to content

Commit 5671dc2

Browse files
committed
Ban Crypto/Gambling posts
1 parent b650a92 commit 5671dc2

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

TechStacks.ServiceInterface/PostServices.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,16 @@ private async Task InsertCommentTreeAsync(long postId, HackerNewsComment comment
128128

129129
public async Task<CreatePostResponse> Post(CreatePost request)
130130
{
131+
var titleLower = request.Title.ToLower();
132+
if ((titleLower.Contains("crypto") && !titleLower.Contains("cryptography") && !titleLower.Contains("cryptographic"))
133+
|| titleLower.Contains("blockchain")
134+
|| titleLower.Contains("gambling")
135+
|| titleLower.Contains("casino"))
136+
{
137+
log.LogInformation("Banning post with title: {Title}", request.Title);
138+
throw new ArgumentException("Crypto and Gaming related content is not allowed", nameof(request.Title));
139+
}
140+
131141
var user = GetUser();
132142
AssertCanPostToOrganization(Db, request.OrganizationId, user, out var org, out var orgMember);
133143
AssertCanPostTypeToOrganization(request.Type, org, orgMember, user);

TechStacks.ServiceModel/Posts.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public class CreatePost : IReturn<CreatePostResponse>, IPost
4747

4848
public int CategoryId { get; set; }
4949

50+
[ValidateNotEmpty]
5051
public string Title { get; set; }
5152

5253
[Index]

0 commit comments

Comments
 (0)