[backend/akko-client] Expose accurate upload limits

This commit is contained in:
Kopper 2024-09-09 16:36:06 +03:00 committed by Iceshrimp development
parent 30af407865
commit 0cb2e9e9f3
2 changed files with 14 additions and 15 deletions

View file

@ -16,7 +16,7 @@ namespace Iceshrimp.Backend.Controllers.Federation;
[Route("/nodeinfo")]
[EnableCors("well-known")]
[Produces(MediaTypeNames.Application.Json)]
public class NodeInfoController(IOptions<Config.InstanceSection> config, DatabaseContext db) : ControllerBase
public class NodeInfoController(IOptions<Config.InstanceSection> instanceConfig, IOptions<Config.StorageSection> storageConfig, DatabaseContext db) : ControllerBase
{
[HttpGet("2.1")]
[HttpGet("2.0")]
@ -25,7 +25,7 @@ public class NodeInfoController(IOptions<Config.InstanceSection> config, Databas
{
var cutoffMonth = DateTime.UtcNow - TimeSpan.FromDays(30);
var cutoffHalfYear = DateTime.UtcNow - TimeSpan.FromDays(180);
var instance = config.Value;
var instance = instanceConfig.Value;
var totalUsers =
await db.Users.LongCountAsync(p => p.IsLocalUser && !Constants.SystemUsers.Contains(p.UsernameLower));
var activeMonth =
@ -37,6 +37,7 @@ public class NodeInfoController(IOptions<Config.InstanceSection> config, Databas
!Constants.SystemUsers.Contains(p.UsernameLower) &&
p.LastActiveDate > cutoffHalfYear);
var localPosts = await db.Notes.LongCountAsync(p => p.UserHost == null);
var maxUploadSize = storageConfig.Value.MaxUploadSizeBytes;
return new NodeInfoResponse
{
@ -91,23 +92,21 @@ public class NodeInfoController(IOptions<Config.InstanceSection> config, Databas
EnableGithubIntegration = false,
EnableDiscordIntegration = false,
EnableEmail = false,
// TODO: STUB
PublicTimelineVisibility = new() {
Bubble = false,
Federated = false,
Local = false,
},
UploadLimits = new() {
General = 50_000_000,
Avatar = 50_000_000,
Background = 50_000_000,
Banner = 50_000_000,
UploadLimits = new() {
General = maxUploadSize,
Avatar = maxUploadSize,
Background = maxUploadSize,
Banner = maxUploadSize,
},
Suggestions = new() {
Suggestions = new() {
Enabled = false
},
Federation = new() {
Federation = new() {
Enabled = true
}
},

View file

@ -133,10 +133,10 @@ public class NodeInfoResponse
public class PleromaUploadLimits
{
[J("general")] public int? General { get; set; }
[J("avatar")] public int? Avatar { get; set; }
[J("background")] public int? Background { get; set; }
[J("banner")] public int? Banner { get; set; }
[J("general")] public long? General { get; set; }
[J("avatar")] public long? Avatar { get; set; }
[J("background")] public long? Background { get; set; }
[J("banner")] public long? Banner { get; set; }
}
public class PleromaSuggestions