mirror of
https://github.com/QuotifyTeam/QuotifyBE.git
synced 2025-12-17 08:40:06 +01:00
Compare commits
3 Commits
870fcf7573
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 75beb7a8a1 | |||
| d81a6b961c | |||
| 56bd82f6a2 |
@@ -139,7 +139,7 @@ public class GeneralUseHelpers(ApplicationDbContext db, IConfiguration appsettin
|
||||
{
|
||||
|
||||
string _model = model ?? _appsettings.GetSection("LlmIntegration")["DefaultModel"] ?? "deepclaude";
|
||||
float _temp = temp ?? 0.6f; // sane default
|
||||
float _temp = temp ?? 0.8f; // sane default
|
||||
string _included_sample = string.Empty;
|
||||
string _prompt = prompt ?? _appsettings.GetSection("LlmIntegration")["DefaultPrompt"] ??
|
||||
"Cześć, czy jesteś w stanie wymyślić i stworzyć jeden oryginalny cytat? " +
|
||||
|
||||
@@ -387,6 +387,7 @@ public class QuotesController : ControllerBase
|
||||
// Try to find the quote in question
|
||||
Quote? quote = await _db.Quotes
|
||||
.Include(q => q.QuoteCategories)
|
||||
.Include(q => q.Image)
|
||||
.FirstOrDefaultAsync(q => q.Id == id);
|
||||
|
||||
// Failed?
|
||||
|
||||
@@ -20,6 +20,7 @@ public class UserContentController : ControllerBase
|
||||
private readonly IConfiguration _appsettings;
|
||||
private readonly ApplicationDbContext _db;
|
||||
private readonly GeneralUseHelpers guhf;
|
||||
List<string> _allowedExtensions = new List<string>() { ".jpg", ".jpeg", ".jfif", ".png", ".gif", ".avif", ".webp" };
|
||||
|
||||
public UserContentController(IConfiguration appsettings, ApplicationDbContext db, GeneralUseHelpers GUHF)
|
||||
{
|
||||
@@ -86,15 +87,14 @@ public class UserContentController : ControllerBase
|
||||
}
|
||||
|
||||
// Dozwolone rozszerzenia
|
||||
List<string> allowedExtensions = new List<string>() { ".jpg", ".jpeg", ".jfif", ".png", ".gif", ".avif", ".webp" };
|
||||
string fileExtension = Path.GetExtension(file.FileName).ToLower();
|
||||
|
||||
if (!allowedExtensions.Contains(fileExtension))
|
||||
if (!_allowedExtensions.Contains(fileExtension))
|
||||
{
|
||||
return StatusCode(415, new ErrorDTO
|
||||
{
|
||||
Status = "error",
|
||||
Error_msg = $"Unknown file extension. Allowed: {string.Join(", ", allowedExtensions)}"
|
||||
Error_msg = $"Unknown file extension. Allowed: {string.Join(", ", _allowedExtensions)}"
|
||||
});
|
||||
}
|
||||
|
||||
@@ -149,6 +149,34 @@ public class UserContentController : ControllerBase
|
||||
});
|
||||
}
|
||||
|
||||
// GET /api/v1/uc/restrictions
|
||||
/// <summary>
|
||||
/// [AUTHED] Get server restrictions for file upload
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Returns a list of allowed file extensions and mimetypes for upload.
|
||||
/// </remarks>
|
||||
/// <response code="200">Returned on valid request</response>
|
||||
[HttpGet("restrictions")]
|
||||
[Authorize]
|
||||
[EnableCors]
|
||||
[ProducesResponseType(200)]
|
||||
public IActionResult GetFileUploadRestrictions()
|
||||
{
|
||||
return Ok(new
|
||||
{
|
||||
Status = "ok",
|
||||
AllowedMimeTypes = new List<string>
|
||||
{
|
||||
"image/" // this could be done dynamically ~eee4
|
||||
},
|
||||
AllowedExtensions = _allowedExtensions,
|
||||
MaxFileSize = int.TryParse(_appsettings.GetSection("UserContent")["MaxFileSize"], out int r)
|
||||
? r
|
||||
: 5 * 1024 * 1024
|
||||
});
|
||||
}
|
||||
|
||||
// DELETE /api/v1/uc/images/{id}
|
||||
/// <summary>
|
||||
/// [AUTHED] Delete an image
|
||||
|
||||
@@ -2,8 +2,8 @@ namespace QuotifyBE.DTOs;
|
||||
|
||||
public record class AskLLMInDTO
|
||||
{
|
||||
public string? CustomPrompt { get; set; }
|
||||
public string? Model { get; set; } = "deepclaude";
|
||||
public string? CustomPrompt { get; set; } = null;
|
||||
public string? Model { get; set; } = null;
|
||||
public float? Temperature { get; set; } = 0.8f;
|
||||
public int? CategoryId { get; set; } = null;
|
||||
public bool? UseSampleQuote { get; set; } = false;
|
||||
|
||||
Reference in New Issue
Block a user