🐛 Bug fixes

This commit is contained in:
2025-07-19 02:49:39 +08:00
parent 57f85ec341
commit e0e1eb76cd
12 changed files with 37 additions and 16 deletions

1
DysonNetwork.Drive/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/Uploads/

View File

@@ -52,10 +52,8 @@
<PackageReference Include="EFCore.BulkExtensions" Version="9.0.1" />
<PackageReference Include="EFCore.BulkExtensions.PostgreSql" Version="9.0.1" />
<PackageReference Include="EFCore.NamingConventions" Version="9.0.0" />
<PackageReference Include="SkiaSharp" Version="3.119.0" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="3.119.0" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="3.119.0" />
<PackageReference Include="SkiaSharp.NativeAssets.macOS" Version="3.119.0" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="2.88.9" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="2.88.9" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="9.0.3" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="9.0.3" />
<PackageReference Include="tusdotnet" Version="2.10.0" />

View File

@@ -18,7 +18,7 @@ public static class ApplicationBuilderExtensions
app.UseAuthorization();
app.MapControllers();
app.MapTus("/tus", _ => Task.FromResult(TusService.BuildConfiguration(tusStore)));
app.MapTus("/api/tus", _ => Task.FromResult(TusService.BuildConfiguration(tusStore, app.Configuration)));
return app;
}

View File

@@ -146,7 +146,11 @@ public class FileService(
{
case "image":
var blurhash =
BlurHashSharp.SkiaSharp.BlurHashEncoder.Encode(xComponent: 3, yComponent: 3, filename: ogFilePath);
BlurHashSharp.SkiaSharp.BlurHashEncoder.Encode(
xComponent: 3,
yComponent: 3,
filename: ogFilePath
);
// Rewind stream
stream.Position = 0;
@@ -160,7 +164,7 @@ public class FileService(
// Try to get orientation from exif data
var orientation = 1;
var meta = new Dictionary<string, object>
var meta = new Dictionary<string, object?>
{
["blur"] = blurhash,
["format"] = format,

View File

@@ -12,7 +12,7 @@ namespace DysonNetwork.Drive.Storage;
public abstract class TusService
{
public static DefaultTusConfiguration BuildConfiguration(ITusStore store) => new()
public static DefaultTusConfiguration BuildConfiguration(ITusStore store, IConfiguration configuration) => new()
{
Store = store,
Events = new Events
@@ -73,6 +73,13 @@ public abstract class TusService
// Dispose the stream after all processing is complete
await fileStream.DisposeAsync();
},
OnCreateCompleteAsync = eventContext =>
{
var gatewayUrl = configuration["GatewayUrl"];
if (gatewayUrl is not null)
eventContext.SetUploadUrl(new Uri(gatewayUrl + "/drive/tus/" + eventContext.FileId));
return Task.CompletedTask;
}
}
};

View File

@@ -1,6 +1,7 @@
{
"Debug": true,
"BaseUrl": "http://localhost:5071",
"GatewayUrl": "http://localhost:5094",
"Logging": {
"LogLevel": {
"Default": "Information",

View File

@@ -79,7 +79,8 @@ public class RegistryProxyConfigProvider : IProxyConfigProvider, IDisposable
{
RouteId = $"direct-{directRoute.Service}-{directRoute.Path.Replace("/", "-")}",
ClusterId = directRoute.Service,
Match = new RouteMatch { Path = directRoute.Path }
Match = new RouteMatch { Path = directRoute.Path },
TimeoutPolicy = directRoute.IsWebsocket ? "Disable" : null
};
routes.Add(route);
_logger.LogInformation(" Added Direct Route: {Path} -> {Service}", directRoute.Path,
@@ -196,10 +197,11 @@ public class RegistryProxyConfigProvider : IProxyConfigProvider, IDisposable
new Microsoft.Extensions.Primitives.CancellationChangeToken(CancellationToken.None);
}
private record DirectRouteConfig
public record DirectRouteConfig
{
public required string Path { get; set; }
public required string Service { get; set; }
public bool IsWebsocket { get; set; } = false;
}
public virtual void Dispose()

View File

@@ -30,7 +30,8 @@
"DirectRoutes": [
{
"Path": "/ws",
"Service": "DysonNetwork.Pusher"
"Service": "DysonNetwork.Pusher",
"IsWebSocket": true
},
{
"Path": "/.well-known/openid-configuration",

View File

@@ -2,11 +2,11 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;
using DysonNetwork.Shared.Data;
using DysonNetwork.Shared.Proto;
using DysonNetwork.Sphere.Post;
using Microsoft.EntityFrameworkCore;
using NodaTime;
using VerificationMark = DysonNetwork.Shared.Data.VerificationMark;
using Account = DysonNetwork.Pass.Account.Account;
namespace DysonNetwork.Sphere.Publisher;

View File

@@ -34,7 +34,7 @@ public class PublisherController(
var account = await accounts.GetAccountAsync(
new GetAccountRequest { Id = publisher.AccountId.Value.ToString() }
);
publisher.Account = account;
publisher.Account = Pass.Account.Account.FromProtoValue(account);
return Ok(publisher);
}

View File

@@ -163,8 +163,12 @@ public class PublisherService(
Name = name ?? account.Name,
Nick = nick ?? account.Nick,
Bio = bio ?? account.Profile.Bio,
Picture = picture ?? CloudFileReferenceObject.FromProtoValue(account.Profile.Picture),
Background = background ?? CloudFileReferenceObject.FromProtoValue(account.Profile.Background),
Picture = picture ?? (account.Profile.Picture is null
? null
: CloudFileReferenceObject.FromProtoValue(account.Profile.Picture)),
Background = background ?? (account.Profile.Background is null
? null
: CloudFileReferenceObject.FromProtoValue(account.Profile.Background)),
AccountId = Guid.Parse(account.Id),
Members = new List<PublisherMember>
{
@@ -191,6 +195,7 @@ public class PublisherService(
}
);
}
if (publisher.Background is not null)
{
await fileRefs.CreateReferenceAsync(
@@ -250,6 +255,7 @@ public class PublisherService(
}
);
}
if (publisher.Background is not null)
{
await fileRefs.CreateReferenceAsync(

View File

@@ -90,6 +90,7 @@
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ARepeatedField_00601_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FLibrary_003FApplication_0020Support_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F331aca3f6f414013b09964063341351379060_003Fc1_003F67c16263_003FRepeatedField_00601_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AResizeOptions_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FLibrary_003FApplication_0020Support_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fef3339e864a448e2b1ec6fa7bbf4c6661fee00_003F48_003F0209e410_003FResizeOptions_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AResourceManagerStringLocalizerFactory_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FLibrary_003FApplication_0020Support_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fb62f365d06c44ad695ff75960cdf97a2a800_003Fe4_003Ff6ba93b7_003FResourceManagerStringLocalizerFactory_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ARouteConfig_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FLibrary_003FApplication_0020Support_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fbf3f51607a3e4e76b5b91640cd7409195c430_003F84_003F98414804_003FRouteConfig_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ARSA_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FLibrary_003FApplication_0020Support_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fee4f989f6b8042b59b2654fdc188e287243600_003F8b_003F44e5f855_003FRSA_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASafeHandle_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FLibrary_003FApplication_0020Support_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fb6f0571a6bc744b0b551fd4578292582e54c00_003F66_003Fde27c365_003FSafeHandle_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASecuritySchemeType_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FLibrary_003FApplication_0020Support_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003F29898ce74e3763a786ac1bd9a6db2152e1af75769440b1e53b9cbdf1dda1bd99_003FSecuritySchemeType_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>