fix(controller): update paste expiration check to handle zero expiration case

This commit is contained in:
2026-03-10 19:12:54 -04:00
parent f70328c93d
commit 797747f718
@@ -96,7 +96,7 @@ namespace SharpbinV3.Server.Controllers
public async Task<IActionResult> GetPasteByID(string id) public async Task<IActionResult> GetPasteByID(string id)
{ {
var paste = await _pasteService.Get(id); var paste = await _pasteService.Get(id);
if (paste == null || paste.ExpiresAt < DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()) if (paste == null || paste.ExpiresAt != 0 && paste.ExpiresAt < DateTimeOffset.UtcNow.ToUnixTimeMilliseconds())
return NotFound(new { success = false, message = "Paste not found" }); return NotFound(new { success = false, message = "Paste not found" });
var jwtUser = HttpContext.GetJwtUser(); var jwtUser = HttpContext.GetJwtUser();
@@ -150,7 +150,7 @@ namespace SharpbinV3.Server.Controllers
public async Task<IActionResult> GetRawPasteByID(string id) public async Task<IActionResult> GetRawPasteByID(string id)
{ {
var paste = await _pasteService.Get(id); var paste = await _pasteService.Get(id);
if (paste == null || paste.ExpiresAt < DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()) if (paste == null || paste.ExpiresAt != 0 && paste.ExpiresAt < DateTimeOffset.UtcNow.ToUnixTimeMilliseconds())
return NotFound(); return NotFound();
if (paste.IsCompressed) if (paste.IsCompressed)
Response.Headers.Append("Content-Encoding", "gzip"); Response.Headers.Append("Content-Encoding", "gzip");