(string appId, [FromQuery] AppRequestPurpose purpose)
| 452 | } |
| 453 | |
| 454 | [HttpPost("/api/_apps/{appId}/requests/reject")] |
| 455 | public async Task<IActionResult> RejectAppRequest(string appId, [FromQuery] AppRequestPurpose purpose) |
| 456 | { |
| 457 | var user = this.GetCurrentUserIdentity(); |
| 458 | |
| 459 | // check if there's a pending request for this user |
| 460 | var existingRequest = await _db.Connection.QueryFirstOrDefaultAsync<int>( |
| 461 | @"SELECT COUNT(*) FROM app_requests r |
| 462 | INNER JOIN apps a ON a.id = r.app_id |
| 463 | WHERE r.app_id = @appId |
| 464 | AND r.target_user_email = @userEmail |
| 465 | AND r.purpose = @purpose |
| 466 | AND r.status = 'pending' |
| 467 | AND a.deleted_at IS NULL", |
| 468 | new { appId, userEmail = user.Email.ToLower(), purpose = purpose.ToString() }); |
| 469 | |
| 470 | if (existingRequest == 0) |
| 471 | return NotFound("No pending app request found"); |
| 472 | |
| 473 | // mark request as rejected |
| 474 | await _db.Connection.ExecuteAsync(@" |
| 475 | UPDATE app_requests |
| 476 | SET status = 'rejected', completed_at = @completedAt |
| 477 | WHERE app_id = @appId |
| 478 | AND target_user_email = @userEmail |
| 479 | AND purpose = @purpose |
| 480 | AND status = 'pending'", |
| 481 | new { appId, userEmail = user.Email.ToLower(), purpose = purpose.ToString(), completedAt = DateTime.UtcNow }); |
| 482 | |
| 483 | return Ok(new { }); |
| 484 | } |
| 485 | |
| 486 | private async Task<Application?> GetOwnedApp(string appId) |
| 487 | { |
nothing calls this directly
no test coverage detected