using Iceshrimp.Backend.Core.Database; using Iceshrimp.Backend.Core.Database.Tables; using Iceshrimp.Backend.Core.Middleware; using Iceshrimp.Backend.Core.Services; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.EntityFrameworkCore; namespace Iceshrimp.Backend.Pages; public class QueueJobModel(DatabaseContext db) : PageModel { public Job Job = null!; public async Task OnGet([FromRoute] Guid id) { if (!Request.Cookies.TryGetValue("admin_session", out var cookie)) return Redirect("/login"); if (!await db.Sessions.AnyAsync(p => p.Token == cookie && p.Active && p.User.IsAdmin)) return Redirect("/login"); Job = await db.Jobs.FirstOrDefaultAsync(p => p.Id == id) ?? throw GracefulException.NotFound($"Job {id} not found"); return Page(); } }