[backend/akko-client] Expose accurate upload limits
This commit is contained in:
parent
30af407865
commit
0cb2e9e9f3
2 changed files with 14 additions and 15 deletions
|
@ -16,7 +16,7 @@ namespace Iceshrimp.Backend.Controllers.Federation;
|
||||||
[Route("/nodeinfo")]
|
[Route("/nodeinfo")]
|
||||||
[EnableCors("well-known")]
|
[EnableCors("well-known")]
|
||||||
[Produces(MediaTypeNames.Application.Json)]
|
[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.1")]
|
||||||
[HttpGet("2.0")]
|
[HttpGet("2.0")]
|
||||||
|
@ -25,7 +25,7 @@ public class NodeInfoController(IOptions<Config.InstanceSection> config, Databas
|
||||||
{
|
{
|
||||||
var cutoffMonth = DateTime.UtcNow - TimeSpan.FromDays(30);
|
var cutoffMonth = DateTime.UtcNow - TimeSpan.FromDays(30);
|
||||||
var cutoffHalfYear = DateTime.UtcNow - TimeSpan.FromDays(180);
|
var cutoffHalfYear = DateTime.UtcNow - TimeSpan.FromDays(180);
|
||||||
var instance = config.Value;
|
var instance = instanceConfig.Value;
|
||||||
var totalUsers =
|
var totalUsers =
|
||||||
await db.Users.LongCountAsync(p => p.IsLocalUser && !Constants.SystemUsers.Contains(p.UsernameLower));
|
await db.Users.LongCountAsync(p => p.IsLocalUser && !Constants.SystemUsers.Contains(p.UsernameLower));
|
||||||
var activeMonth =
|
var activeMonth =
|
||||||
|
@ -37,6 +37,7 @@ public class NodeInfoController(IOptions<Config.InstanceSection> config, Databas
|
||||||
!Constants.SystemUsers.Contains(p.UsernameLower) &&
|
!Constants.SystemUsers.Contains(p.UsernameLower) &&
|
||||||
p.LastActiveDate > cutoffHalfYear);
|
p.LastActiveDate > cutoffHalfYear);
|
||||||
var localPosts = await db.Notes.LongCountAsync(p => p.UserHost == null);
|
var localPosts = await db.Notes.LongCountAsync(p => p.UserHost == null);
|
||||||
|
var maxUploadSize = storageConfig.Value.MaxUploadSizeBytes;
|
||||||
|
|
||||||
return new NodeInfoResponse
|
return new NodeInfoResponse
|
||||||
{
|
{
|
||||||
|
@ -91,23 +92,21 @@ public class NodeInfoController(IOptions<Config.InstanceSection> config, Databas
|
||||||
EnableGithubIntegration = false,
|
EnableGithubIntegration = false,
|
||||||
EnableDiscordIntegration = false,
|
EnableDiscordIntegration = false,
|
||||||
EnableEmail = false,
|
EnableEmail = false,
|
||||||
|
|
||||||
// TODO: STUB
|
|
||||||
PublicTimelineVisibility = new() {
|
PublicTimelineVisibility = new() {
|
||||||
Bubble = false,
|
Bubble = false,
|
||||||
Federated = false,
|
Federated = false,
|
||||||
Local = false,
|
Local = false,
|
||||||
},
|
},
|
||||||
UploadLimits = new() {
|
UploadLimits = new() {
|
||||||
General = 50_000_000,
|
General = maxUploadSize,
|
||||||
Avatar = 50_000_000,
|
Avatar = maxUploadSize,
|
||||||
Background = 50_000_000,
|
Background = maxUploadSize,
|
||||||
Banner = 50_000_000,
|
Banner = maxUploadSize,
|
||||||
},
|
},
|
||||||
Suggestions = new() {
|
Suggestions = new() {
|
||||||
Enabled = false
|
Enabled = false
|
||||||
},
|
},
|
||||||
Federation = new() {
|
Federation = new() {
|
||||||
Enabled = true
|
Enabled = true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -133,10 +133,10 @@ public class NodeInfoResponse
|
||||||
|
|
||||||
public class PleromaUploadLimits
|
public class PleromaUploadLimits
|
||||||
{
|
{
|
||||||
[J("general")] public int? General { get; set; }
|
[J("general")] public long? General { get; set; }
|
||||||
[J("avatar")] public int? Avatar { get; set; }
|
[J("avatar")] public long? Avatar { get; set; }
|
||||||
[J("background")] public int? Background { get; set; }
|
[J("background")] public long? Background { get; set; }
|
||||||
[J("banner")] public int? Banner { get; set; }
|
[J("banner")] public long? Banner { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PleromaSuggestions
|
public class PleromaSuggestions
|
||||||
|
|
Loading…
Add table
Reference in a new issue