♻️ Extract the Storage service to DysonNetwork.Drive microservice

This commit is contained in:
2025-07-06 17:29:26 +08:00
parent 6a3d04af3d
commit 14b79f16f4
71 changed files with 2629 additions and 346 deletions

View File

@ -1,4 +1,5 @@
using System.Text.RegularExpressions;
using DysonNetwork.Common.Interfaces;
using DysonNetwork.Common.Models;
using DysonNetwork.Common.Services;
using DysonNetwork.Sphere.Connection.WebReader;
@ -13,7 +14,7 @@ namespace DysonNetwork.Sphere.Post;
public partial class PostService(
AppDatabase db,
FileReferenceService fileRefService,
IFileReferenceServiceClient fileRefService,
IStringLocalizer<NotificationResource> localizer,
IServiceScopeFactory factory,
FlushBufferService flushBuffer,
@ -135,9 +136,9 @@ public partial class PostService(
foreach (var file in post.Attachments)
{
await fileRefService.CreateReferenceAsync(
file.Id,
file.Id.ToString(),
PostFileUsageIdentifier,
postResourceId
post.ResourceIdentifier
);
}
}
@ -218,12 +219,18 @@ public partial class PostService(
{
var postResourceId = $"post:{post.Id}";
// Update resource references using the new file list
await fileRefService.UpdateResourceFilesAsync(
postResourceId,
attachments,
PostFileUsageIdentifier
);
// Delete existing references for this resource and usage
await fileRefService.DeleteResourceReferencesAsync(post.ResourceIdentifier, PostFileUsageIdentifier);
// Create new references for each file
foreach (var fileId in attachments)
{
await fileRefService.CreateReferenceAsync(
fileId.ToString(),
PostFileUsageIdentifier,
post.ResourceIdentifier
);
}
// Update post attachments by getting files from database
var files = await db.Files