diff --git a/DysonNetwork.Drive/.gitignore b/DysonNetwork.Drive/.gitignore
new file mode 100644
index 0000000..d11896c
--- /dev/null
+++ b/DysonNetwork.Drive/.gitignore
@@ -0,0 +1 @@
+/Uploads/
\ No newline at end of file
diff --git a/DysonNetwork.Drive/DysonNetwork.Drive.csproj b/DysonNetwork.Drive/DysonNetwork.Drive.csproj
index 1685fbd..b41eb1e 100644
--- a/DysonNetwork.Drive/DysonNetwork.Drive.csproj
+++ b/DysonNetwork.Drive/DysonNetwork.Drive.csproj
@@ -52,10 +52,8 @@
-
-
-
-
+
+
diff --git a/DysonNetwork.Drive/Startup/ApplicationBuilderExtensions.cs b/DysonNetwork.Drive/Startup/ApplicationBuilderExtensions.cs
index ef2896b..b2c41f5 100644
--- a/DysonNetwork.Drive/Startup/ApplicationBuilderExtensions.cs
+++ b/DysonNetwork.Drive/Startup/ApplicationBuilderExtensions.cs
@@ -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;
}
diff --git a/DysonNetwork.Drive/Storage/FileService.cs b/DysonNetwork.Drive/Storage/FileService.cs
index 6131a18..318e7e8 100644
--- a/DysonNetwork.Drive/Storage/FileService.cs
+++ b/DysonNetwork.Drive/Storage/FileService.cs
@@ -50,7 +50,7 @@ public class FileService(
return file;
}
-
+
public async Task> GetFilesAsync(List fileIds)
{
var cachedFiles = new Dictionary();
@@ -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
+ var meta = new Dictionary
{
["blur"] = blurhash,
["format"] = format,
diff --git a/DysonNetwork.Drive/Storage/TusService.cs b/DysonNetwork.Drive/Storage/TusService.cs
index 8f66936..9d9f9ea 100644
--- a/DysonNetwork.Drive/Storage/TusService.cs
+++ b/DysonNetwork.Drive/Storage/TusService.cs
@@ -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;
}
}
};
diff --git a/DysonNetwork.Drive/appsettings.json b/DysonNetwork.Drive/appsettings.json
index df61dbb..78b0850 100644
--- a/DysonNetwork.Drive/appsettings.json
+++ b/DysonNetwork.Drive/appsettings.json
@@ -1,6 +1,7 @@
{
"Debug": true,
"BaseUrl": "http://localhost:5071",
+ "GatewayUrl": "http://localhost:5094",
"Logging": {
"LogLevel": {
"Default": "Information",
diff --git a/DysonNetwork.Gateway/RegistryProxyConfigProvider.cs b/DysonNetwork.Gateway/RegistryProxyConfigProvider.cs
index c7851d2..e399eb4 100644
--- a/DysonNetwork.Gateway/RegistryProxyConfigProvider.cs
+++ b/DysonNetwork.Gateway/RegistryProxyConfigProvider.cs
@@ -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()
diff --git a/DysonNetwork.Gateway/appsettings.json b/DysonNetwork.Gateway/appsettings.json
index 858b693..683c3ab 100644
--- a/DysonNetwork.Gateway/appsettings.json
+++ b/DysonNetwork.Gateway/appsettings.json
@@ -30,7 +30,8 @@
"DirectRoutes": [
{
"Path": "/ws",
- "Service": "DysonNetwork.Pusher"
+ "Service": "DysonNetwork.Pusher",
+ "IsWebSocket": true
},
{
"Path": "/.well-known/openid-configuration",
diff --git a/DysonNetwork.Sphere/Publisher/Publisher.cs b/DysonNetwork.Sphere/Publisher/Publisher.cs
index c8bfc81..b976d62 100644
--- a/DysonNetwork.Sphere/Publisher/Publisher.cs
+++ b/DysonNetwork.Sphere/Publisher/Publisher.cs
@@ -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;
diff --git a/DysonNetwork.Sphere/Publisher/PublisherController.cs b/DysonNetwork.Sphere/Publisher/PublisherController.cs
index f18fba0..80736ad 100644
--- a/DysonNetwork.Sphere/Publisher/PublisherController.cs
+++ b/DysonNetwork.Sphere/Publisher/PublisherController.cs
@@ -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);
}
diff --git a/DysonNetwork.Sphere/Publisher/PublisherService.cs b/DysonNetwork.Sphere/Publisher/PublisherService.cs
index db7300c..c63e6d0 100644
--- a/DysonNetwork.Sphere/Publisher/PublisherService.cs
+++ b/DysonNetwork.Sphere/Publisher/PublisherService.cs
@@ -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
{
@@ -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(
diff --git a/DysonNetwork.sln.DotSettings.user b/DysonNetwork.sln.DotSettings.user
index 6f4a05e..1aded9d 100644
--- a/DysonNetwork.sln.DotSettings.user
+++ b/DysonNetwork.sln.DotSettings.user
@@ -90,6 +90,7 @@
ForceIncluded
ForceIncluded
ForceIncluded
+ ForceIncluded
ForceIncluded
ForceIncluded
ForceIncluded