Skip to content

Commit

Permalink
fix spam feature not deleting topic if it was the only post
Browse files Browse the repository at this point in the history
  • Loading branch information
adelikat committed Jul 4, 2024
1 parent 5705099 commit 2b02bf3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion TASVideos/Pages/Forum/Posts/Edit.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,13 +244,14 @@ public async Task<IActionResult> OnPostSpam()
return AccessDenied();
}

var postCount = await db.ForumPosts.CountAsync(p => p.TopicId == post.TopicId);

await db.ForumPosts.Where(p => p.Id == Id)
.ExecuteUpdateAsync(b => b
.SetProperty(p => p.TopicId, SiteGlobalConstants.SpamTopicId)
.SetProperty(p => p.ForumId, SiteGlobalConstants.SpamForumId));

bool topicDeleted = false;
var postCount = await db.ForumPosts.CountAsync(p => p.TopicId == post.TopicId);
if (postCount == 1)
{
await db.ForumTopics.Where(t => t.Id == post.TopicId).ExecuteDeleteAsync();
Expand Down

0 comments on commit 2b02bf3

Please sign in to comment.