feat: update API routes for paste options and recent pastes

This commit is contained in:
2026-01-08 17:31:02 -05:00
parent 5a630d2a71
commit 1f2761f463
6 changed files with 37 additions and 9 deletions
@@ -206,7 +206,28 @@ namespace SharpbinV3.Server.Controllers
}
[HttpGet]
[Route("create/options")]
[Route("recent")]
public async Task<IActionResult> GetRecentPastes()
{
var results = await _pasteService.GetList(0, 50, true);
return Ok(results.Select(p => new
{
p.ID,
p.UUID,
p.Title,
p.Size,
p.TrueSize,
p.IsCompressed,
p.Views,
p.Syntax,
p.Visibility,
p.ExpiresAt,
p.EditedAt
}));
}
[HttpGet]
[Route("info")]
public IActionResult GetCreatePasteOptions()
{
var options = new
+7 -4
View File
@@ -66,12 +66,15 @@ namespace SharpbinV3.Server.Services
}
public async Task<bool> EditText(Paste paste, string text)
{
var compressedData = _cs.Compress(text);
paste.Content = compressedData;
paste.Size = compressedData.Length;
var data = Encoding.UTF8.GetBytes(text);
if (_pasteSettings.EnablePasteCompression)
data = _cs.Compress(text);
paste.Content = data;
paste.Size = data.Length;
paste.TrueSize = Encoding.UTF8.GetByteCount(text);
paste.EditedAt = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
paste.IsCompressed = compressedData.Length < Encoding.UTF8.GetByteCount(text);
paste.IsCompressed = data.Length < Encoding.UTF8.GetByteCount(text);
_db.Pastes.Update(paste);
var result = await _db.SaveChangesAsync();
return result > 0;