Notify performers of API bookings and client-signed estimates
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
fae754f102
commit
f9d95fd98f
13 changed files with 390 additions and 63 deletions
|
|
@ -10,6 +10,8 @@ using Yavsc.Models.Billing;
|
|||
using Yavsc.Models.Relationship;
|
||||
using Yavsc.Models.Workflow;
|
||||
using Yavsc.Server.Helpers;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Services;
|
||||
|
||||
namespace Yavsc.Controllers;
|
||||
|
||||
|
|
@ -19,10 +21,12 @@ namespace Yavsc.Controllers;
|
|||
public class RdvQueryApiController : Controller
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
private readonly IYavscMessageSender _messageSender;
|
||||
|
||||
public RdvQueryApiController(ApplicationDbContext context)
|
||||
public RdvQueryApiController(ApplicationDbContext context, IYavscMessageSender messageSender)
|
||||
{
|
||||
_context = context;
|
||||
_messageSender = messageSender;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
|
|
@ -93,6 +97,16 @@ public class RdvQueryApiController : Controller
|
|||
return BadRequest(new { Error = "location is required" });
|
||||
}
|
||||
|
||||
var performer = await _context.Performers
|
||||
.AsNoTracking()
|
||||
.SingleOrDefaultAsync(p => p.PerformerId == query.PerformerId, cancellationToken);
|
||||
if (performer is null)
|
||||
return BadRequest(new { Error = "performer not found" });
|
||||
var client = await _context.Users.SingleOrDefaultAsync(u => u.Id == uid, cancellationToken);
|
||||
if (client is null)
|
||||
return Unauthorized();
|
||||
query.Client = client;
|
||||
|
||||
var resolvedLocation = await ResolveLocationAsync(query.Location, cancellationToken);
|
||||
if (resolvedLocation is null)
|
||||
{
|
||||
|
|
@ -124,6 +138,9 @@ public class RdvQueryApiController : Controller
|
|||
throw;
|
||||
}
|
||||
|
||||
if (performer.AcceptNotifications && performer.AcceptPublicContact)
|
||||
await _messageSender.NotifyBookQueryAsync(new[] { performer.PerformerId }, query.CreateEvent("NewCommand"));
|
||||
|
||||
return CreatedAtRoute("GetRdvQuery", new { id = query.Id }, query);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue