Skip to content

Commit

Permalink
Replace CreateFlagCommand with lock
Browse files Browse the repository at this point in the history
  • Loading branch information
mythz committed Aug 20, 2024
1 parent ce51ebc commit 2f21b84
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 23 deletions.
1 change: 0 additions & 1 deletion MyApp.ServiceInterface/AiServerServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public class AiServerServices(ILogger<AiServerServices> log,
QuestionsProvider questions,
RendererCache rendererCache,
WorkerAnswerNotifier answerNotifier,
ICommandExecutor executor,
IBackgroundJobs jobs) : Service
{
public async Task<object> Any(CreateAnswersForModels request)
Expand Down
13 changes: 0 additions & 13 deletions MyApp.ServiceInterface/App/CreateFlagCommand.cs

This file was deleted.

22 changes: 13 additions & 9 deletions MyApp.ServiceInterface/UserServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -324,15 +324,19 @@ public async Task<object> Any(FlagContent request)
return HttpError.NotFound("Does not exist");

var userName = Request.GetClaimsPrincipal().GetUserName();
jobs.RunCommand<CreateFlagCommand>(new Flag {
PostId = postId,
RefId = request.RefId,
UserName = userName,
Type = request.Type,
Reason = request.Reason,
RemoteIp = Request?.RemoteIp,
CreatedDate = DateTime.UtcNow,
});
lock (Locks.AppDb)
{
Db.Insert(new Flag
{
PostId = postId,
RefId = request.RefId,
UserName = userName,
Type = request.Type,
Reason = request.Reason,
RemoteIp = Request?.RemoteIp,
CreatedDate = DateTime.UtcNow,
});
}
return new FlagContent();
}
}

0 comments on commit 2f21b84

Please sign in to comment.