✨ Able to only remove automated status
This commit is contained in:
@@ -276,15 +276,21 @@ public class AccountCurrentController(
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpDelete("statuses")]
|
[HttpDelete("statuses")]
|
||||||
public async Task<ActionResult> DeleteStatus()
|
public async Task<ActionResult> DeleteStatus([FromQuery] string? app)
|
||||||
{
|
{
|
||||||
if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized();
|
if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized();
|
||||||
|
|
||||||
var now = SystemClock.Instance.GetCurrentInstant();
|
var now = SystemClock.Instance.GetCurrentInstant();
|
||||||
var status = await db.AccountStatuses
|
var queryable = db.AccountStatuses
|
||||||
.Where(s => s.AccountId == currentUser.Id)
|
.Where(s => s.AccountId == currentUser.Id)
|
||||||
.Where(s => s.ClearedAt == null || s.ClearedAt > now)
|
.Where(s => s.ClearedAt == null || s.ClearedAt > now)
|
||||||
.OrderByDescending(s => s.CreatedAt)
|
.OrderByDescending(s => s.CreatedAt)
|
||||||
|
.AsQueryable();
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(app))
|
||||||
|
queryable = queryable.Where(s => s.IsAutomated && s.AppIdentifier == app);
|
||||||
|
|
||||||
|
var status = await queryable
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
if (status is null) return NotFound();
|
if (status is null) return NotFound();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user