diff --git a/DysonNetwork.Develop/AppDatabase.cs b/DysonNetwork.Develop/AppDatabase.cs index a74cead..83e3181 100644 --- a/DysonNetwork.Develop/AppDatabase.cs +++ b/DysonNetwork.Develop/AppDatabase.cs @@ -1,6 +1,5 @@ using System.Text.Json; -using DysonNetwork.Develop.Identity; -using DysonNetwork.Develop.Project; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Design; @@ -11,13 +10,13 @@ public class AppDatabase( IConfiguration configuration ) : DbContext(options) { - public DbSet Developers { get; set; } = null!; + public DbSet Developers { get; set; } = null!; - public DbSet DevProjects { get; set; } = null!; + public DbSet DevProjects { get; set; } = null!; - public DbSet CustomApps { get; set; } = null!; - public DbSet CustomAppSecrets { get; set; } = null!; - public DbSet BotAccounts { get; set; } = null!; + public DbSet CustomApps { get; set; } = null!; + public DbSet CustomAppSecrets { get; set; } = null!; + public DbSet BotAccounts { get; set; } = null!; protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { diff --git a/DysonNetwork.Develop/Identity/BotAccountController.cs b/DysonNetwork.Develop/Identity/BotAccountController.cs index e7663d6..ec82048 100644 --- a/DysonNetwork.Develop/Identity/BotAccountController.cs +++ b/DysonNetwork.Develop/Identity/BotAccountController.cs @@ -1,6 +1,7 @@ using System.ComponentModel.DataAnnotations; using DysonNetwork.Develop.Project; using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using DysonNetwork.Shared.Proto; using DysonNetwork.Shared.Registry; using Grpc.Core; @@ -436,7 +437,7 @@ public class BotAccountController( } } - private async Task<(Developer?, DevProject?, BotAccount?)> ValidateBotAccess( + private async Task<(SnDeveloper?, SnDevProject?, BotAccount?)> ValidateBotAccess( string pubName, Guid projectId, Guid botId, diff --git a/DysonNetwork.Develop/Identity/BotAccountPublicController.cs b/DysonNetwork.Develop/Identity/BotAccountPublicController.cs index 75c00af..6fb04b0 100644 --- a/DysonNetwork.Develop/Identity/BotAccountPublicController.cs +++ b/DysonNetwork.Develop/Identity/BotAccountPublicController.cs @@ -1,3 +1,4 @@ +using DysonNetwork.Shared.Models; using Microsoft.AspNetCore.Mvc; namespace DysonNetwork.Develop.Identity; @@ -7,7 +8,7 @@ namespace DysonNetwork.Develop.Identity; public class BotAccountPublicController(BotAccountService botService, DeveloperService developerService) : ControllerBase { [HttpGet("{botId:guid}")] - public async Task> GetBotTransparentInfo([FromRoute] Guid botId) + public async Task> GetBotTransparentInfo([FromRoute] Guid botId) { var bot = await botService.GetBotByIdAsync(botId); if (bot is null) return NotFound("Bot not found"); @@ -21,7 +22,7 @@ public class BotAccountPublicController(BotAccountService botService, DeveloperS } [HttpGet("{botId:guid}/developer")] - public async Task> GetBotDeveloper([FromRoute] Guid botId) + public async Task> GetBotDeveloper([FromRoute] Guid botId) { var bot = await botService.GetBotByIdAsync(botId); if (bot is null) return NotFound("Bot not found"); diff --git a/DysonNetwork.Develop/Identity/BotAccountService.cs b/DysonNetwork.Develop/Identity/BotAccountService.cs index 70fbf48..5deddc3 100644 --- a/DysonNetwork.Develop/Identity/BotAccountService.cs +++ b/DysonNetwork.Develop/Identity/BotAccountService.cs @@ -1,5 +1,5 @@ -using DysonNetwork.Develop.Project; using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using DysonNetwork.Shared.Proto; using DysonNetwork.Shared.Registry; using Grpc.Core; @@ -29,7 +29,7 @@ public class BotAccountService( } public async Task CreateBotAsync( - DevProject project, + SnDevProject project, string slug, Account account, string? pictureId, @@ -165,7 +165,7 @@ public class BotAccountService( foreach (var bot in bots) { bot.Account = data - .Select(AccountReference.FromProtoValue) + .Select(SnAccount.FromProtoValue) .FirstOrDefault(e => e.AutomatedId == bot.Id); } diff --git a/DysonNetwork.Develop/Identity/CustomAppController.cs b/DysonNetwork.Develop/Identity/CustomAppController.cs index 49c07bb..c6cd253 100644 --- a/DysonNetwork.Develop/Identity/CustomAppController.cs +++ b/DysonNetwork.Develop/Identity/CustomAppController.cs @@ -1,5 +1,6 @@ using System.ComponentModel.DataAnnotations; using DysonNetwork.Develop.Project; +using DysonNetwork.Shared.Models; using DysonNetwork.Shared.Proto; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; diff --git a/DysonNetwork.Develop/Identity/CustomAppService.cs b/DysonNetwork.Develop/Identity/CustomAppService.cs index 313d0df..29fd7c1 100644 --- a/DysonNetwork.Develop/Identity/CustomAppService.cs +++ b/DysonNetwork.Develop/Identity/CustomAppService.cs @@ -1,5 +1,5 @@ using DysonNetwork.Develop.Project; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using DysonNetwork.Shared.Proto; using Microsoft.EntityFrameworkCore; using System.Security.Cryptography; @@ -46,7 +46,7 @@ public class CustomAppService( ); if (picture is null) throw new InvalidOperationException("Invalid picture id, unable to find the file on cloud."); - app.Picture = CloudFileReferenceObject.FromProtoValue(picture); + app.Picture = SnCloudFileReferenceObject.FromProtoValue(picture); // Create a new reference await fileRefs.CreateReferenceAsync( @@ -65,7 +65,7 @@ public class CustomAppService( ); if (background is null) throw new InvalidOperationException("Invalid picture id, unable to find the file on cloud."); - app.Background = CloudFileReferenceObject.FromProtoValue(background); + app.Background = SnCloudFileReferenceObject.FromProtoValue(background); // Create a new reference await fileRefs.CreateReferenceAsync( @@ -209,7 +209,7 @@ public class CustomAppService( ); if (picture is null) throw new InvalidOperationException("Invalid picture id, unable to find the file on cloud."); - app.Picture = CloudFileReferenceObject.FromProtoValue(picture); + app.Picture = SnCloudFileReferenceObject.FromProtoValue(picture); // Create a new reference await fileRefs.CreateReferenceAsync( @@ -228,7 +228,7 @@ public class CustomAppService( ); if (background is null) throw new InvalidOperationException("Invalid picture id, unable to find the file on cloud."); - app.Background = CloudFileReferenceObject.FromProtoValue(background); + app.Background = SnCloudFileReferenceObject.FromProtoValue(background); // Create a new reference await fileRefs.CreateReferenceAsync( diff --git a/DysonNetwork.Develop/Identity/CustomAppServiceGrpc.cs b/DysonNetwork.Develop/Identity/CustomAppServiceGrpc.cs index bbe1561..d13660b 100644 --- a/DysonNetwork.Develop/Identity/CustomAppServiceGrpc.cs +++ b/DysonNetwork.Develop/Identity/CustomAppServiceGrpc.cs @@ -1,3 +1,4 @@ +using DysonNetwork.Shared.Models; using DysonNetwork.Shared.Proto; using Grpc.Core; using Microsoft.EntityFrameworkCore; diff --git a/DysonNetwork.Develop/Identity/Developer.cs b/DysonNetwork.Develop/Identity/Developer.cs deleted file mode 100644 index ef618aa..0000000 --- a/DysonNetwork.Develop/Identity/Developer.cs +++ /dev/null @@ -1,79 +0,0 @@ -using System.ComponentModel.DataAnnotations.Schema; -using System.Text.Json.Serialization; -using DysonNetwork.Develop.Project; -using DysonNetwork.Shared.Proto; -using DysonNetwork.Shared.Data; -using VerificationMark = DysonNetwork.Shared.Data.VerificationMark; - -namespace DysonNetwork.Develop.Identity; - -public class Developer -{ - public Guid Id { get; set; } = Guid.NewGuid(); - public Guid PublisherId { get; set; } - - [JsonIgnore] public List Projects { get; set; } = []; - - [NotMapped] public PublisherInfo? Publisher { get; set; } -} - -public class PublisherInfo -{ - public Guid Id { get; set; } - public PublisherType Type { get; set; } - public string Name { get; set; } = string.Empty; - public string Nick { get; set; } = string.Empty; - public string? Bio { get; set; } - - public CloudFileReferenceObject? Picture { get; set; } - public CloudFileReferenceObject? Background { get; set; } - - public VerificationMark? Verification { get; set; } - public Guid? AccountId { get; set; } - public Guid? RealmId { get; set; } - - public static PublisherInfo FromProto(Publisher proto) - { - var info = new PublisherInfo - { - Id = Guid.Parse(proto.Id), - Type = proto.Type == PublisherType.PubIndividual - ? PublisherType.PubIndividual - : PublisherType.PubOrganizational, - Name = proto.Name, - Nick = proto.Nick, - Bio = string.IsNullOrEmpty(proto.Bio) ? null : proto.Bio, - Verification = proto.VerificationMark is not null - ? VerificationMark.FromProtoValue(proto.VerificationMark) - : null, - AccountId = string.IsNullOrEmpty(proto.AccountId) ? null : Guid.Parse(proto.AccountId), - RealmId = string.IsNullOrEmpty(proto.RealmId) ? null : Guid.Parse(proto.RealmId) - }; - - if (proto.Picture != null) - { - info.Picture = new CloudFileReferenceObject - { - Id = proto.Picture.Id, - Name = proto.Picture.Name, - MimeType = proto.Picture.MimeType, - Hash = proto.Picture.Hash, - Size = proto.Picture.Size - }; - } - - if (proto.Background != null) - { - info.Background = new CloudFileReferenceObject - { - Id = proto.Background.Id, - Name = proto.Background.Name, - MimeType = proto.Background.MimeType, - Hash = proto.Background.Hash, - Size = (long)proto.Background.Size - }; - } - - return info; - } -} \ No newline at end of file diff --git a/DysonNetwork.Develop/Identity/DeveloperController.cs b/DysonNetwork.Develop/Identity/DeveloperController.cs index 137ef0d..b904732 100644 --- a/DysonNetwork.Develop/Identity/DeveloperController.cs +++ b/DysonNetwork.Develop/Identity/DeveloperController.cs @@ -1,4 +1,5 @@ using DysonNetwork.Shared.Auth; +using DysonNetwork.Shared.Models; using DysonNetwork.Shared.Proto; using Grpc.Core; using Microsoft.AspNetCore.Authorization; @@ -18,7 +19,7 @@ public class DeveloperController( : ControllerBase { [HttpGet("{name}")] - public async Task> GetDeveloper(string name) + public async Task> GetDeveloper(string name) { var developer = await ds.GetDeveloperByName(name); if (developer is null) return NotFound(); @@ -47,7 +48,7 @@ public class DeveloperController( [HttpGet] [Authorize] - public async Task>> ListJoinedDevelopers() + public async Task>> ListJoinedDevelopers() { if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized(); @@ -69,7 +70,7 @@ public class DeveloperController( [HttpPost("{name}/enroll")] [Authorize] [RequiredPermission("global", "developers.create")] - public async Task> EnrollDeveloperProgram(string name) + public async Task> EnrollDeveloperProgram(string name) { if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized(); var accountId = Guid.Parse(currentUser.Id); @@ -96,7 +97,7 @@ public class DeveloperController( var hasDeveloper = await db.Developers.AnyAsync(d => d.PublisherId == pub.Id); if (hasDeveloper) return BadRequest("Publisher is already in the developer program"); - var developer = new Developer + var developer = new SnDeveloper { Id = Guid.NewGuid(), PublisherId = pub.Id diff --git a/DysonNetwork.Develop/Identity/DeveloperService.cs b/DysonNetwork.Develop/Identity/DeveloperService.cs index 72b5611..7bc2960 100644 --- a/DysonNetwork.Develop/Identity/DeveloperService.cs +++ b/DysonNetwork.Develop/Identity/DeveloperService.cs @@ -1,3 +1,4 @@ +using DysonNetwork.Shared.Models; using DysonNetwork.Shared.Proto; using Grpc.Core; using Microsoft.EntityFrameworkCore; @@ -9,7 +10,7 @@ public class DeveloperService( PublisherService.PublisherServiceClient ps, ILogger logger) { - public async Task LoadDeveloperPublisher(Developer developer) + public async Task LoadDeveloperPublisher(SnDeveloper developer) { var pubResponse = await ps.GetPublisherAsync(new GetPublisherRequest { Id = developer.PublisherId.ToString() }); developer.Publisher = PublisherInfo.FromProto(pubResponse.Publisher); @@ -17,7 +18,7 @@ public class DeveloperService( } - public async Task> LoadDeveloperPublisher(IEnumerable developers) + public async Task> LoadDeveloperPublisher(IEnumerable developers) { var enumerable = developers.ToList(); var pubIds = enumerable.Select(d => d.PublisherId).ToList(); @@ -33,7 +34,7 @@ public class DeveloperService( }); } - public async Task GetDeveloperByName(string name) + public async Task GetDeveloperByName(string name) { try { @@ -50,7 +51,7 @@ public class DeveloperService( } } - public async Task GetDeveloperById(Guid id) + public async Task GetDeveloperById(Guid id) { return await db.Developers.FirstOrDefaultAsync(d => d.Id == id); } diff --git a/DysonNetwork.Develop/Migrations/20250807133702_InitialMigration.Designer.cs b/DysonNetwork.Develop/Migrations/20250807133702_InitialMigration.Designer.cs index b181d32..a27793c 100644 --- a/DysonNetwork.Develop/Migrations/20250807133702_InitialMigration.Designer.cs +++ b/DysonNetwork.Develop/Migrations/20250807133702_InitialMigration.Designer.cs @@ -1,8 +1,7 @@ // using System; using DysonNetwork.Develop; -using DysonNetwork.Develop.Identity; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -35,7 +34,7 @@ namespace DysonNetwork.Develop.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -70,7 +69,7 @@ namespace DysonNetwork.Develop.Migrations .HasColumnType("jsonb") .HasColumnName("oauth_config"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -88,7 +87,7 @@ namespace DysonNetwork.Develop.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); diff --git a/DysonNetwork.Develop/Migrations/20250807133702_InitialMigration.cs b/DysonNetwork.Develop/Migrations/20250807133702_InitialMigration.cs index 0714885..1c85364 100644 --- a/DysonNetwork.Develop/Migrations/20250807133702_InitialMigration.cs +++ b/DysonNetwork.Develop/Migrations/20250807133702_InitialMigration.cs @@ -1,6 +1,5 @@ using System; -using DysonNetwork.Develop.Identity; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore.Migrations; using NodaTime; @@ -35,9 +34,9 @@ namespace DysonNetwork.Develop.Migrations name = table.Column(type: "character varying(1024)", maxLength: 1024, nullable: false), description = table.Column(type: "character varying(4096)", maxLength: 4096, nullable: true), status = table.Column(type: "integer", nullable: false), - picture = table.Column(type: "jsonb", nullable: true), - background = table.Column(type: "jsonb", nullable: true), - verification = table.Column(type: "jsonb", nullable: true), + picture = table.Column(type: "jsonb", nullable: true), + background = table.Column(type: "jsonb", nullable: true), + verification = table.Column(type: "jsonb", nullable: true), oauth_config = table.Column(type: "jsonb", nullable: true), links = table.Column(type: "jsonb", nullable: true), developer_id = table.Column(type: "uuid", nullable: false), diff --git a/DysonNetwork.Develop/Migrations/20250818124844_AddDevProject.Designer.cs b/DysonNetwork.Develop/Migrations/20250818124844_AddDevProject.Designer.cs index b5c34a9..e802348 100644 --- a/DysonNetwork.Develop/Migrations/20250818124844_AddDevProject.Designer.cs +++ b/DysonNetwork.Develop/Migrations/20250818124844_AddDevProject.Designer.cs @@ -1,8 +1,7 @@ // using System; using DysonNetwork.Develop; -using DysonNetwork.Develop.Identity; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -35,7 +34,7 @@ namespace DysonNetwork.Develop.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -66,7 +65,7 @@ namespace DysonNetwork.Develop.Migrations .HasColumnType("jsonb") .HasColumnName("oauth_config"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -88,7 +87,7 @@ namespace DysonNetwork.Develop.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); diff --git a/DysonNetwork.Develop/Migrations/20250819163227_AddBotAccount.Designer.cs b/DysonNetwork.Develop/Migrations/20250819163227_AddBotAccount.Designer.cs index a01e413..c06e883 100644 --- a/DysonNetwork.Develop/Migrations/20250819163227_AddBotAccount.Designer.cs +++ b/DysonNetwork.Develop/Migrations/20250819163227_AddBotAccount.Designer.cs @@ -1,8 +1,7 @@ // using System; using DysonNetwork.Develop; -using DysonNetwork.Develop.Identity; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -77,7 +76,7 @@ namespace DysonNetwork.Develop.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -108,7 +107,7 @@ namespace DysonNetwork.Develop.Migrations .HasColumnType("jsonb") .HasColumnName("oauth_config"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -130,7 +129,7 @@ namespace DysonNetwork.Develop.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); diff --git a/DysonNetwork.Develop/Migrations/AppDatabaseModelSnapshot.cs b/DysonNetwork.Develop/Migrations/AppDatabaseModelSnapshot.cs index 3bd4069..1468032 100644 --- a/DysonNetwork.Develop/Migrations/AppDatabaseModelSnapshot.cs +++ b/DysonNetwork.Develop/Migrations/AppDatabaseModelSnapshot.cs @@ -1,8 +1,7 @@ // using System; using DysonNetwork.Develop; -using DysonNetwork.Develop.Identity; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; @@ -74,7 +73,7 @@ namespace DysonNetwork.Develop.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -105,7 +104,7 @@ namespace DysonNetwork.Develop.Migrations .HasColumnType("jsonb") .HasColumnName("oauth_config"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -127,7 +126,7 @@ namespace DysonNetwork.Develop.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); diff --git a/DysonNetwork.Develop/Project/DevProjectService.cs b/DysonNetwork.Develop/Project/DevProjectService.cs index 5bd27cf..9c387fa 100644 --- a/DysonNetwork.Develop/Project/DevProjectService.cs +++ b/DysonNetwork.Develop/Project/DevProjectService.cs @@ -1,6 +1,6 @@ -using DysonNetwork.Develop.Identity; using Microsoft.EntityFrameworkCore; using DysonNetwork.Shared.Proto; +using DysonNetwork.Shared.Models; namespace DysonNetwork.Develop.Project; @@ -10,12 +10,12 @@ public class DevProjectService( FileService.FileServiceClient files ) { - public async Task CreateProjectAsync( - Developer developer, + public async Task CreateProjectAsync( + SnDeveloper developer, DevProjectController.DevProjectRequest request ) { - var project = new DevProject + var project = new SnDevProject { Slug = request.Slug!, Name = request.Name!, @@ -29,7 +29,7 @@ public class DevProjectService( return project; } - public async Task GetProjectAsync(Guid id, Guid? developerId = null) + public async Task GetProjectAsync(Guid id, Guid? developerId = null) { var query = db.DevProjects.AsQueryable(); @@ -41,14 +41,14 @@ public class DevProjectService( return await query.FirstOrDefaultAsync(p => p.Id == id); } - public async Task> GetProjectsByDeveloperAsync(Guid developerId) + public async Task> GetProjectsByDeveloperAsync(Guid developerId) { return await db.DevProjects .Where(p => p.DeveloperId == developerId) .ToListAsync(); } - public async Task UpdateProjectAsync( + public async Task UpdateProjectAsync( Guid id, Guid developerId, DevProjectController.DevProjectRequest request diff --git a/DysonNetwork.Drive/AppDatabase.cs b/DysonNetwork.Drive/AppDatabase.cs index 47f31bc..c4a12af 100644 --- a/DysonNetwork.Drive/AppDatabase.cs +++ b/DysonNetwork.Drive/AppDatabase.cs @@ -1,8 +1,8 @@ using System.Linq.Expressions; using System.Reflection; using DysonNetwork.Drive.Billing; -using DysonNetwork.Drive.Storage; using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Design; using Microsoft.EntityFrameworkCore.Query; @@ -17,11 +17,11 @@ public class AppDatabase( ) : DbContext(options) { public DbSet Pools { get; set; } = null!; - public DbSet Bundles { get; set; } = null!; + public DbSet Bundles { get; set; } = null!; public DbSet QuotaRecords { get; set; } = null!; - public DbSet Files { get; set; } = null!; + public DbSet Files { get; set; } = null!; public DbSet FileReferences { get; set; } = null!; protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) diff --git a/DysonNetwork.Drive/Billing/Quota.cs b/DysonNetwork.Drive/Billing/Quota.cs index 4a4d611..6246448 100644 --- a/DysonNetwork.Drive/Billing/Quota.cs +++ b/DysonNetwork.Drive/Billing/Quota.cs @@ -1,4 +1,5 @@ using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using NodaTime; namespace DysonNetwork.Drive.Billing; diff --git a/DysonNetwork.Drive/Migrations/20250713121317_InitialMigration.Designer.cs b/DysonNetwork.Drive/Migrations/20250713121317_InitialMigration.Designer.cs index 6a7a144..44374be 100644 --- a/DysonNetwork.Drive/Migrations/20250713121317_InitialMigration.Designer.cs +++ b/DysonNetwork.Drive/Migrations/20250713121317_InitialMigration.Designer.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; using DysonNetwork.Drive; using DysonNetwork.Drive.Storage; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; diff --git a/DysonNetwork.Drive/Migrations/20250713121317_InitialMigration.cs b/DysonNetwork.Drive/Migrations/20250713121317_InitialMigration.cs index 54aa9f2..8f3e7e8 100644 --- a/DysonNetwork.Drive/Migrations/20250713121317_InitialMigration.cs +++ b/DysonNetwork.Drive/Migrations/20250713121317_InitialMigration.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; using DysonNetwork.Drive.Storage; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore.Migrations; using NodaTime; diff --git a/DysonNetwork.Drive/Migrations/20250715080004_ReinitalMigration.Designer.cs b/DysonNetwork.Drive/Migrations/20250715080004_ReinitalMigration.Designer.cs index a450ff7..f693b0b 100644 --- a/DysonNetwork.Drive/Migrations/20250715080004_ReinitalMigration.Designer.cs +++ b/DysonNetwork.Drive/Migrations/20250715080004_ReinitalMigration.Designer.cs @@ -2,7 +2,7 @@ using System; using System.Collections.Generic; using DysonNetwork.Drive; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; diff --git a/DysonNetwork.Drive/Migrations/20250726103203_AddCloudFilePool.Designer.cs b/DysonNetwork.Drive/Migrations/20250726103203_AddCloudFilePool.Designer.cs index b08c290..45d6a4d 100644 --- a/DysonNetwork.Drive/Migrations/20250726103203_AddCloudFilePool.Designer.cs +++ b/DysonNetwork.Drive/Migrations/20250726103203_AddCloudFilePool.Designer.cs @@ -2,8 +2,7 @@ using System; using System.Collections.Generic; using DysonNetwork.Drive; -using DysonNetwork.Drive.Storage; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; diff --git a/DysonNetwork.Drive/Migrations/20250726103203_AddCloudFilePool.cs b/DysonNetwork.Drive/Migrations/20250726103203_AddCloudFilePool.cs index d06532f..e8c11fa 100644 --- a/DysonNetwork.Drive/Migrations/20250726103203_AddCloudFilePool.cs +++ b/DysonNetwork.Drive/Migrations/20250726103203_AddCloudFilePool.cs @@ -1,6 +1,6 @@ using System; using System.Collections.Generic; -using DysonNetwork.Drive.Storage; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore.Migrations; using NodaTime; diff --git a/DysonNetwork.Drive/Migrations/20250726120323_AddFilePoolDescription.Designer.cs b/DysonNetwork.Drive/Migrations/20250726120323_AddFilePoolDescription.Designer.cs index 7483097..2ce60bf 100644 --- a/DysonNetwork.Drive/Migrations/20250726120323_AddFilePoolDescription.Designer.cs +++ b/DysonNetwork.Drive/Migrations/20250726120323_AddFilePoolDescription.Designer.cs @@ -2,8 +2,7 @@ using System; using System.Collections.Generic; using DysonNetwork.Drive; -using DysonNetwork.Drive.Storage; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; diff --git a/DysonNetwork.Drive/Migrations/20250726172039_AddCloudFileExpiration.Designer.cs b/DysonNetwork.Drive/Migrations/20250726172039_AddCloudFileExpiration.Designer.cs index b99df8b..668e4c8 100644 --- a/DysonNetwork.Drive/Migrations/20250726172039_AddCloudFileExpiration.Designer.cs +++ b/DysonNetwork.Drive/Migrations/20250726172039_AddCloudFileExpiration.Designer.cs @@ -2,8 +2,7 @@ using System; using System.Collections.Generic; using DysonNetwork.Drive; -using DysonNetwork.Drive.Storage; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; diff --git a/DysonNetwork.Drive/Migrations/20250727092028_AddQuotaRecord.Designer.cs b/DysonNetwork.Drive/Migrations/20250727092028_AddQuotaRecord.Designer.cs index 42f0a28..d5fcf73 100644 --- a/DysonNetwork.Drive/Migrations/20250727092028_AddQuotaRecord.Designer.cs +++ b/DysonNetwork.Drive/Migrations/20250727092028_AddQuotaRecord.Designer.cs @@ -2,8 +2,7 @@ using System; using System.Collections.Generic; using DysonNetwork.Drive; -using DysonNetwork.Drive.Storage; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; diff --git a/DysonNetwork.Drive/Migrations/20250727130951_AddFileBundle.Designer.cs b/DysonNetwork.Drive/Migrations/20250727130951_AddFileBundle.Designer.cs index 1a5879b..69573e7 100644 --- a/DysonNetwork.Drive/Migrations/20250727130951_AddFileBundle.Designer.cs +++ b/DysonNetwork.Drive/Migrations/20250727130951_AddFileBundle.Designer.cs @@ -2,8 +2,7 @@ using System; using System.Collections.Generic; using DysonNetwork.Drive; -using DysonNetwork.Drive.Storage; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; diff --git a/DysonNetwork.Drive/Migrations/20250808170904_AddHiddenPool.Designer.cs b/DysonNetwork.Drive/Migrations/20250808170904_AddHiddenPool.Designer.cs index 6a78213..10c2390 100644 --- a/DysonNetwork.Drive/Migrations/20250808170904_AddHiddenPool.Designer.cs +++ b/DysonNetwork.Drive/Migrations/20250808170904_AddHiddenPool.Designer.cs @@ -2,8 +2,7 @@ using System; using System.Collections.Generic; using DysonNetwork.Drive; -using DysonNetwork.Drive.Storage; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; diff --git a/DysonNetwork.Drive/Migrations/20250819164302_RemoveUploadedTo.Designer.cs b/DysonNetwork.Drive/Migrations/20250819164302_RemoveUploadedTo.Designer.cs index a967531..e50dff0 100644 --- a/DysonNetwork.Drive/Migrations/20250819164302_RemoveUploadedTo.Designer.cs +++ b/DysonNetwork.Drive/Migrations/20250819164302_RemoveUploadedTo.Designer.cs @@ -2,8 +2,7 @@ using System; using System.Collections.Generic; using DysonNetwork.Drive; -using DysonNetwork.Drive.Storage; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; diff --git a/DysonNetwork.Drive/Migrations/20250907070034_RemoveNetTopo.Designer.cs b/DysonNetwork.Drive/Migrations/20250907070034_RemoveNetTopo.Designer.cs index b97a6d2..079a1a6 100644 --- a/DysonNetwork.Drive/Migrations/20250907070034_RemoveNetTopo.Designer.cs +++ b/DysonNetwork.Drive/Migrations/20250907070034_RemoveNetTopo.Designer.cs @@ -2,8 +2,7 @@ using System; using System.Collections.Generic; using DysonNetwork.Drive; -using DysonNetwork.Drive.Storage; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; diff --git a/DysonNetwork.Drive/Migrations/AppDatabaseModelSnapshot.cs b/DysonNetwork.Drive/Migrations/AppDatabaseModelSnapshot.cs index 590e663..8ffcd23 100644 --- a/DysonNetwork.Drive/Migrations/AppDatabaseModelSnapshot.cs +++ b/DysonNetwork.Drive/Migrations/AppDatabaseModelSnapshot.cs @@ -2,8 +2,7 @@ using System; using System.Collections.Generic; using DysonNetwork.Drive; -using DysonNetwork.Drive.Storage; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; diff --git a/DysonNetwork.Drive/Storage/BundleController.cs b/DysonNetwork.Drive/Storage/BundleController.cs index 9eeeb1c..d400f2d 100644 --- a/DysonNetwork.Drive/Storage/BundleController.cs +++ b/DysonNetwork.Drive/Storage/BundleController.cs @@ -1,4 +1,5 @@ using System.ComponentModel.DataAnnotations; +using DysonNetwork.Shared.Models; using DysonNetwork.Shared.Proto; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; @@ -22,7 +23,7 @@ public class BundleController(AppDatabase db) : ControllerBase } [HttpGet("{id:guid}")] - public async Task> GetBundle([FromRoute] Guid id, [FromQuery] string? passcode) + public async Task> GetBundle([FromRoute] Guid id, [FromQuery] string? passcode) { var bundle = await db.Bundles .Where(e => e.Id == id) @@ -36,7 +37,7 @@ public class BundleController(AppDatabase db) : ControllerBase [HttpGet("me")] [Authorize] - public async Task>> ListBundles( + public async Task>> ListBundles( [FromQuery] string? term, [FromQuery] int offset = 0, [FromQuery] int take = 20 @@ -65,7 +66,7 @@ public class BundleController(AppDatabase db) : ControllerBase [HttpPost] [Authorize] - public async Task> CreateBundle([FromBody] BundleRequest request) + public async Task> CreateBundle([FromBody] BundleRequest request) { if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized(); var accountId = Guid.Parse(currentUser.Id); @@ -77,7 +78,7 @@ public class BundleController(AppDatabase db) : ControllerBase if (string.IsNullOrEmpty(request.Name)) request.Name = "Unnamed Bundle"; - var bundle = new FileBundle + var bundle = new SnFileBundle { Slug = request.Slug, Name = request.Name, @@ -95,7 +96,7 @@ public class BundleController(AppDatabase db) : ControllerBase [HttpPut("{id:guid}")] [Authorize] - public async Task> UpdateBundle([FromRoute] Guid id, [FromBody] BundleRequest request) + public async Task> UpdateBundle([FromRoute] Guid id, [FromBody] BundleRequest request) { if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized(); var accountId = Guid.Parse(currentUser.Id); diff --git a/DysonNetwork.Drive/Storage/FileController.cs b/DysonNetwork.Drive/Storage/FileController.cs index 94ce483..7d23e3b 100644 --- a/DysonNetwork.Drive/Storage/FileController.cs +++ b/DysonNetwork.Drive/Storage/FileController.cs @@ -1,6 +1,6 @@ using DysonNetwork.Drive.Billing; using DysonNetwork.Shared.Auth; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using DysonNetwork.Shared.Proto; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; diff --git a/DysonNetwork.Drive/Storage/FilePoolController.cs b/DysonNetwork.Drive/Storage/FilePoolController.cs index 4105f4b..ce91c84 100644 --- a/DysonNetwork.Drive/Storage/FilePoolController.cs +++ b/DysonNetwork.Drive/Storage/FilePoolController.cs @@ -1,3 +1,4 @@ +using DysonNetwork.Shared.Models; using DysonNetwork.Shared.Proto; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; diff --git a/DysonNetwork.Drive/Storage/FileReferenceService.cs b/DysonNetwork.Drive/Storage/FileReferenceService.cs index 439eeb7..f171d78 100644 --- a/DysonNetwork.Drive/Storage/FileReferenceService.cs +++ b/DysonNetwork.Drive/Storage/FileReferenceService.cs @@ -1,4 +1,5 @@ using DysonNetwork.Shared.Cache; +using DysonNetwork.Shared.Models; using EFCore.BulkExtensions; using Microsoft.EntityFrameworkCore; using NodaTime; @@ -347,7 +348,7 @@ public class FileReferenceService(AppDatabase db, FileService fileService, ICach /// The ID of the resource /// Optional filter by usage context /// A list of files referenced by the resource - public async Task> GetResourceFilesAsync(string resourceId, string? usage = null) + public async Task> GetResourceFilesAsync(string resourceId, string? usage = null) { var query = db.FileReferences.Where(r => r.ResourceId == resourceId); diff --git a/DysonNetwork.Drive/Storage/FileService.cs b/DysonNetwork.Drive/Storage/FileService.cs index 1048af4..5fd2e25 100644 --- a/DysonNetwork.Drive/Storage/FileService.cs +++ b/DysonNetwork.Drive/Storage/FileService.cs @@ -12,9 +12,9 @@ using NATS.Client.Core; using NetVips; using NodaTime; using System.Linq.Expressions; -using DysonNetwork.Shared.Data; using Microsoft.EntityFrameworkCore.Query; using NATS.Net; +using DysonNetwork.Shared.Models; namespace DysonNetwork.Drive.Storage; @@ -512,7 +512,7 @@ public class FileService( } } - private async Task GetBundleAsync(Guid id, Guid accountId) + private async Task GetBundleAsync(Guid id, Guid accountId) { var bundle = await db.Bundles .Where(e => e.Id == id) @@ -569,7 +569,7 @@ public class FileService( await Task.WhenAll(tasks); } - public async Task> LoadFromReference(List references) + public async Task> LoadFromReference(List references) { var cachedFiles = new Dictionary(); var uncachedIds = new List(); diff --git a/DysonNetwork.Drive/Storage/Model/FileUploadModels.cs b/DysonNetwork.Drive/Storage/Model/FileUploadModels.cs index b2d73f5..642c51d 100644 --- a/DysonNetwork.Drive/Storage/Model/FileUploadModels.cs +++ b/DysonNetwork.Drive/Storage/Model/FileUploadModels.cs @@ -1,3 +1,4 @@ +using DysonNetwork.Shared.Models; using NodaTime; namespace DysonNetwork.Drive.Storage.Model @@ -18,7 +19,7 @@ namespace DysonNetwork.Drive.Storage.Model public class CreateUploadTaskResponse { public bool FileExists { get; set; } - public CloudFile? File { get; set; } + public SnCloudFile? File { get; set; } public string? TaskId { get; set; } public long? ChunkSize { get; set; } public int? ChunksCount { get; set; } diff --git a/DysonNetwork.Drive/bun.lock b/DysonNetwork.Drive/bun.lock deleted file mode 100644 index d7a853d..0000000 --- a/DysonNetwork.Drive/bun.lock +++ /dev/null @@ -1,13 +0,0 @@ -{ - "lockfileVersion": 1, - "workspaces": { - "": { - "dependencies": { - "highlight.js": "^11.11.1", - }, - }, - }, - "packages": { - "highlight.js": ["highlight.js@11.11.1", "", {}, "sha512-Xwwo44whKBVCYoliBQwaPvtd/2tYFkRQtXDWj1nackaV2JPXx3L0+Jvd8/qCJ2p+ML0/XVkJ2q+Mr+UVdpJK5w=="], - } -} diff --git a/DysonNetwork.Pass/Account/AccountCurrentController.cs b/DysonNetwork.Pass/Account/AccountCurrentController.cs index 0ad6b63..d863e4f 100644 --- a/DysonNetwork.Pass/Account/AccountCurrentController.cs +++ b/DysonNetwork.Pass/Account/AccountCurrentController.cs @@ -1,16 +1,15 @@ using System.ComponentModel.DataAnnotations; -using DysonNetwork.Pass.Auth; using DysonNetwork.Pass.Permission; using DysonNetwork.Pass.Wallet; -using DysonNetwork.Shared.Data; using DysonNetwork.Shared.Error; +using DysonNetwork.Shared.Models; using DysonNetwork.Shared.Proto; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using NodaTime; using AuthService = DysonNetwork.Pass.Auth.AuthService; -using AuthSession = DysonNetwork.Pass.Auth.AuthSession; +using SnAuthSession = DysonNetwork.Shared.Models.SnAuthSession; namespace DysonNetwork.Pass.Account; @@ -132,7 +131,7 @@ public class AccountCurrentController( Usage = "profile.picture" } ); - profile.Picture = CloudFileReferenceObject.FromProtoValue(file); + profile.Picture = SnCloudFileReferenceObject.FromProtoValue(file); } if (request.BackgroundId is not null) @@ -150,7 +149,7 @@ public class AccountCurrentController( Usage = "profile.background" } ); - profile.Background = CloudFileReferenceObject.FromProtoValue(file); + profile.Background = SnCloudFileReferenceObject.FromProtoValue(file); } db.Update(profile); @@ -558,10 +557,10 @@ public class AccountCurrentController( [HttpGet("devices")] [Authorize] - public async Task>> GetDevices() + public async Task>> GetDevices() { if (HttpContext.Items["CurrentUser"] is not Account currentUser || - HttpContext.Items["CurrentSession"] is not AuthSession currentSession) return Unauthorized(); + HttpContext.Items["CurrentSession"] is not SnAuthSession currentSession) return Unauthorized(); Response.Headers.Append("X-Auth-Session", currentSession.Id.ToString()); @@ -569,7 +568,7 @@ public class AccountCurrentController( .Where(device => device.AccountId == currentUser.Id) .ToListAsync(); - var challengeDevices = devices.Select(AuthClientWithChallenge.FromClient).ToList(); + var challengeDevices = devices.Select(SnAuthClientWithChallenge.FromClient).ToList(); var deviceIds = challengeDevices.Select(x => x.Id).ToList(); var authChallenges = await db.AuthChallenges @@ -585,13 +584,13 @@ public class AccountCurrentController( [HttpGet("sessions")] [Authorize] - public async Task>> GetSessions( + public async Task>> GetSessions( [FromQuery] int take = 20, [FromQuery] int offset = 0 ) { if (HttpContext.Items["CurrentUser"] is not Account currentUser || - HttpContext.Items["CurrentSession"] is not AuthSession currentSession) return Unauthorized(); + HttpContext.Items["CurrentSession"] is not SnAuthSession currentSession) return Unauthorized(); var query = db.AuthSessions .Include(session => session.Account) @@ -613,7 +612,7 @@ public class AccountCurrentController( [HttpDelete("sessions/{id:guid}")] [Authorize] - public async Task> DeleteSession(Guid id) + public async Task> DeleteSession(Guid id) { if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized(); @@ -630,7 +629,7 @@ public class AccountCurrentController( [HttpDelete("devices/{deviceId}")] [Authorize] - public async Task> DeleteDevice(string deviceId) + public async Task> DeleteDevice(string deviceId) { if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized(); @@ -647,10 +646,10 @@ public class AccountCurrentController( [HttpDelete("sessions/current")] [Authorize] - public async Task> DeleteCurrentSession() + public async Task> DeleteCurrentSession() { if (HttpContext.Items["CurrentUser"] is not Account currentUser || - HttpContext.Items["CurrentSession"] is not AuthSession currentSession) return Unauthorized(); + HttpContext.Items["CurrentSession"] is not SnAuthSession currentSession) return Unauthorized(); try { @@ -665,7 +664,7 @@ public class AccountCurrentController( [HttpPatch("devices/{deviceId}/label")] [Authorize] - public async Task> UpdateDeviceLabel(string deviceId, [FromBody] string label) + public async Task> UpdateDeviceLabel(string deviceId, [FromBody] string label) { if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized(); @@ -682,10 +681,10 @@ public class AccountCurrentController( [HttpPatch("devices/current/label")] [Authorize] - public async Task> UpdateCurrentDeviceLabel([FromBody] string label) + public async Task> UpdateCurrentDeviceLabel([FromBody] string label) { if (HttpContext.Items["CurrentUser"] is not Account currentUser || - HttpContext.Items["CurrentSession"] is not AuthSession currentSession) return Unauthorized(); + HttpContext.Items["CurrentSession"] is not SnAuthSession currentSession) return Unauthorized(); var device = await db.AuthClients.FirstOrDefaultAsync(d => d.Id == currentSession.Challenge.ClientId); if (device is null) return NotFound(); diff --git a/DysonNetwork.Pass/Account/AccountEventService.cs b/DysonNetwork.Pass/Account/AccountEventService.cs index b9567de..af51f83 100644 --- a/DysonNetwork.Pass/Account/AccountEventService.cs +++ b/DysonNetwork.Pass/Account/AccountEventService.cs @@ -1,6 +1,7 @@ using System.Globalization; using DysonNetwork.Pass.Wallet; using DysonNetwork.Shared.Cache; +using DysonNetwork.Shared.Models; using DysonNetwork.Shared.Proto; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Localization; diff --git a/DysonNetwork.Pass/Account/AccountService.cs b/DysonNetwork.Pass/Account/AccountService.cs index 2229fbd..b0fee94 100644 --- a/DysonNetwork.Pass/Account/AccountService.cs +++ b/DysonNetwork.Pass/Account/AccountService.cs @@ -1,12 +1,11 @@ using System.Globalization; using System.Text.Json; -using DysonNetwork.Pass.Auth; using DysonNetwork.Pass.Auth.OpenId; using DysonNetwork.Pass.Localization; using DysonNetwork.Pass.Mailer; using DysonNetwork.Pass.Permission; using DysonNetwork.Shared.Cache; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using DysonNetwork.Shared.Proto; using DysonNetwork.Shared.Stream; using EFCore.BulkExtensions; @@ -141,7 +140,7 @@ public class AccountService( var defaultGroup = await db.PermissionGroups.FirstOrDefaultAsync(g => g.Key == "default"); if (defaultGroup is not null) { - db.PermissionGroupMembers.Add(new PermissionGroupMember + db.PermissionGroupMembers.Add(new SnPermissionGroupMember { Actor = $"user:{account.Id}", Group = defaultGroup @@ -217,7 +216,7 @@ public class AccountService( Usage = "profile.picture" } ); - account.Profile.Picture = CloudFileReferenceObject.FromProtoValue(file); + account.Profile.Picture = SnCloudFileReferenceObject.FromProtoValue(file); } if (!string.IsNullOrEmpty(backgroundId)) @@ -231,7 +230,7 @@ public class AccountService( Usage = "profile.background" } ); - account.Profile.Background = CloudFileReferenceObject.FromProtoValue(file); + account.Profile.Background = SnCloudFileReferenceObject.FromProtoValue(file); } db.Accounts.Add(account); @@ -516,7 +515,7 @@ public class AccountService( .AnyAsync(s => s.Challenge.ClientId == id); } - public async Task UpdateDeviceName(Account account, string deviceId, string label) + public async Task UpdateDeviceName(Account account, string deviceId, string label) { var device = await db.AuthClients.FirstOrDefaultAsync(c => c.DeviceId == deviceId && c.AccountId == account.Id ); diff --git a/DysonNetwork.Pass/Account/ActionLogService.cs b/DysonNetwork.Pass/Account/ActionLogService.cs index 3860748..8e710dc 100644 --- a/DysonNetwork.Pass/Account/ActionLogService.cs +++ b/DysonNetwork.Pass/Account/ActionLogService.cs @@ -1,5 +1,6 @@ using DysonNetwork.Shared.Cache; using DysonNetwork.Shared.GeoIp; +using DysonNetwork.Shared.Models; namespace DysonNetwork.Pass.Account; @@ -36,7 +37,7 @@ public class ActionLogService(GeoIpService geo, FlushBufferService fbs) else throw new ArgumentException("No user context was found"); - if (request.HttpContext.Items["CurrentSession"] is Auth.AuthSession currentSession) + if (request.HttpContext.Items["CurrentSession"] is SnAuthSession currentSession) log.SessionId = currentSession.Id; fbs.Enqueue(log); diff --git a/DysonNetwork.Pass/Account/BotAccountReceiverGrpc.cs b/DysonNetwork.Pass/Account/BotAccountReceiverGrpc.cs index dd0c627..f224c4c 100644 --- a/DysonNetwork.Pass/Account/BotAccountReceiverGrpc.cs +++ b/DysonNetwork.Pass/Account/BotAccountReceiverGrpc.cs @@ -1,4 +1,4 @@ -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using DysonNetwork.Shared.Proto; using Grpc.Core; using Microsoft.EntityFrameworkCore; @@ -65,7 +65,7 @@ public class BotAccountReceiverGrpc( Usage = "profile.picture" } ); - account.Profile.Picture = CloudFileReferenceObject.FromProtoValue(file); + account.Profile.Picture = SnCloudFileReferenceObject.FromProtoValue(file); } if (request.BackgroundId is not null) @@ -83,7 +83,7 @@ public class BotAccountReceiverGrpc( Usage = "profile.background" } ); - account.Profile.Background = CloudFileReferenceObject.FromProtoValue(file); + account.Profile.Background = SnCloudFileReferenceObject.FromProtoValue(file); } db.Accounts.Update(account); diff --git a/DysonNetwork.Pass/AppDatabase.cs b/DysonNetwork.Pass/AppDatabase.cs index 8fe40b8..5a31fe1 100644 --- a/DysonNetwork.Pass/AppDatabase.cs +++ b/DysonNetwork.Pass/AppDatabase.cs @@ -3,12 +3,9 @@ using System.Reflection; using System.Text.Json; using System.Text.Json.Serialization; using DysonNetwork.Pass.Account; -using DysonNetwork.Pass.Auth; -using DysonNetwork.Pass.Credit; -using DysonNetwork.Pass.Leveling; using DysonNetwork.Pass.Permission; -using DysonNetwork.Pass.Wallet; using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Design; using Microsoft.EntityFrameworkCore.Query; @@ -22,36 +19,36 @@ public class AppDatabase( IConfiguration configuration ) : DbContext(options) { - public DbSet PermissionNodes { get; set; } = null!; - public DbSet PermissionGroups { get; set; } = null!; - public DbSet PermissionGroupMembers { get; set; } = null!; + public DbSet PermissionNodes { get; set; } = null!; + public DbSet PermissionGroups { get; set; } = null!; + public DbSet PermissionGroupMembers { get; set; } = null!; - public DbSet MagicSpells { get; set; } = null!; + public DbSet MagicSpells { get; set; } = null!; public DbSet Accounts { get; set; } = null!; public DbSet AccountConnections { get; set; } = null!; - public DbSet AccountProfiles { get; set; } = null!; + public DbSet AccountProfiles { get; set; } = null!; public DbSet AccountContacts { get; set; } = null!; public DbSet AccountAuthFactors { get; set; } = null!; - public DbSet AccountRelationships { get; set; } = null!; - public DbSet AccountStatuses { get; set; } = null!; - public DbSet AccountCheckInResults { get; set; } = null!; - public DbSet Badges { get; set; } = null!; + public DbSet AccountRelationships { get; set; } = null!; + public DbSet AccountStatuses { get; set; } = null!; + public DbSet AccountCheckInResults { get; set; } = null!; + public DbSet Badges { get; set; } = null!; public DbSet ActionLogs { get; set; } = null!; - public DbSet AbuseReports { get; set; } = null!; + public DbSet AbuseReports { get; set; } = null!; - public DbSet AuthSessions { get; set; } = null!; - public DbSet AuthChallenges { get; set; } = null!; - public DbSet AuthClients { get; set; } = null!; - public DbSet ApiKeys { get; set; } = null!; + public DbSet AuthSessions { get; set; } = null!; + public DbSet AuthChallenges { get; set; } = null!; + public DbSet AuthClients { get; set; } = null!; + public DbSet ApiKeys { get; set; } = null!; - public DbSet Wallets { get; set; } = null!; - public DbSet WalletPockets { get; set; } = null!; - public DbSet PaymentOrders { get; set; } = null!; - public DbSet PaymentTransactions { get; set; } = null!; - public DbSet WalletSubscriptions { get; set; } = null!; + public DbSet Wallets { get; set; } = null!; + public DbSet WalletPockets { get; set; } = null!; + public DbSet PaymentOrders { get; set; } = null!; + public DbSet PaymentTransactions { get; set; } = null!; + public DbSet WalletSubscriptions { get; set; } = null!; public DbSet WalletCoupons { get; set; } = null!; - public DbSet Punishments { get; set; } = null!; + public DbSet Punishments { get; set; } = null!; public DbSet SocialCreditRecords { get; set; } = null!; public DbSet ExperienceRecords { get; set; } = null!; @@ -74,11 +71,11 @@ public class AppDatabase( optionsBuilder.UseAsyncSeeding(async (context, _, cancellationToken) => { - var defaultPermissionGroup = await context.Set() + var defaultPermissionGroup = await context.Set() .FirstOrDefaultAsync(g => g.Key == "default", cancellationToken); if (defaultPermissionGroup is null) { - context.Set().Add(new PermissionGroup + context.Set().Add(new SnPermissionGroup { Key = "default", Nodes = new List @@ -111,21 +108,21 @@ public class AppDatabase( { base.OnModelCreating(modelBuilder); - modelBuilder.Entity() + modelBuilder.Entity() .HasKey(pg => new { pg.GroupId, pg.Actor }); - modelBuilder.Entity() + modelBuilder.Entity() .HasOne(pg => pg.Group) .WithMany(g => g.Members) .HasForeignKey(pg => pg.GroupId) .OnDelete(DeleteBehavior.Cascade); - modelBuilder.Entity() + modelBuilder.Entity() .HasKey(r => new { FromAccountId = r.AccountId, ToAccountId = r.RelatedId }); - modelBuilder.Entity() + modelBuilder.Entity() .HasOne(r => r.Account) .WithMany(a => a.OutgoingRelationships) .HasForeignKey(r => r.AccountId); - modelBuilder.Entity() + modelBuilder.Entity() .HasOne(r => r.Related) .WithMany(a => a.IncomingRelationships) .HasForeignKey(r => r.RelatedId); diff --git a/DysonNetwork.Pass/Auth/AuthController.cs b/DysonNetwork.Pass/Auth/AuthController.cs index b71cc25..8bc9757 100644 --- a/DysonNetwork.Pass/Auth/AuthController.cs +++ b/DysonNetwork.Pass/Auth/AuthController.cs @@ -11,6 +11,7 @@ using Microsoft.Extensions.Localization; using AccountAuthFactor = DysonNetwork.Pass.Account.AccountAuthFactor; using AccountService = DysonNetwork.Pass.Account.AccountService; using ActionLogService = DysonNetwork.Pass.Account.ActionLogService; +using DysonNetwork.Shared.Models; namespace DysonNetwork.Pass.Auth; diff --git a/DysonNetwork.Pass/Auth/AuthService.cs b/DysonNetwork.Pass/Auth/AuthService.cs index b9df27b..ede5390 100644 --- a/DysonNetwork.Pass/Auth/AuthService.cs +++ b/DysonNetwork.Pass/Auth/AuthService.cs @@ -3,6 +3,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using DysonNetwork.Pass.Account; using DysonNetwork.Shared.Cache; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using NodaTime; @@ -76,10 +77,10 @@ public class AuthService( return totalRequiredSteps; } - public async Task CreateSessionForOidcAsync(Account.Account account, Instant time, + public async Task CreateSessionForOidcAsync(Account.Account account, Instant time, Guid? customAppId = null) { - var challenge = new AuthChallenge + var challenge = new SnAuthChallenge { AccountId = account.Id, IpAddress = HttpContext.Connection.RemoteIpAddress?.ToString(), @@ -89,7 +90,7 @@ public class AuthService( Type = customAppId is not null ? ChallengeType.OAuth : ChallengeType.Oidc }; - var session = new AuthSession + var session = new SnAuthSession { AccountId = account.Id, CreatedAt = time, @@ -105,7 +106,7 @@ public class AuthService( return session; } - public async Task GetOrCreateDeviceAsync( + public async Task GetOrCreateDeviceAsync( Guid accountId, string deviceId, string? deviceName = null, @@ -114,7 +115,7 @@ public class AuthService( { var device = await db.AuthClients.FirstOrDefaultAsync(d => d.DeviceId == deviceId && d.AccountId == accountId); if (device is not null) return device; - device = new AuthClient + device = new SnAuthClient { Platform = platform, DeviceId = deviceId, @@ -181,7 +182,7 @@ public class AuthService( } } - public string CreateToken(AuthSession session) + public string CreateToken(SnAuthSession session) { // Load the private key for signing var privateKeyPem = File.ReadAllText(config["AuthToken:PrivateKeyPath"]!); @@ -199,7 +200,7 @@ public class AuthService( /// Completed challenge /// Signed compact token /// If challenge not completed or session already exists - public async Task CreateSessionAndIssueToken(AuthChallenge challenge) + public async Task CreateSessionAndIssueToken(SnAuthChallenge challenge) { if (challenge.StepRemain != 0) throw new ArgumentException("Challenge not yet completed."); @@ -210,7 +211,7 @@ public class AuthService( throw new ArgumentException("Session already exists for this challenge."); var now = SystemClock.Instance.GetCurrentInstant(); - var session = new AuthSession + var session = new SnAuthSession { LastGrantedAt = now, ExpiredAt = now.Plus(Duration.FromDays(7)), @@ -256,7 +257,7 @@ public class AuthService( return $"{payloadBase64}.{signatureBase64}"; } - public async Task ValidateSudoMode(AuthSession session, string? pinCode) + public async Task ValidateSudoMode(SnAuthSession session, string? pinCode) { // Check if the session is already in sudo mode (cached) var sudoModeKey = $"accounts:{session.Id}:sudo"; @@ -319,7 +320,7 @@ public class AuthService( return factor.VerifyPassword(pinCode); } - public async Task GetApiKey(Guid id, Guid? accountId = null) + public async Task GetApiKey(Guid id, Guid? accountId = null) { var key = await db.ApiKeys .Include(e => e.Session) @@ -329,13 +330,13 @@ public class AuthService( return key; } - public async Task CreateApiKey(Guid accountId, string label, Instant? expiredAt = null) + public async Task CreateApiKey(Guid accountId, string label, Instant? expiredAt = null) { - var key = new ApiKey + var key = new SnApiKey { AccountId = accountId, Label = label, - Session = new AuthSession + Session = new SnAuthSession { AccountId = accountId, ExpiredAt = expiredAt @@ -348,7 +349,7 @@ public class AuthService( return key; } - public async Task IssueApiKeyToken(ApiKey key) + public async Task IssueApiKeyToken(SnApiKey key) { key.Session.LastGrantedAt = SystemClock.Instance.GetCurrentInstant(); db.Update(key.Session); @@ -357,14 +358,14 @@ public class AuthService( return tk; } - public async Task RevokeApiKeyToken(ApiKey key) + public async Task RevokeApiKeyToken(SnApiKey key) { db.Remove(key); db.Remove(key.Session); await db.SaveChangesAsync(); } - public async Task RotateApiKeyToken(ApiKey key) + public async Task RotateApiKeyToken(SnApiKey key) { await using var transaction = await db.Database.BeginTransactionAsync(); try @@ -372,7 +373,7 @@ public class AuthService( var oldSessionId = key.SessionId; // Create new session - var newSession = new AuthSession + var newSession = new SnAuthSession { AccountId = key.AccountId, ExpiredAt = key.Session?.ExpiredAt diff --git a/DysonNetwork.Pass/Auth/CompactTokenService.cs b/DysonNetwork.Pass/Auth/CompactTokenService.cs index 0c49da0..84caa35 100644 --- a/DysonNetwork.Pass/Auth/CompactTokenService.cs +++ b/DysonNetwork.Pass/Auth/CompactTokenService.cs @@ -1,4 +1,5 @@ using System.Security.Cryptography; +using DysonNetwork.Shared.Models; namespace DysonNetwork.Pass.Auth; @@ -7,7 +8,7 @@ public class CompactTokenService(IConfiguration config) private readonly string _privateKeyPath = config["AuthToken:PrivateKeyPath"] ?? throw new InvalidOperationException("AuthToken:PrivateKeyPath configuration is missing"); - public string CreateToken(AuthSession session) + public string CreateToken(SnAuthSession session) { // Load the private key for signing var privateKeyPem = File.ReadAllText(_privateKeyPath); diff --git a/DysonNetwork.Pass/Auth/OidcProvider/Controllers/OidcProviderController.cs b/DysonNetwork.Pass/Auth/OidcProvider/Controllers/OidcProviderController.cs index b568150..daafc12 100644 --- a/DysonNetwork.Pass/Auth/OidcProvider/Controllers/OidcProviderController.cs +++ b/DysonNetwork.Pass/Auth/OidcProvider/Controllers/OidcProviderController.cs @@ -8,10 +8,10 @@ using System.Text.Json.Serialization; using System.Web; using DysonNetwork.Pass.Account; using DysonNetwork.Pass.Auth.OidcProvider.Options; -using DysonNetwork.Shared.Data; using Microsoft.EntityFrameworkCore; using Microsoft.IdentityModel.Tokens; using NodaTime; +using DysonNetwork.Shared.Models; namespace DysonNetwork.Pass.Auth.OidcProvider.Controllers; @@ -98,9 +98,9 @@ public class OidcProviderController( var clientInfo = new ClientInfoResponse { ClientId = Guid.Parse(client.Id), - Picture = client.Picture is not null ? CloudFileReferenceObject.FromProtoValue(client.Picture) : null, + Picture = client.Picture is not null ? SnCloudFileReferenceObject.FromProtoValue(client.Picture) : null, Background = client.Background is not null - ? CloudFileReferenceObject.FromProtoValue(client.Background) + ? SnCloudFileReferenceObject.FromProtoValue(client.Background) : null, ClientName = client.Name, HomeUri = client.Links.HomePage, @@ -304,7 +304,7 @@ public class OidcProviderController( public async Task GetUserInfo() { if (HttpContext.Items["CurrentUser"] is not Account.Account currentUser || - HttpContext.Items["CurrentSession"] is not AuthSession currentSession) return Unauthorized(); + HttpContext.Items["CurrentSession"] is not SnAuthSession currentSession) return Unauthorized(); // Get requested scopes from the token var scopes = currentSession.Challenge?.Scopes ?? []; diff --git a/DysonNetwork.Pass/Auth/OidcProvider/Responses/ClientInfoResponse.cs b/DysonNetwork.Pass/Auth/OidcProvider/Responses/ClientInfoResponse.cs index b8db785..d9ab45b 100644 --- a/DysonNetwork.Pass/Auth/OidcProvider/Responses/ClientInfoResponse.cs +++ b/DysonNetwork.Pass/Auth/OidcProvider/Responses/ClientInfoResponse.cs @@ -1,13 +1,13 @@ using System.Text.Json.Serialization; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; namespace DysonNetwork.Pass.Auth.OidcProvider.Responses; public class ClientInfoResponse { public Guid ClientId { get; set; } - public CloudFileReferenceObject? Picture { get; set; } - public CloudFileReferenceObject? Background { get; set; } + public SnCloudFileReferenceObject? Picture { get; set; } + public SnCloudFileReferenceObject? Background { get; set; } public string? ClientName { get; set; } public string? HomeUri { get; set; } public string? PolicyUri { get; set; } diff --git a/DysonNetwork.Pass/Auth/OidcProvider/Services/OidcProviderService.cs b/DysonNetwork.Pass/Auth/OidcProvider/Services/OidcProviderService.cs index 3a2bc24..7838fc9 100644 --- a/DysonNetwork.Pass/Auth/OidcProvider/Services/OidcProviderService.cs +++ b/DysonNetwork.Pass/Auth/OidcProvider/Services/OidcProviderService.cs @@ -6,6 +6,7 @@ using DysonNetwork.Pass.Auth.OidcProvider.Models; using DysonNetwork.Pass.Auth.OidcProvider.Options; using DysonNetwork.Pass.Auth.OidcProvider.Responses; using DysonNetwork.Shared.Cache; +using DysonNetwork.Shared.Models; using DysonNetwork.Shared.Proto; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Options; diff --git a/DysonNetwork.Pass/Auth/OpenId/OidcController.cs b/DysonNetwork.Pass/Auth/OpenId/OidcController.cs index a165757..c041315 100644 --- a/DysonNetwork.Pass/Auth/OpenId/OidcController.cs +++ b/DysonNetwork.Pass/Auth/OpenId/OidcController.cs @@ -1,5 +1,6 @@ using DysonNetwork.Pass.Account; using DysonNetwork.Shared.Cache; +using DysonNetwork.Shared.Models; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Microsoft.IdentityModel.Tokens; @@ -68,7 +69,7 @@ public class OidcController( /// Handles Apple authentication directly from mobile apps /// [HttpPost("apple/mobile")] - public async Task> AppleMobileLogin( + public async Task> AppleMobileLogin( [FromBody] AppleMobileSignInRequest request ) { diff --git a/DysonNetwork.Pass/Auth/OpenId/OidcService.cs b/DysonNetwork.Pass/Auth/OpenId/OidcService.cs index 257f285..4408e05 100644 --- a/DysonNetwork.Pass/Auth/OpenId/OidcService.cs +++ b/DysonNetwork.Pass/Auth/OpenId/OidcService.cs @@ -2,6 +2,7 @@ using System.IdentityModel.Tokens.Jwt; using System.Text.Json.Serialization; using DysonNetwork.Pass.Account; using DysonNetwork.Shared.Cache; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.IdentityModel.Tokens; using NodaTime; @@ -187,7 +188,7 @@ public abstract class OidcService( /// Creates a challenge and session for an authenticated user /// Also creates or updates the account connection /// - public async Task CreateChallengeForUserAsync( + public async Task CreateChallengeForUserAsync( OidcUserInfo userInfo, Account.Account account, HttpContext request, @@ -219,7 +220,7 @@ public abstract class OidcService( // Create a challenge that's already completed var now = SystemClock.Instance.GetCurrentInstant(); var device = await auth.GetOrCreateDeviceAsync(account.Id, deviceId, deviceName, ClientPlatform.Ios); - var challenge = new AuthChallenge + var challenge = new SnAuthChallenge { ExpiredAt = now.Plus(Duration.FromHours(1)), StepTotal = await auth.DetectChallengeRisk(request.Request, account), diff --git a/DysonNetwork.Pass/Auth/TokenAuthService.cs b/DysonNetwork.Pass/Auth/TokenAuthService.cs index 88163ca..d1375fa 100644 --- a/DysonNetwork.Pass/Auth/TokenAuthService.cs +++ b/DysonNetwork.Pass/Auth/TokenAuthService.cs @@ -3,6 +3,7 @@ using System.Security.Cryptography; using System.Text; using DysonNetwork.Pass.Wallet; using DysonNetwork.Shared.Cache; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using NodaTime; @@ -25,7 +26,7 @@ public class TokenAuthService( /// Incoming token string /// Client IP address, for logging purposes /// (Valid, Session, Message) - public async Task<(bool Valid, AuthSession? Session, string? Message)> AuthenticateTokenAsync(string token, string? ipAddress = null) + public async Task<(bool Valid, SnAuthSession? Session, string? Message)> AuthenticateTokenAsync(string token, string? ipAddress = null) { try { @@ -63,7 +64,7 @@ public class TokenAuthService( // Try cache first var cacheKey = $"{AuthCacheConstants.Prefix}{sessionId}"; - var session = await cache.GetAsync(cacheKey); + var session = await cache.GetAsync(cacheKey); if (session is not null) { logger.LogDebug("AuthenticateTokenAsync: cache hit for {CacheKey}", cacheKey); diff --git a/DysonNetwork.Pass/Credit/SocialCreditService.cs b/DysonNetwork.Pass/Credit/SocialCreditService.cs index 5f8380e..f202b43 100644 --- a/DysonNetwork.Pass/Credit/SocialCreditService.cs +++ b/DysonNetwork.Pass/Credit/SocialCreditService.cs @@ -1,4 +1,5 @@ using DysonNetwork.Shared.Cache; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; namespace DysonNetwork.Pass.Credit; diff --git a/DysonNetwork.Pass/Handlers/LastActiveFlushHandler.cs b/DysonNetwork.Pass/Handlers/LastActiveFlushHandler.cs index e958322..7710d6f 100644 --- a/DysonNetwork.Pass/Handlers/LastActiveFlushHandler.cs +++ b/DysonNetwork.Pass/Handlers/LastActiveFlushHandler.cs @@ -1,4 +1,5 @@ using DysonNetwork.Shared.Cache; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using NodaTime; using Quartz; @@ -7,7 +8,7 @@ namespace DysonNetwork.Pass.Handlers; public class LastActiveInfo { - public Auth.AuthSession Session { get; set; } = null!; + public SnAuthSession Session { get; set; } = null!; public Account.Account Account { get; set; } = null!; public Instant SeenAt { get; set; } } diff --git a/DysonNetwork.Pass/Leveling/ExperienceService.cs b/DysonNetwork.Pass/Leveling/ExperienceService.cs index f018fff..808cd2b 100644 --- a/DysonNetwork.Pass/Leveling/ExperienceService.cs +++ b/DysonNetwork.Pass/Leveling/ExperienceService.cs @@ -1,5 +1,6 @@ using DysonNetwork.Pass.Wallet; using DysonNetwork.Shared.Cache; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; namespace DysonNetwork.Pass.Leveling; diff --git a/DysonNetwork.Pass/Migrations/20250713121237_InitialMigration.Designer.cs b/DysonNetwork.Pass/Migrations/20250713121237_InitialMigration.Designer.cs index cfc7f8f..a71086a 100644 --- a/DysonNetwork.Pass/Migrations/20250713121237_InitialMigration.Designer.cs +++ b/DysonNetwork.Pass/Migrations/20250713121237_InitialMigration.Designer.cs @@ -4,8 +4,7 @@ using System.Collections.Generic; using System.Text.Json; using DysonNetwork.Pass; using DysonNetwork.Pass.Account; -using DysonNetwork.Pass.Wallet; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -390,7 +389,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("jsonb") .HasColumnName("active_badge"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -449,7 +448,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("character varying(256)") .HasColumnName("middle_name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -472,7 +471,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); @@ -1029,7 +1028,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -1052,7 +1051,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("character varying(1024)") .HasColumnName("name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -1070,7 +1069,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); diff --git a/DysonNetwork.Pass/Migrations/20250713121237_InitialMigration.cs b/DysonNetwork.Pass/Migrations/20250713121237_InitialMigration.cs index 767e246..2596527 100644 --- a/DysonNetwork.Pass/Migrations/20250713121237_InitialMigration.cs +++ b/DysonNetwork.Pass/Migrations/20250713121237_InitialMigration.cs @@ -2,8 +2,7 @@ using System.Collections.Generic; using System.Text.Json; using DysonNetwork.Pass.Account; -using DysonNetwork.Pass.Wallet; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore.Migrations; using NetTopologySuite.Geometries; using NodaTime; @@ -49,9 +48,9 @@ namespace DysonNetwork.Pass.Migrations name = table.Column(type: "character varying(1024)", maxLength: 1024, nullable: false), description = table.Column(type: "character varying(4096)", maxLength: 4096, nullable: true), status = table.Column(type: "integer", nullable: false), - picture = table.Column(type: "jsonb", nullable: true), - background = table.Column(type: "jsonb", nullable: true), - verification = table.Column(type: "jsonb", nullable: true), + picture = table.Column(type: "jsonb", nullable: true), + background = table.Column(type: "jsonb", nullable: true), + verification = table.Column(type: "jsonb", nullable: true), created_at = table.Column(type: "timestamp with time zone", nullable: false), updated_at = table.Column(type: "timestamp with time zone", nullable: false), deleted_at = table.Column(type: "timestamp with time zone", nullable: true) @@ -242,13 +241,13 @@ namespace DysonNetwork.Pass.Migrations location = table.Column(type: "character varying(1024)", maxLength: 1024, nullable: true), birthday = table.Column(type: "timestamp with time zone", nullable: true), last_seen_at = table.Column(type: "timestamp with time zone", nullable: true), - verification = table.Column(type: "jsonb", nullable: true), + verification = table.Column(type: "jsonb", nullable: true), active_badge = table.Column(type: "jsonb", nullable: true), experience = table.Column(type: "integer", nullable: false), picture_id = table.Column(type: "character varying(32)", maxLength: 32, nullable: true), background_id = table.Column(type: "character varying(32)", maxLength: 32, nullable: true), - picture = table.Column(type: "jsonb", nullable: true), - background = table.Column(type: "jsonb", nullable: true), + picture = table.Column(type: "jsonb", nullable: true), + background = table.Column(type: "jsonb", nullable: true), account_id = table.Column(type: "uuid", nullable: false), created_at = table.Column(type: "timestamp with time zone", nullable: false), updated_at = table.Column(type: "timestamp with time zone", nullable: false), diff --git a/DysonNetwork.Pass/Migrations/20250715075623_ReinitalMigration.Designer.cs b/DysonNetwork.Pass/Migrations/20250715075623_ReinitalMigration.Designer.cs index 21c66af..bb4ce1e 100644 --- a/DysonNetwork.Pass/Migrations/20250715075623_ReinitalMigration.Designer.cs +++ b/DysonNetwork.Pass/Migrations/20250715075623_ReinitalMigration.Designer.cs @@ -4,8 +4,7 @@ using System.Collections.Generic; using System.Text.Json; using DysonNetwork.Pass; using DysonNetwork.Pass.Account; -using DysonNetwork.Pass.Wallet; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -390,7 +389,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("jsonb") .HasColumnName("active_badge"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -444,7 +443,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("character varying(256)") .HasColumnName("middle_name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -462,7 +461,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); @@ -1019,7 +1018,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -1042,7 +1041,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("character varying(1024)") .HasColumnName("name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -1060,7 +1059,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); diff --git a/DysonNetwork.Pass/Migrations/20250720193202_RemoveNotification.Designer.cs b/DysonNetwork.Pass/Migrations/20250720193202_RemoveNotification.Designer.cs index 9fbeddb..83b730a 100644 --- a/DysonNetwork.Pass/Migrations/20250720193202_RemoveNotification.Designer.cs +++ b/DysonNetwork.Pass/Migrations/20250720193202_RemoveNotification.Designer.cs @@ -4,8 +4,7 @@ using System.Collections.Generic; using System.Text.Json; using DysonNetwork.Pass; using DysonNetwork.Pass.Account; -using DysonNetwork.Pass.Wallet; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -390,7 +389,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("jsonb") .HasColumnName("active_badge"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -444,7 +443,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("character varying(256)") .HasColumnName("middle_name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -462,7 +461,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); @@ -898,7 +897,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -921,7 +920,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("character varying(1024)") .HasColumnName("name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -939,7 +938,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); diff --git a/DysonNetwork.Pass/Migrations/20250731071524_AddCheckInBackdated.Designer.cs b/DysonNetwork.Pass/Migrations/20250731071524_AddCheckInBackdated.Designer.cs index 6733916..9e7b725 100644 --- a/DysonNetwork.Pass/Migrations/20250731071524_AddCheckInBackdated.Designer.cs +++ b/DysonNetwork.Pass/Migrations/20250731071524_AddCheckInBackdated.Designer.cs @@ -4,8 +4,7 @@ using System.Collections.Generic; using System.Text.Json; using DysonNetwork.Pass; using DysonNetwork.Pass.Account; -using DysonNetwork.Pass.Wallet; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -390,7 +389,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("jsonb") .HasColumnName("active_badge"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -444,7 +443,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("character varying(256)") .HasColumnName("middle_name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -462,7 +461,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); @@ -902,7 +901,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -925,7 +924,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("character varying(1024)") .HasColumnName("name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -943,7 +942,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); diff --git a/DysonNetwork.Pass/Migrations/20250807162919_RemoveDevelopers.Designer.cs b/DysonNetwork.Pass/Migrations/20250807162919_RemoveDevelopers.Designer.cs index 7a99d2c..e514402 100644 --- a/DysonNetwork.Pass/Migrations/20250807162919_RemoveDevelopers.Designer.cs +++ b/DysonNetwork.Pass/Migrations/20250807162919_RemoveDevelopers.Designer.cs @@ -4,8 +4,7 @@ using System.Collections.Generic; using System.Text.Json; using DysonNetwork.Pass; using DysonNetwork.Pass.Account; -using DysonNetwork.Pass.Wallet; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -390,7 +389,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("jsonb") .HasColumnName("active_badge"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -444,7 +443,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("character varying(256)") .HasColumnName("middle_name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -462,7 +461,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); diff --git a/DysonNetwork.Pass/Migrations/20250807162919_RemoveDevelopers.cs b/DysonNetwork.Pass/Migrations/20250807162919_RemoveDevelopers.cs index 643a430..90b46ab 100644 --- a/DysonNetwork.Pass/Migrations/20250807162919_RemoveDevelopers.cs +++ b/DysonNetwork.Pass/Migrations/20250807162919_RemoveDevelopers.cs @@ -1,6 +1,6 @@ using System; using System.Collections.Generic; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore.Migrations; using NodaTime; @@ -70,16 +70,16 @@ namespace DysonNetwork.Pass.Migrations columns: table => new { id = table.Column(type: "uuid", nullable: false), - background = table.Column(type: "jsonb", nullable: true), + background = table.Column(type: "jsonb", nullable: true), created_at = table.Column(type: "timestamp with time zone", nullable: false), deleted_at = table.Column(type: "timestamp with time zone", nullable: true), description = table.Column(type: "character varying(4096)", maxLength: 4096, nullable: true), name = table.Column(type: "character varying(1024)", maxLength: 1024, nullable: false), - picture = table.Column(type: "jsonb", nullable: true), + picture = table.Column(type: "jsonb", nullable: true), slug = table.Column(type: "character varying(1024)", maxLength: 1024, nullable: false), status = table.Column(type: "integer", nullable: false), updated_at = table.Column(type: "timestamp with time zone", nullable: false), - verification = table.Column(type: "jsonb", nullable: true) + verification = table.Column(type: "jsonb", nullable: true) }, constraints: table => { diff --git a/DysonNetwork.Pass/Migrations/20250808152643_AddProfileLinks.Designer.cs b/DysonNetwork.Pass/Migrations/20250808152643_AddProfileLinks.Designer.cs index dd5e834..2307600 100644 --- a/DysonNetwork.Pass/Migrations/20250808152643_AddProfileLinks.Designer.cs +++ b/DysonNetwork.Pass/Migrations/20250808152643_AddProfileLinks.Designer.cs @@ -4,8 +4,7 @@ using System.Collections.Generic; using System.Text.Json; using DysonNetwork.Pass; using DysonNetwork.Pass.Account; -using DysonNetwork.Pass.Wallet; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -390,7 +389,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("jsonb") .HasColumnName("active_badge"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -448,7 +447,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("character varying(256)") .HasColumnName("middle_name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -466,7 +465,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); diff --git a/DysonNetwork.Pass/Migrations/20250808152851_AddPublicContact.Designer.cs b/DysonNetwork.Pass/Migrations/20250808152851_AddPublicContact.Designer.cs index 8ff4ce1..15be622 100644 --- a/DysonNetwork.Pass/Migrations/20250808152851_AddPublicContact.Designer.cs +++ b/DysonNetwork.Pass/Migrations/20250808152851_AddPublicContact.Designer.cs @@ -4,8 +4,7 @@ using System.Collections.Generic; using System.Text.Json; using DysonNetwork.Pass; using DysonNetwork.Pass.Account; -using DysonNetwork.Pass.Wallet; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -394,7 +393,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("jsonb") .HasColumnName("active_badge"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -452,7 +451,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("character varying(256)") .HasColumnName("middle_name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -470,7 +469,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); diff --git a/DysonNetwork.Pass/Migrations/20250813072436_AddAuthorizeDevice.Designer.cs b/DysonNetwork.Pass/Migrations/20250813072436_AddAuthorizeDevice.Designer.cs index 93ebc42..2eadbab 100644 --- a/DysonNetwork.Pass/Migrations/20250813072436_AddAuthorizeDevice.Designer.cs +++ b/DysonNetwork.Pass/Migrations/20250813072436_AddAuthorizeDevice.Designer.cs @@ -4,8 +4,7 @@ using System.Collections.Generic; using System.Text.Json; using DysonNetwork.Pass; using DysonNetwork.Pass.Account; -using DysonNetwork.Pass.Wallet; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -394,7 +393,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("jsonb") .HasColumnName("active_badge"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -452,7 +451,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("character varying(256)") .HasColumnName("middle_name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -470,7 +469,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); diff --git a/DysonNetwork.Pass/Migrations/20250813121421_AddAuthDevicePlatform.Designer.cs b/DysonNetwork.Pass/Migrations/20250813121421_AddAuthDevicePlatform.Designer.cs index dc671a2..0661160 100644 --- a/DysonNetwork.Pass/Migrations/20250813121421_AddAuthDevicePlatform.Designer.cs +++ b/DysonNetwork.Pass/Migrations/20250813121421_AddAuthDevicePlatform.Designer.cs @@ -4,8 +4,7 @@ using System.Collections.Generic; using System.Text.Json; using DysonNetwork.Pass; using DysonNetwork.Pass.Account; -using DysonNetwork.Pass.Wallet; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -394,7 +393,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("jsonb") .HasColumnName("active_badge"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -452,7 +451,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("character varying(256)") .HasColumnName("middle_name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -470,7 +469,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); diff --git a/DysonNetwork.Pass/Migrations/20250815041723_RemoveAuthClientIndex.Designer.cs b/DysonNetwork.Pass/Migrations/20250815041723_RemoveAuthClientIndex.Designer.cs index 3c1628c..a90a032 100644 --- a/DysonNetwork.Pass/Migrations/20250815041723_RemoveAuthClientIndex.Designer.cs +++ b/DysonNetwork.Pass/Migrations/20250815041723_RemoveAuthClientIndex.Designer.cs @@ -4,8 +4,7 @@ using System.Collections.Generic; using System.Text.Json; using DysonNetwork.Pass; using DysonNetwork.Pass.Account; -using DysonNetwork.Pass.Wallet; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -394,7 +393,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("jsonb") .HasColumnName("active_badge"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -452,7 +451,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("character varying(256)") .HasColumnName("middle_name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -470,7 +469,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); diff --git a/DysonNetwork.Pass/Migrations/20250818125540_RemoveChallengeOldDeviceId.Designer.cs b/DysonNetwork.Pass/Migrations/20250818125540_RemoveChallengeOldDeviceId.Designer.cs index 0a72fb8..1a2d364 100644 --- a/DysonNetwork.Pass/Migrations/20250818125540_RemoveChallengeOldDeviceId.Designer.cs +++ b/DysonNetwork.Pass/Migrations/20250818125540_RemoveChallengeOldDeviceId.Designer.cs @@ -4,8 +4,7 @@ using System.Collections.Generic; using System.Text.Json; using DysonNetwork.Pass; using DysonNetwork.Pass.Account; -using DysonNetwork.Pass.Wallet; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -394,7 +393,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("jsonb") .HasColumnName("active_badge"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -452,7 +451,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("character varying(256)") .HasColumnName("middle_name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -470,7 +469,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); diff --git a/DysonNetwork.Pass/Migrations/20250819162856_AddBotAccount.Designer.cs b/DysonNetwork.Pass/Migrations/20250819162856_AddBotAccount.Designer.cs index 85d7be9..0a1e423 100644 --- a/DysonNetwork.Pass/Migrations/20250819162856_AddBotAccount.Designer.cs +++ b/DysonNetwork.Pass/Migrations/20250819162856_AddBotAccount.Designer.cs @@ -4,8 +4,7 @@ using System.Collections.Generic; using System.Text.Json; using DysonNetwork.Pass; using DysonNetwork.Pass.Account; -using DysonNetwork.Pass.Wallet; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -398,7 +397,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("jsonb") .HasColumnName("active_badge"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -456,7 +455,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("character varying(256)") .HasColumnName("middle_name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -474,7 +473,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); diff --git a/DysonNetwork.Pass/Migrations/20250820104425_AddApiKeys.Designer.cs b/DysonNetwork.Pass/Migrations/20250820104425_AddApiKeys.Designer.cs index 2ad696d..e288bc3 100644 --- a/DysonNetwork.Pass/Migrations/20250820104425_AddApiKeys.Designer.cs +++ b/DysonNetwork.Pass/Migrations/20250820104425_AddApiKeys.Designer.cs @@ -4,8 +4,7 @@ using System.Collections.Generic; using System.Text.Json; using DysonNetwork.Pass; using DysonNetwork.Pass.Account; -using DysonNetwork.Pass.Wallet; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -398,7 +397,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("jsonb") .HasColumnName("active_badge"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -456,7 +455,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("character varying(256)") .HasColumnName("middle_name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -474,7 +473,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); diff --git a/DysonNetwork.Pass/Migrations/20250820120632_AddCreditAndLevelingRecords.Designer.cs b/DysonNetwork.Pass/Migrations/20250820120632_AddCreditAndLevelingRecords.Designer.cs index ac2e57d..74ec8d5 100644 --- a/DysonNetwork.Pass/Migrations/20250820120632_AddCreditAndLevelingRecords.Designer.cs +++ b/DysonNetwork.Pass/Migrations/20250820120632_AddCreditAndLevelingRecords.Designer.cs @@ -4,8 +4,7 @@ using System.Collections.Generic; using System.Text.Json; using DysonNetwork.Pass; using DysonNetwork.Pass.Account; -using DysonNetwork.Pass.Wallet; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -398,7 +397,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("jsonb") .HasColumnName("active_badge"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -456,7 +455,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("character varying(256)") .HasColumnName("middle_name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -474,7 +473,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); diff --git a/DysonNetwork.Pass/Migrations/20250821093930_AddLevelingBonusMultiplier.Designer.cs b/DysonNetwork.Pass/Migrations/20250821093930_AddLevelingBonusMultiplier.Designer.cs index a0657e2..73d5ced 100644 --- a/DysonNetwork.Pass/Migrations/20250821093930_AddLevelingBonusMultiplier.Designer.cs +++ b/DysonNetwork.Pass/Migrations/20250821093930_AddLevelingBonusMultiplier.Designer.cs @@ -4,8 +4,7 @@ using System.Collections.Generic; using System.Text.Json; using DysonNetwork.Pass; using DysonNetwork.Pass.Account; -using DysonNetwork.Pass.Wallet; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -398,7 +397,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("jsonb") .HasColumnName("active_badge"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -456,7 +455,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("character varying(256)") .HasColumnName("middle_name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -474,7 +473,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); diff --git a/DysonNetwork.Pass/Migrations/20250822142926_CacheSocialCreditsInProfile.Designer.cs b/DysonNetwork.Pass/Migrations/20250822142926_CacheSocialCreditsInProfile.Designer.cs index 6513674..01aa3a4 100644 --- a/DysonNetwork.Pass/Migrations/20250822142926_CacheSocialCreditsInProfile.Designer.cs +++ b/DysonNetwork.Pass/Migrations/20250822142926_CacheSocialCreditsInProfile.Designer.cs @@ -4,8 +4,7 @@ using System.Collections.Generic; using System.Text.Json; using DysonNetwork.Pass; using DysonNetwork.Pass.Account; -using DysonNetwork.Pass.Wallet; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -398,7 +397,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("jsonb") .HasColumnName("active_badge"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -456,7 +455,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("character varying(256)") .HasColumnName("middle_name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -478,7 +477,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); diff --git a/DysonNetwork.Pass/Migrations/20250904144723_AddOrderProductIdentifier.Designer.cs b/DysonNetwork.Pass/Migrations/20250904144723_AddOrderProductIdentifier.Designer.cs index eb415d9..8e934d5 100644 --- a/DysonNetwork.Pass/Migrations/20250904144723_AddOrderProductIdentifier.Designer.cs +++ b/DysonNetwork.Pass/Migrations/20250904144723_AddOrderProductIdentifier.Designer.cs @@ -4,8 +4,7 @@ using System.Collections.Generic; using System.Text.Json; using DysonNetwork.Pass; using DysonNetwork.Pass.Account; -using DysonNetwork.Pass.Wallet; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -398,7 +397,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("jsonb") .HasColumnName("active_badge"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -456,7 +455,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("character varying(256)") .HasColumnName("middle_name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -478,7 +477,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); diff --git a/DysonNetwork.Pass/Migrations/20250906174610_AddAccountRegion.Designer.cs b/DysonNetwork.Pass/Migrations/20250906174610_AddAccountRegion.Designer.cs index 2da0d5e..b0204d6 100644 --- a/DysonNetwork.Pass/Migrations/20250906174610_AddAccountRegion.Designer.cs +++ b/DysonNetwork.Pass/Migrations/20250906174610_AddAccountRegion.Designer.cs @@ -4,8 +4,7 @@ using System.Collections.Generic; using System.Text.Json; using DysonNetwork.Pass; using DysonNetwork.Pass.Account; -using DysonNetwork.Pass.Wallet; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -404,7 +403,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("jsonb") .HasColumnName("active_badge"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -462,7 +461,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("character varying(256)") .HasColumnName("middle_name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -484,7 +483,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); diff --git a/DysonNetwork.Pass/Migrations/20250907065433_RefactorGeoIpPoint.Designer.cs b/DysonNetwork.Pass/Migrations/20250907065433_RefactorGeoIpPoint.Designer.cs index 8e3032b..2fdcedd 100644 --- a/DysonNetwork.Pass/Migrations/20250907065433_RefactorGeoIpPoint.Designer.cs +++ b/DysonNetwork.Pass/Migrations/20250907065433_RefactorGeoIpPoint.Designer.cs @@ -4,9 +4,8 @@ using System.Collections.Generic; using System.Text.Json; using DysonNetwork.Pass; using DysonNetwork.Pass.Account; -using DysonNetwork.Pass.Wallet; -using DysonNetwork.Shared.Data; using DysonNetwork.Shared.GeoIp; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -404,7 +403,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("jsonb") .HasColumnName("active_badge"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -462,7 +461,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("character varying(256)") .HasColumnName("middle_name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -484,7 +483,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); diff --git a/DysonNetwork.Pass/Migrations/20250907065933_RemoveNetTopo.Designer.cs b/DysonNetwork.Pass/Migrations/20250907065933_RemoveNetTopo.Designer.cs index 4ebd5bb..8ef04bf 100644 --- a/DysonNetwork.Pass/Migrations/20250907065933_RemoveNetTopo.Designer.cs +++ b/DysonNetwork.Pass/Migrations/20250907065933_RemoveNetTopo.Designer.cs @@ -4,9 +4,8 @@ using System.Collections.Generic; using System.Text.Json; using DysonNetwork.Pass; using DysonNetwork.Pass.Account; -using DysonNetwork.Pass.Wallet; -using DysonNetwork.Shared.Data; using DysonNetwork.Shared.GeoIp; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -403,7 +402,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("jsonb") .HasColumnName("active_badge"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -461,7 +460,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("character varying(256)") .HasColumnName("middle_name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -483,7 +482,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); diff --git a/DysonNetwork.Pass/Migrations/20250908151924_AddAutomatedStatus.Designer.cs b/DysonNetwork.Pass/Migrations/20250908151924_AddAutomatedStatus.Designer.cs index 7d8614e..43084a6 100644 --- a/DysonNetwork.Pass/Migrations/20250908151924_AddAutomatedStatus.Designer.cs +++ b/DysonNetwork.Pass/Migrations/20250908151924_AddAutomatedStatus.Designer.cs @@ -4,9 +4,8 @@ using System.Collections.Generic; using System.Text.Json; using DysonNetwork.Pass; using DysonNetwork.Pass.Account; -using DysonNetwork.Pass.Wallet; -using DysonNetwork.Shared.Data; using DysonNetwork.Shared.GeoIp; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -403,7 +402,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("jsonb") .HasColumnName("active_badge"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -461,7 +460,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("character varying(256)") .HasColumnName("middle_name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -483,7 +482,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); diff --git a/DysonNetwork.Pass/Migrations/20250924054811_AddStatusMeta.Designer.cs b/DysonNetwork.Pass/Migrations/20250924054811_AddStatusMeta.Designer.cs index e386bd9..54263d5 100644 --- a/DysonNetwork.Pass/Migrations/20250924054811_AddStatusMeta.Designer.cs +++ b/DysonNetwork.Pass/Migrations/20250924054811_AddStatusMeta.Designer.cs @@ -4,9 +4,8 @@ using System.Collections.Generic; using System.Text.Json; using DysonNetwork.Pass; using DysonNetwork.Pass.Account; -using DysonNetwork.Pass.Wallet; -using DysonNetwork.Shared.Data; using DysonNetwork.Shared.GeoIp; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -403,7 +402,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("jsonb") .HasColumnName("active_badge"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -461,7 +460,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("character varying(256)") .HasColumnName("middle_name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -483,7 +482,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); diff --git a/DysonNetwork.Pass/Migrations/AppDatabaseModelSnapshot.cs b/DysonNetwork.Pass/Migrations/AppDatabaseModelSnapshot.cs index 4c131b9..569eb33 100644 --- a/DysonNetwork.Pass/Migrations/AppDatabaseModelSnapshot.cs +++ b/DysonNetwork.Pass/Migrations/AppDatabaseModelSnapshot.cs @@ -4,9 +4,8 @@ using System.Collections.Generic; using System.Text.Json; using DysonNetwork.Pass; using DysonNetwork.Pass.Account; -using DysonNetwork.Pass.Wallet; -using DysonNetwork.Shared.Data; using DysonNetwork.Shared.GeoIp; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; @@ -400,7 +399,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("jsonb") .HasColumnName("active_badge"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -458,7 +457,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("character varying(256)") .HasColumnName("middle_name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -480,7 +479,7 @@ namespace DysonNetwork.Pass.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); diff --git a/DysonNetwork.Pass/Permission/PermissionService.cs b/DysonNetwork.Pass/Permission/PermissionService.cs index a3214b6..dd0702b 100644 --- a/DysonNetwork.Pass/Permission/PermissionService.cs +++ b/DysonNetwork.Pass/Permission/PermissionService.cs @@ -3,6 +3,7 @@ using NodaTime; using System.Text.Json; using DysonNetwork.Pass; using DysonNetwork.Shared.Cache; +using DysonNetwork.Shared.Models; namespace DysonNetwork.Pass.Permission; @@ -75,7 +76,7 @@ public class PermissionService( return result; } - public async Task AddPermissionNode( + public async Task AddPermissionNode( string actor, string area, string key, @@ -86,7 +87,7 @@ public class PermissionService( { if (value is null) throw new ArgumentNullException(nameof(value)); - var node = new PermissionNode + var node = new SnPermissionNode { Actor = actor, Key = key, @@ -105,8 +106,8 @@ public class PermissionService( return node; } - public async Task AddPermissionNodeToGroup( - PermissionGroup group, + public async Task AddPermissionNodeToGroup( + SnPermissionGroup group, string actor, string area, string key, @@ -117,7 +118,7 @@ public class PermissionService( { if (value is null) throw new ArgumentNullException(nameof(value)); - var node = new PermissionNode + var node = new SnPermissionNode { Actor = actor, Key = key, @@ -152,7 +153,7 @@ public class PermissionService( await InvalidatePermissionCacheAsync(actor, area, key); } - public async Task RemovePermissionNodeFromGroup(PermissionGroup group, string actor, string area, string key) + public async Task RemovePermissionNodeFromGroup(SnPermissionGroup group, string actor, string area, string key) { var node = await db.PermissionNodes .Where(n => n.GroupId == group.Id) @@ -185,9 +186,9 @@ public class PermissionService( return JsonDocument.Parse(str); } - public static PermissionNode NewPermissionNode(string actor, string area, string key, T value) + public static SnPermissionNode NewPermissionNode(string actor, string area, string key, T value) { - return new PermissionNode + return new SnPermissionNode { Actor = actor, Area = area, diff --git a/DysonNetwork.Pass/Permission/PermissionServiceGrpc.cs b/DysonNetwork.Pass/Permission/PermissionServiceGrpc.cs index 435c8f6..c4614b1 100644 --- a/DysonNetwork.Pass/Permission/PermissionServiceGrpc.cs +++ b/DysonNetwork.Pass/Permission/PermissionServiceGrpc.cs @@ -4,6 +4,7 @@ using DysonNetwork.Shared.Proto; using Google.Protobuf.WellKnownTypes; using System.Text.Json; using NodaTime.Serialization.Protobuf; +using DysonNetwork.Shared.Models; namespace DysonNetwork.Pass.Permission; diff --git a/DysonNetwork.Pass/Startup/BroadcastEventHandler.cs b/DysonNetwork.Pass/Startup/BroadcastEventHandler.cs index c326ed1..efead54 100644 --- a/DysonNetwork.Pass/Startup/BroadcastEventHandler.cs +++ b/DysonNetwork.Pass/Startup/BroadcastEventHandler.cs @@ -1,5 +1,6 @@ using System.Text.Json; using DysonNetwork.Pass.Wallet; +using DysonNetwork.Shared.Models; using DysonNetwork.Shared.Proto; using DysonNetwork.Shared.Stream; using NATS.Client.Core; diff --git a/DysonNetwork.Pass/Team/Team.cs b/DysonNetwork.Pass/Team/Team.cs deleted file mode 100644 index a6cf330..0000000 --- a/DysonNetwork.Pass/Team/Team.cs +++ /dev/null @@ -1,79 +0,0 @@ -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -using System.Text.Json.Serialization; -using DysonNetwork.Shared.Data; -using Microsoft.EntityFrameworkCore; -using NodaTime; - -namespace DysonNetwork.Pass.Team; - -public enum TeamType -{ - Individual, - Organizational -} - -[Index(nameof(Name), IsUnique = true)] -public class Team : ModelBase, IIdentifiedResource -{ - public Guid Id { get; set; } - public TeamType Type { get; set; } - [MaxLength(256)] public string Name { get; set; } = string.Empty; - [MaxLength(256)] public string Nick { get; set; } = string.Empty; - [MaxLength(4096)] public string? Bio { get; set; } - - [Column(TypeName = "jsonb")] public CloudFileReferenceObject? Picture { get; set; } - [Column(TypeName = "jsonb")] public CloudFileReferenceObject? Background { get; set; } - - [Column(TypeName = "jsonb")] public VerificationMark? Verification { get; set; } - - [JsonIgnore] public ICollection Members { get; set; } = new List(); - [JsonIgnore] public ICollection Features { get; set; } = new List(); - - public Guid? AccountId { get; set; } - public Account.Account? Account { get; set; } - - public string ResourceIdentifier => $"publisher/{Id}"; -} - -public enum TeamMemberRole -{ - Owner = 100, - Manager = 75, - Editor = 50, - Viewer = 25 -} - -public class TeamMember : ModelBase -{ - public Guid TeamId { get; set; } - [JsonIgnore] public Team Team { get; set; } = null!; - public Guid AccountId { get; set; } - public Account.Account Account { get; set; } = null!; - - public TeamMemberRole Role { get; set; } = TeamMemberRole.Viewer; - public Instant? JoinedAt { get; set; } -} - -public enum TeamSubscriptionStatus -{ - Active, - Expired, - Cancelled -} - -public class TeamFeature : ModelBase -{ - public Guid Id { get; set; } - [MaxLength(1024)] public string Flag { get; set; } = null!; - public Instant? ExpiredAt { get; set; } - - public Guid TeamId { get; set; } - public Team Team { get; set; } = null!; -} - -public abstract class TeamFeatureFlag -{ - public static List AllFlags => [Develop]; - public static string Develop = "develop"; -} \ No newline at end of file diff --git a/DysonNetwork.Pass/Wallet/OrderController.cs b/DysonNetwork.Pass/Wallet/OrderController.cs index 089b6fb..6b580b1 100644 --- a/DysonNetwork.Pass/Wallet/OrderController.cs +++ b/DysonNetwork.Pass/Wallet/OrderController.cs @@ -1,4 +1,5 @@ using DysonNetwork.Pass.Auth; +using DysonNetwork.Shared.Models; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; @@ -10,7 +11,7 @@ namespace DysonNetwork.Pass.Wallet; public class OrderController(PaymentService payment, AuthService auth, AppDatabase db) : ControllerBase { [HttpGet("{id:guid}")] - public async Task> GetOrderById(Guid id) + public async Task> GetOrderById(Guid id) { var order = await db.PaymentOrders.FindAsync(id); @@ -22,7 +23,7 @@ public class OrderController(PaymentService payment, AuthService auth, AppDataba [HttpPost("{id:guid}/pay")] [Authorize] - public async Task> PayOrder(Guid id, [FromBody] PayOrderRequest request) + public async Task> PayOrder(Guid id, [FromBody] PayOrderRequest request) { if (HttpContext.Items["CurrentUser"] is not Account.Account currentUser) return Unauthorized(); diff --git a/DysonNetwork.Pass/Wallet/PaymentService.cs b/DysonNetwork.Pass/Wallet/PaymentService.cs index c4e7b45..06fb884 100644 --- a/DysonNetwork.Pass/Wallet/PaymentService.cs +++ b/DysonNetwork.Pass/Wallet/PaymentService.cs @@ -1,6 +1,7 @@ using System.Globalization; using System.Text.Json; using DysonNetwork.Pass.Localization; +using DysonNetwork.Shared.Models; using DysonNetwork.Shared.Proto; using DysonNetwork.Shared.Stream; using Microsoft.EntityFrameworkCore; diff --git a/DysonNetwork.Pass/Wallet/PaymentServiceGrpc.cs b/DysonNetwork.Pass/Wallet/PaymentServiceGrpc.cs index 5b1c3c6..ae0526d 100644 --- a/DysonNetwork.Pass/Wallet/PaymentServiceGrpc.cs +++ b/DysonNetwork.Pass/Wallet/PaymentServiceGrpc.cs @@ -1,3 +1,4 @@ +using DysonNetwork.Shared.Models; using DysonNetwork.Shared.Proto; using Grpc.Core; using NodaTime; diff --git a/DysonNetwork.Pass/Wallet/SubscriptionController.cs b/DysonNetwork.Pass/Wallet/SubscriptionController.cs index 10b98ef..2706a05 100644 --- a/DysonNetwork.Pass/Wallet/SubscriptionController.cs +++ b/DysonNetwork.Pass/Wallet/SubscriptionController.cs @@ -4,6 +4,7 @@ using Microsoft.EntityFrameworkCore; using NodaTime; using System.ComponentModel.DataAnnotations; using DysonNetwork.Pass.Wallet.PaymentHandlers; +using DysonNetwork.Shared.Models; namespace DysonNetwork.Pass.Wallet; @@ -14,7 +15,7 @@ public class SubscriptionController(SubscriptionService subscriptions, AfdianPay { [HttpGet] [Authorize] - public async Task>> ListSubscriptions( + public async Task>> ListSubscriptions( [FromQuery] int offset = 0, [FromQuery] int take = 20 ) @@ -40,7 +41,7 @@ public class SubscriptionController(SubscriptionService subscriptions, AfdianPay [HttpGet("fuzzy/{prefix}")] [Authorize] - public async Task> GetSubscriptionFuzzy(string prefix) + public async Task> GetSubscriptionFuzzy(string prefix) { if (HttpContext.Items["CurrentUser"] is not Account.Account currentUser) return Unauthorized(); @@ -56,7 +57,7 @@ public class SubscriptionController(SubscriptionService subscriptions, AfdianPay [HttpGet("{identifier}")] [Authorize] - public async Task> GetSubscription(string identifier) + public async Task> GetSubscription(string identifier) { if (HttpContext.Items["CurrentUser"] is not Account.Account currentUser) return Unauthorized(); @@ -79,7 +80,7 @@ public class SubscriptionController(SubscriptionService subscriptions, AfdianPay [HttpPost] [Authorize] - public async Task> CreateSubscription( + public async Task> CreateSubscription( [FromBody] CreateSubscriptionRequest request, [FromHeader(Name = "X-Noop")] bool noop = false ) @@ -118,7 +119,7 @@ public class SubscriptionController(SubscriptionService subscriptions, AfdianPay [HttpPost("{identifier}/cancel")] [Authorize] - public async Task> CancelSubscription(string identifier) + public async Task> CancelSubscription(string identifier) { if (HttpContext.Items["CurrentUser"] is not Account.Account currentUser) return Unauthorized(); @@ -135,7 +136,7 @@ public class SubscriptionController(SubscriptionService subscriptions, AfdianPay [HttpPost("{identifier}/order")] [Authorize] - public async Task> CreateSubscriptionOrder(string identifier) + public async Task> CreateSubscriptionOrder(string identifier) { if (HttpContext.Items["CurrentUser"] is not Account.Account currentUser) return Unauthorized(); diff --git a/DysonNetwork.Pass/Wallet/SubscriptionRenewalJob.cs b/DysonNetwork.Pass/Wallet/SubscriptionRenewalJob.cs index 2e12cb2..f0f4a66 100644 --- a/DysonNetwork.Pass/Wallet/SubscriptionRenewalJob.cs +++ b/DysonNetwork.Pass/Wallet/SubscriptionRenewalJob.cs @@ -1,3 +1,4 @@ +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using NodaTime; using Quartz; diff --git a/DysonNetwork.Pass/Wallet/SubscriptionService.cs b/DysonNetwork.Pass/Wallet/SubscriptionService.cs index 82dccea..b447083 100644 --- a/DysonNetwork.Pass/Wallet/SubscriptionService.cs +++ b/DysonNetwork.Pass/Wallet/SubscriptionService.cs @@ -4,6 +4,7 @@ using System.Text.Json; using DysonNetwork.Pass.Localization; using DysonNetwork.Pass.Wallet.PaymentHandlers; using DysonNetwork.Shared.Cache; +using DysonNetwork.Shared.Models; using DysonNetwork.Shared.Proto; using Google.Protobuf.WellKnownTypes; using Microsoft.EntityFrameworkCore; diff --git a/DysonNetwork.Pass/Wallet/WalletController.cs b/DysonNetwork.Pass/Wallet/WalletController.cs index 8537834..254a265 100644 --- a/DysonNetwork.Pass/Wallet/WalletController.cs +++ b/DysonNetwork.Pass/Wallet/WalletController.cs @@ -1,5 +1,6 @@ using System.ComponentModel.DataAnnotations; using DysonNetwork.Pass.Permission; +using DysonNetwork.Shared.Models; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; @@ -40,7 +41,7 @@ public class WalletController(AppDatabase db, WalletService ws, PaymentService p [HttpGet("transactions")] [Authorize] - public async Task>> GetTransactions( + public async Task>> GetTransactions( [FromQuery] int offset = 0, [FromQuery] int take = 20 ) { @@ -67,7 +68,7 @@ public class WalletController(AppDatabase db, WalletService ws, PaymentService p [HttpGet("orders")] [Authorize] - public async Task>> GetOrders( + public async Task>> GetOrders( [FromQuery] int offset = 0, [FromQuery] int take = 20 ) { @@ -104,7 +105,7 @@ public class WalletController(AppDatabase db, WalletService ws, PaymentService p [HttpPost("balance")] [Authorize] [RequiredPermission("maintenance", "wallets.balance.modify")] - public async Task> ModifyWalletBalance([FromBody] WalletBalanceRequest request) + public async Task> ModifyWalletBalance([FromBody] WalletBalanceRequest request) { var wallet = await ws.GetWalletAsync(request.AccountId); if (wallet is null) return NotFound("Wallet was not found."); diff --git a/DysonNetwork.Pass/Wallet/WalletService.cs b/DysonNetwork.Pass/Wallet/WalletService.cs index 98d3636..3a61860 100644 --- a/DysonNetwork.Pass/Wallet/WalletService.cs +++ b/DysonNetwork.Pass/Wallet/WalletService.cs @@ -1,3 +1,4 @@ +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; namespace DysonNetwork.Pass.Wallet; @@ -27,7 +28,7 @@ public class WalletService(AppDatabase db) return wallet; } - public async Task<(WalletPocket wallet, bool isNewlyCreated)> GetOrCreateWalletPocketAsync( + public async Task<(SnWalletPocket wallet, bool isNewlyCreated)> GetOrCreateWalletPocketAsync( Guid walletId, string currency, decimal? initialAmount = null @@ -36,7 +37,7 @@ public class WalletService(AppDatabase db) var pocket = await db.WalletPockets.FirstOrDefaultAsync(p => p.Currency == currency && p.WalletId == walletId); if (pocket != null) return (pocket, false); - pocket = new WalletPocket + pocket = new SnWalletPocket { Currency = currency, Amount = initialAmount ?? 0, diff --git a/DysonNetwork.Ring/AppDatabase.cs b/DysonNetwork.Ring/AppDatabase.cs index d7d8a65..cca4af3 100644 --- a/DysonNetwork.Ring/AppDatabase.cs +++ b/DysonNetwork.Ring/AppDatabase.cs @@ -1,7 +1,7 @@ using System.Linq.Expressions; using System.Reflection; -using DysonNetwork.Ring.Notification; using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Design; using Microsoft.EntityFrameworkCore.Query; @@ -15,8 +15,8 @@ public class AppDatabase( IConfiguration configuration ) : DbContext(options) { - public DbSet Notifications { get; set; } = null!; - public DbSet PushSubscriptions { get; set; } = null!; + public DbSet Notifications { get; set; } = null!; + public DbSet PushSubscriptions { get; set; } = null!; protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { diff --git a/DysonNetwork.Ring/Connection/IWebSocketPacketHandler.cs b/DysonNetwork.Ring/Connection/IWebSocketPacketHandler.cs index b7108e4..9aa1d47 100644 --- a/DysonNetwork.Ring/Connection/IWebSocketPacketHandler.cs +++ b/DysonNetwork.Ring/Connection/IWebSocketPacketHandler.cs @@ -1,6 +1,6 @@ using System.Net.WebSockets; using DysonNetwork.Shared.Proto; -using WebSocketPacket = DysonNetwork.Shared.Data.WebSocketPacket; +using WebSocketPacket = DysonNetwork.Shared.Models.WebSocketPacket; namespace DysonNetwork.Ring.Connection; diff --git a/DysonNetwork.Ring/Connection/WebSocketController.cs b/DysonNetwork.Ring/Connection/WebSocketController.cs index f1b5668..e5027f1 100644 --- a/DysonNetwork.Ring/Connection/WebSocketController.cs +++ b/DysonNetwork.Ring/Connection/WebSocketController.cs @@ -3,7 +3,7 @@ using DysonNetwork.Shared.Proto; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Swashbuckle.AspNetCore.Annotations; -using WebSocketPacket = DysonNetwork.Shared.Data.WebSocketPacket; +using WebSocketPacket = DysonNetwork.Shared.Models.WebSocketPacket; namespace DysonNetwork.Ring.Connection; diff --git a/DysonNetwork.Ring/Connection/WebSocketService.cs b/DysonNetwork.Ring/Connection/WebSocketService.cs index a017e7f..93253bf 100644 --- a/DysonNetwork.Ring/Connection/WebSocketService.cs +++ b/DysonNetwork.Ring/Connection/WebSocketService.cs @@ -1,10 +1,10 @@ using System.Collections.Concurrent; using System.Net.WebSockets; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using DysonNetwork.Shared.Proto; using DysonNetwork.Shared.Stream; using NATS.Client.Core; -using WebSocketPacket = DysonNetwork.Shared.Data.WebSocketPacket; +using WebSocketPacket = DysonNetwork.Shared.Models.WebSocketPacket; namespace DysonNetwork.Ring.Connection; diff --git a/DysonNetwork.Ring/Notification/Notification.cs b/DysonNetwork.Ring/Notification/Notification.cs deleted file mode 100644 index c997fed..0000000 --- a/DysonNetwork.Ring/Notification/Notification.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -using DysonNetwork.Shared.Data; -using NodaTime; - -namespace DysonNetwork.Ring.Notification; - -public class Notification : ModelBase -{ - public Guid Id { get; set; } = Guid.NewGuid(); - [MaxLength(1024)] public string Topic { get; set; } = null!; - [MaxLength(1024)] public string? Title { get; set; } - [MaxLength(2048)] public string? Subtitle { get; set; } - [MaxLength(4096)] public string? Content { get; set; } - [Column(TypeName = "jsonb")] public Dictionary Meta { get; set; } = new(); - public int Priority { get; set; } = 10; - public Instant? ViewedAt { get; set; } - - public Guid AccountId { get; set; } -} - diff --git a/DysonNetwork.Ring/Notification/NotificationController.cs b/DysonNetwork.Ring/Notification/NotificationController.cs index 0552094..c364c7f 100644 --- a/DysonNetwork.Ring/Notification/NotificationController.cs +++ b/DysonNetwork.Ring/Notification/NotificationController.cs @@ -1,5 +1,6 @@ using System.ComponentModel.DataAnnotations; using DysonNetwork.Shared.Auth; +using DysonNetwork.Shared.Models; using DysonNetwork.Shared.Proto; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; @@ -78,7 +79,7 @@ public class NotificationController( [HttpPut("subscription")] [Authorize] - public async Task> + public async Task> SubscribeToPushNotification( [FromBody] PushNotificationSubscribeRequest request ) diff --git a/DysonNetwork.Ring/Notification/PushService.cs b/DysonNetwork.Ring/Notification/PushService.cs index c9d5074..3cea7d1 100644 --- a/DysonNetwork.Ring/Notification/PushService.cs +++ b/DysonNetwork.Ring/Notification/PushService.cs @@ -2,10 +2,11 @@ using CorePush.Apple; using CorePush.Firebase; using DysonNetwork.Ring.Connection; using DysonNetwork.Ring.Services; +using DysonNetwork.Shared.Models; using DysonNetwork.Shared.Proto; using Microsoft.EntityFrameworkCore; using NodaTime; -using WebSocketPacket = DysonNetwork.Shared.Data.WebSocketPacket; +using WebSocketPacket = DysonNetwork.Shared.Models.WebSocketPacket; namespace DysonNetwork.Ring.Notification; @@ -62,7 +63,7 @@ public class PushService .ExecuteDeleteAsync(); } - public async Task SubscribeDevice( + public async Task SubscribeDevice( string deviceId, string deviceToken, PushProvider provider, @@ -90,7 +91,7 @@ public class PushService return existingSubscription; } - var subscription = new PushSubscription + var subscription = new SnNotificationPushSubscription { DeviceId = deviceId, DeviceToken = deviceToken, @@ -259,7 +260,7 @@ public class PushService await DeliverPushNotification(notification); } - private async Task SendPushNotificationAsync(PushSubscription subscription, Notification notification) + private async Task SendPushNotificationAsync(SnNotificationPushSubscription subscription, Notification notification) { try { diff --git a/DysonNetwork.Ring/Notification/PushSubscription.cs b/DysonNetwork.Ring/Notification/PushSubscription.cs deleted file mode 100644 index 753aff5..0000000 --- a/DysonNetwork.Ring/Notification/PushSubscription.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.ComponentModel.DataAnnotations; -using DysonNetwork.Shared.Data; -using Microsoft.EntityFrameworkCore; -using NodaTime; - -namespace DysonNetwork.Ring.Notification; - -public enum PushProvider -{ - Apple, - Google -} - -[Index(nameof(AccountId), nameof(DeviceId), nameof(DeletedAt), IsUnique = true)] -public class PushSubscription : ModelBase -{ - public Guid Id { get; set; } = Guid.NewGuid(); - public Guid AccountId { get; set; } - [MaxLength(8192)] public string DeviceId { get; set; } = null!; - [MaxLength(8192)] public string DeviceToken { get; set; } = null!; - public PushProvider Provider { get; set; } - - public int CountDelivered { get; set; } - public Instant? LastUsedAt { get; set; } -} \ No newline at end of file diff --git a/DysonNetwork.Ring/Services/PusherServiceGrpc.cs b/DysonNetwork.Ring/Services/PusherServiceGrpc.cs index de68ef5..34aeb3d 100644 --- a/DysonNetwork.Ring/Services/PusherServiceGrpc.cs +++ b/DysonNetwork.Ring/Services/PusherServiceGrpc.cs @@ -25,7 +25,7 @@ public class RingServiceGrpc( public override Task PushWebSocketPacket(PushWebSocketPacketRequest request, ServerCallContext context) { - var packet = Shared.Data.WebSocketPacket.FromProtoValue(request.Packet); + var packet = Shared.Models.WebSocketPacket.FromProtoValue(request.Packet); WebSocketService.SendPacketToAccount(Guid.Parse(request.UserId), packet); return Task.FromResult(new Empty()); @@ -34,7 +34,7 @@ public class RingServiceGrpc( public override Task PushWebSocketPacketToUsers(PushWebSocketPacketToUsersRequest request, ServerCallContext context) { - var packet = Shared.Data.WebSocketPacket.FromProtoValue(request.Packet); + var packet = Shared.Models.WebSocketPacket.FromProtoValue(request.Packet); foreach (var accountId in request.UserIds) WebSocketService.SendPacketToAccount(Guid.Parse(accountId), packet); @@ -45,7 +45,7 @@ public class RingServiceGrpc( public override Task PushWebSocketPacketToDevice(PushWebSocketPacketToDeviceRequest request, ServerCallContext context) { - var packet = Shared.Data.WebSocketPacket.FromProtoValue(request.Packet); + var packet = Shared.Models.WebSocketPacket.FromProtoValue(request.Packet); websocket.SendPacketToDevice(request.DeviceId, packet); return Task.FromResult(new Empty()); @@ -54,7 +54,7 @@ public override Task PushWebSocketPacketToDevice(PushWebSocketPacketToDev public override Task PushWebSocketPacketToDevices(PushWebSocketPacketToDevicesRequest request, ServerCallContext context) { - var packet = Shared.Data.WebSocketPacket.FromProtoValue(request.Packet); + var packet = Shared.Models.WebSocketPacket.FromProtoValue(request.Packet); foreach (var deviceId in request.DeviceIds) websocket.SendPacketToDevice(deviceId, packet); diff --git a/DysonNetwork.Ring/Services/QueueBackgroundService.cs b/DysonNetwork.Ring/Services/QueueBackgroundService.cs index a2f0f1b..974bef8 100644 --- a/DysonNetwork.Ring/Services/QueueBackgroundService.cs +++ b/DysonNetwork.Ring/Services/QueueBackgroundService.cs @@ -119,7 +119,7 @@ public class QueueBackgroundService( var pushService = scope.ServiceProvider.GetRequiredService(); var logger = scope.ServiceProvider.GetRequiredService>(); - var notification = JsonSerializer.Deserialize(message.Data); + var notification = JsonSerializer.Deserialize(message.Data); if (notification == null) { logger.LogError("Invalid push notification data format"); diff --git a/DysonNetwork.Ring/Services/QueueService.cs b/DysonNetwork.Ring/Services/QueueService.cs index 3a3622c..7c6b168 100644 --- a/DysonNetwork.Ring/Services/QueueService.cs +++ b/DysonNetwork.Ring/Services/QueueService.cs @@ -26,7 +26,7 @@ public class QueueService(INatsConnection nats) await js.PublishAsync(QueueBackgroundService.QueueName, rawMessage); } - public async Task EnqueuePushNotification(Notification.Notification notification, Guid userId, bool isSavable = false) + public async Task EnqueuePushNotification(Shared.Models.SnNotification notification, Guid userId, bool isSavable = false) { // Update the account ID in case it wasn't set notification.AccountId = userId; diff --git a/DysonNetwork.Shared/Auth/AuthScheme.cs b/DysonNetwork.Shared/Auth/AuthScheme.cs index 5ac25fe..5fc0a6f 100644 --- a/DysonNetwork.Shared/Auth/AuthScheme.cs +++ b/DysonNetwork.Shared/Auth/AuthScheme.cs @@ -6,7 +6,6 @@ using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; -using SystemClock = NodaTime.SystemClock; namespace DysonNetwork.Shared.Auth; diff --git a/DysonNetwork.Shared/Auth/Startup.cs b/DysonNetwork.Shared/Auth/Startup.cs index e0caf8c..df1b562 100644 --- a/DysonNetwork.Shared/Auth/Startup.cs +++ b/DysonNetwork.Shared/Auth/Startup.cs @@ -1,6 +1,4 @@ -using DysonNetwork.Shared.Proto; using DysonNetwork.Shared.Registry; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; namespace DysonNetwork.Shared.Auth; diff --git a/DysonNetwork.Shared/Content/TextSanitizer.cs b/DysonNetwork.Shared/Content/TextSanitizer.cs index d839f5d..a34d92c 100644 --- a/DysonNetwork.Shared/Content/TextSanitizer.cs +++ b/DysonNetwork.Shared/Content/TextSanitizer.cs @@ -1,6 +1,5 @@ using System.Text; using System.Globalization; -using System.Text.RegularExpressions; namespace DysonNetwork.Shared.Content; diff --git a/DysonNetwork.Shared/Data/Account.cs b/DysonNetwork.Shared/Data/Account.cs deleted file mode 100644 index 46f2031..0000000 --- a/DysonNetwork.Shared/Data/Account.cs +++ /dev/null @@ -1,350 +0,0 @@ -using DysonNetwork.Shared.Proto; -using NodaTime; -using NodaTime.Serialization.Protobuf; - -namespace DysonNetwork.Shared.Data; - -public class AccountReference : ModelBase -{ - public Guid Id { get; set; } - public string Name { get; set; } = string.Empty; - public string Nick { get; set; } = string.Empty; - public string Language { get; set; } = string.Empty; - public Instant? ActivatedAt { get; set; } - public bool IsSuperuser { get; set; } - public Guid? AutomatedId { get; set; } - public AccountProfileReference Profile { get; set; } = null!; - public List Contacts { get; set; } = new(); - public List Badges { get; set; } = new(); - public SubscriptionReference? PerkSubscription { get; set; } - - public Proto.Account ToProtoValue() - { - var proto = new Proto.Account - { - Id = Id.ToString(), - Name = Name, - Nick = Nick, - Language = Language, - ActivatedAt = ActivatedAt?.ToTimestamp(), - IsSuperuser = IsSuperuser, - Profile = Profile.ToProtoValue(), - PerkSubscription = PerkSubscription?.ToProtoValue(), - CreatedAt = CreatedAt.ToTimestamp(), - UpdatedAt = UpdatedAt.ToTimestamp() - }; - - foreach (var contact in Contacts) - proto.Contacts.Add(contact.ToProtoValue()); - - foreach (var badge in Badges) - proto.Badges.Add(badge.ToProtoValue()); - - return proto; - } - - public static AccountReference FromProtoValue(Proto.Account proto) - { - var account = new AccountReference - { - Id = Guid.Parse(proto.Id), - Name = proto.Name, - Nick = proto.Nick, - Language = proto.Language, - ActivatedAt = proto.ActivatedAt?.ToInstant(), - IsSuperuser = proto.IsSuperuser, - AutomatedId = string.IsNullOrEmpty(proto.AutomatedId) ? null : Guid.Parse(proto.AutomatedId), - PerkSubscription = proto.PerkSubscription != null - ? SubscriptionReference.FromProtoValue(proto.PerkSubscription) - : null, - CreatedAt = proto.CreatedAt.ToInstant(), - UpdatedAt = proto.UpdatedAt.ToInstant() - }; - - account.Profile = AccountProfileReference.FromProtoValue(proto.Profile); - - foreach (var contactProto in proto.Contacts) - account.Contacts.Add(AccountContactReference.FromProtoValue(contactProto)); - - foreach (var badgeProto in proto.Badges) - account.Badges.Add(AccountBadgeReference.FromProtoValue(badgeProto)); - - return account; - } -} - -public class AccountProfileReference : ModelBase -{ - public Guid Id { get; set; } - public string? FirstName { get; set; } - public string? MiddleName { get; set; } - public string? LastName { get; set; } - public string? Bio { get; set; } - public string? Gender { get; set; } - public string? Pronouns { get; set; } - public string? TimeZone { get; set; } - public string? Location { get; set; } - public List? Links { get; set; } - public Instant? Birthday { get; set; } - public Instant? LastSeenAt { get; set; } - public VerificationMark? Verification { get; set; } - public int Experience { get; set; } - public int Level => Leveling.ExperiencePerLevel.Count(xp => Experience >= xp) - 1; - public double SocialCredits { get; set; } = 100; - - public int SocialCreditsLevel => SocialCredits switch - { - < 100 => -1, - > 100 and < 200 => 0, - < 200 => 1, - _ => 2 - }; - - public double LevelingProgress => Level >= Leveling.ExperiencePerLevel.Count - 1 - ? 100 - : (Experience - Leveling.ExperiencePerLevel[Level]) * 100.0 / - (Leveling.ExperiencePerLevel[Level + 1] - Leveling.ExperiencePerLevel[Level]); - - public CloudFileReferenceObject? Picture { get; set; } - public CloudFileReferenceObject? Background { get; set; } - public Guid AccountId { get; set; } - - public Proto.AccountProfile ToProtoValue() - { - var proto = new Proto.AccountProfile - { - Id = Id.ToString(), - FirstName = FirstName ?? string.Empty, - MiddleName = MiddleName ?? string.Empty, - LastName = LastName ?? string.Empty, - Bio = Bio ?? string.Empty, - Gender = Gender ?? string.Empty, - Pronouns = Pronouns ?? string.Empty, - TimeZone = TimeZone ?? string.Empty, - Location = Location ?? string.Empty, - Birthday = Birthday?.ToTimestamp(), - LastSeenAt = LastSeenAt?.ToTimestamp(), - Experience = Experience, - Level = Level, - LevelingProgress = LevelingProgress, - SocialCredits = SocialCredits, - SocialCreditsLevel = SocialCreditsLevel, - Picture = Picture?.ToProtoValue(), - Background = Background?.ToProtoValue(), - AccountId = AccountId.ToString(), - Verification = Verification?.ToProtoValue(), - CreatedAt = CreatedAt.ToTimestamp(), - UpdatedAt = UpdatedAt.ToTimestamp() - }; - - return proto; - } - - public static AccountProfileReference FromProtoValue(Proto.AccountProfile proto) - { - return new AccountProfileReference - { - Id = Guid.Parse(proto.Id), - FirstName = string.IsNullOrEmpty(proto.FirstName) ? null : proto.FirstName, - MiddleName = string.IsNullOrEmpty(proto.MiddleName) ? null : proto.MiddleName, - LastName = string.IsNullOrEmpty(proto.LastName) ? null : proto.LastName, - Bio = string.IsNullOrEmpty(proto.Bio) ? null : proto.Bio, - Gender = string.IsNullOrEmpty(proto.Gender) ? null : proto.Gender, - Pronouns = string.IsNullOrEmpty(proto.Pronouns) ? null : proto.Pronouns, - TimeZone = string.IsNullOrEmpty(proto.TimeZone) ? null : proto.TimeZone, - Location = string.IsNullOrEmpty(proto.Location) ? null : proto.Location, - Birthday = proto.Birthday?.ToInstant(), - LastSeenAt = proto.LastSeenAt?.ToInstant(), - Experience = proto.Experience, - SocialCredits = proto.SocialCredits, - Picture = proto.Picture != null ? CloudFileReferenceObject.FromProtoValue(proto.Picture) : null, - Background = proto.Background != null ? CloudFileReferenceObject.FromProtoValue(proto.Background) : null, - AccountId = Guid.Parse(proto.AccountId), - Verification = proto.Verification != null ? VerificationMark.FromProtoValue(proto.Verification) : null, - CreatedAt = proto.CreatedAt.ToInstant(), - UpdatedAt = proto.UpdatedAt.ToInstant() - }; - } -} - -public class AccountContactReference : ModelBase -{ - public Guid Id { get; set; } - public AccountContactReferenceType Type { get; set; } - public Instant? VerifiedAt { get; set; } - public bool IsPrimary { get; set; } = false; - public bool IsPublic { get; set; } = false; - public string Content { get; set; } = string.Empty; - - public Guid AccountId { get; set; } - - public Shared.Proto.AccountContact ToProtoValue() - { - var proto = new Shared.Proto.AccountContact - { - Id = Id.ToString(), - Type = Type switch - { - AccountContactReferenceType.Email => Shared.Proto.AccountContactType.Email, - AccountContactReferenceType.PhoneNumber => Shared.Proto.AccountContactType.PhoneNumber, - AccountContactReferenceType.Address => Shared.Proto.AccountContactType.Address, - _ => Shared.Proto.AccountContactType.Unspecified - }, - Content = Content, - IsPrimary = IsPrimary, - VerifiedAt = VerifiedAt?.ToTimestamp(), - AccountId = AccountId.ToString(), - CreatedAt = CreatedAt.ToTimestamp(), - UpdatedAt = UpdatedAt.ToTimestamp() - }; - - return proto; - } - - public static AccountContactReference FromProtoValue(Shared.Proto.AccountContact proto) - { - var contact = new AccountContactReference - { - Id = Guid.Parse(proto.Id), - AccountId = Guid.Parse(proto.AccountId), - Type = proto.Type switch - { - Shared.Proto.AccountContactType.Email => AccountContactReferenceType.Email, - Shared.Proto.AccountContactType.PhoneNumber => AccountContactReferenceType.PhoneNumber, - Shared.Proto.AccountContactType.Address => AccountContactReferenceType.Address, - _ => AccountContactReferenceType.Email - }, - Content = proto.Content, - IsPrimary = proto.IsPrimary, - VerifiedAt = proto.VerifiedAt?.ToInstant(), - CreatedAt = proto.CreatedAt.ToInstant(), - UpdatedAt = proto.UpdatedAt.ToInstant() - }; - - return contact; - } -} - -public enum AccountContactReferenceType -{ - Email, - PhoneNumber, - Address -} - -public class AccountBadgeReference : ModelBase -{ - public Guid Id { get; set; } = Guid.NewGuid(); - public string Type { get; set; } = null!; - public string? Label { get; set; } - public string? Caption { get; set; } - public Dictionary Meta { get; set; } = new(); - public Instant? ActivatedAt { get; set; } - public Instant? ExpiredAt { get; set; } - - public Guid AccountId { get; set; } - - public AccountBadge ToProtoValue() - { - var proto = new AccountBadge - { - Id = Id.ToString(), - Type = Type, - Label = Label ?? string.Empty, - Caption = Caption ?? string.Empty, - ActivatedAt = ActivatedAt?.ToTimestamp(), - ExpiredAt = ExpiredAt?.ToTimestamp(), - AccountId = AccountId.ToString(), - CreatedAt = CreatedAt.ToTimestamp(), - UpdatedAt = UpdatedAt.ToTimestamp() - }; - proto.Meta.Add(GrpcTypeHelper.ConvertToValueMap(Meta)); - - return proto; - } - - public static AccountBadgeReference FromProtoValue(AccountBadge proto) - { - var badge = new AccountBadgeReference - { - Id = Guid.Parse(proto.Id), - AccountId = Guid.Parse(proto.AccountId), - Type = proto.Type, - Label = proto.Label, - Caption = proto.Caption, - ActivatedAt = proto.ActivatedAt?.ToInstant(), - ExpiredAt = proto.ExpiredAt?.ToInstant(), - CreatedAt = proto.CreatedAt.ToInstant(), - UpdatedAt = proto.UpdatedAt.ToInstant() - }; - - return badge; - } -} - -public class ProfileLinkReference -{ - public string Name { get; set; } = string.Empty; - public string Url { get; set; } = string.Empty; -} - -public static class Leveling -{ - public static readonly List ExperiencePerLevel = - [ - 0, // Level 0 - 100, // Level 1 - 250, // Level 2 - 500, // Level 3 - 1000, // Level 4 - 2000, // Level 5 - 4000, // Level 6 - 8000, // Level 7 - 16000, // Level 8 - 32000, // Level 9 - 64000, // Level 10 - 128000, // Level 11 - 256000, // Level 12 - 512000, // Level 13 - 1024000 - ]; -} - -public class ApiKeyReference : ModelBase -{ - public Guid Id { get; set; } = Guid.NewGuid(); - public string Label { get; set; } = null!; - - public Guid AccountId { get; set; } - public Guid SessionId { get; set; } - - public string? Key { get; set; } - - public ApiKey ToProtoValue() - { - return new ApiKey - { - Id = Id.ToString(), - Label = Label, - AccountId = AccountId.ToString(), - SessionId = SessionId.ToString(), - Key = Key, - CreatedAt = CreatedAt.ToTimestamp(), - UpdatedAt = UpdatedAt.ToTimestamp() - }; - } - - public static ApiKeyReference FromProtoValue(ApiKey proto) - { - return new ApiKeyReference - { - Id = Guid.Parse(proto.Id), - AccountId = Guid.Parse(proto.AccountId), - SessionId = Guid.Parse(proto.SessionId), - Label = proto.Label, - Key = proto.Key, - CreatedAt = proto.CreatedAt.ToInstant(), - UpdatedAt = proto.UpdatedAt.ToInstant() - }; - } -} \ No newline at end of file diff --git a/DysonNetwork.Shared/Data/AccountStatus.cs b/DysonNetwork.Shared/Data/AccountStatus.cs deleted file mode 100644 index 630d514..0000000 --- a/DysonNetwork.Shared/Data/AccountStatus.cs +++ /dev/null @@ -1,58 +0,0 @@ -using DysonNetwork.Shared.Proto; -using NodaTime; -using NodaTime.Serialization.Protobuf; - -namespace DysonNetwork.Shared.Data; - -public class AccountStatusReference : ModelBase -{ - public Guid Id { get; set; } = Guid.NewGuid(); - public StatusAttitude Attitude { get; set; } - public bool IsOnline { get; set; } - public bool IsCustomized { get; set; } = true; - public bool IsInvisible { get; set; } - public bool IsNotDisturb { get; set; } - public string? Label { get; set; } - public Dictionary? Meta { get; set; } - public Instant? ClearedAt { get; set; } - - public Guid AccountId { get; set; } - - public AccountStatus ToProtoValue() - { - var proto = new AccountStatus - { - Id = Id.ToString(), - Attitude = Attitude, - IsOnline = IsOnline, - IsCustomized = IsCustomized, - IsInvisible = IsInvisible, - IsNotDisturb = IsNotDisturb, - Label = Label ?? string.Empty, - Meta = GrpcTypeHelper.ConvertObjectToByteString(Meta), - ClearedAt = ClearedAt?.ToTimestamp(), - AccountId = AccountId.ToString() - }; - - return proto; - } - - public static AccountStatusReference FromProtoValue(AccountStatus proto) - { - var status = new AccountStatusReference - { - Id = Guid.Parse(proto.Id), - Attitude = proto.Attitude, - IsOnline = proto.IsOnline, - IsCustomized = proto.IsCustomized, - IsInvisible = proto.IsInvisible, - IsNotDisturb = proto.IsNotDisturb, - Label = proto.Label, - Meta = GrpcTypeHelper.ConvertByteStringToObject>(proto.Meta), - ClearedAt = proto.ClearedAt?.ToInstant(), - AccountId = Guid.Parse(proto.AccountId) - }; - - return status; - } -} diff --git a/DysonNetwork.Shared/Data/ActionLog.cs b/DysonNetwork.Shared/Data/ActionLog.cs deleted file mode 100644 index 417521a..0000000 --- a/DysonNetwork.Shared/Data/ActionLog.cs +++ /dev/null @@ -1,42 +0,0 @@ -namespace DysonNetwork.Shared.Data; - -public abstract class ActionLogType -{ - public const string NewLogin = "login"; - public const string ChallengeAttempt = "challenges.attempt"; - public const string ChallengeSuccess = "challenges.success"; - public const string ChallengeFailure = "challenges.failure"; - public const string PostCreate = "posts.create"; - public const string PostUpdate = "posts.update"; - public const string PostDelete = "posts.delete"; - public const string PostReact = "posts.react"; - public const string PostPin = "posts.pin"; - public const string PostUnpin = "posts.unpin"; - public const string MessageCreate = "messages.create"; - public const string MessageUpdate = "messages.update"; - public const string MessageDelete = "messages.delete"; - public const string MessageReact = "messages.react"; - public const string PublisherCreate = "publishers.create"; - public const string PublisherUpdate = "publishers.update"; - public const string PublisherDelete = "publishers.delete"; - public const string PublisherMemberInvite = "publishers.members.invite"; - public const string PublisherMemberJoin = "publishers.members.join"; - public const string PublisherMemberLeave = "publishers.members.leave"; - public const string PublisherMemberKick = "publishers.members.kick"; - public const string RealmCreate = "realms.create"; - public const string RealmUpdate = "realms.update"; - public const string RealmDelete = "realms.delete"; - public const string RealmInvite = "realms.invite"; - public const string RealmJoin = "realms.join"; - public const string RealmLeave = "realms.leave"; - public const string RealmKick = "realms.kick"; - public const string RealmAdjustRole = "realms.role.edit"; - public const string ChatroomCreate = "chatrooms.create"; - public const string ChatroomUpdate = "chatrooms.update"; - public const string ChatroomDelete = "chatrooms.delete"; - public const string ChatroomInvite = "chatrooms.invite"; - public const string ChatroomJoin = "chatrooms.join"; - public const string ChatroomLeave = "chatrooms.leave"; - public const string ChatroomKick = "chatrooms.kick"; - public const string ChatroomAdjustRole = "chatrooms.role.edit"; -} diff --git a/DysonNetwork.Shared/Data/Subscription.cs b/DysonNetwork.Shared/Data/Subscription.cs deleted file mode 100644 index 1f53084..0000000 --- a/DysonNetwork.Shared/Data/Subscription.cs +++ /dev/null @@ -1,71 +0,0 @@ -using NodaTime; -using NodaTime.Serialization.Protobuf; - -namespace DysonNetwork.Shared.Data; - -public class SubscriptionReference : ModelBase -{ - public Guid Id { get; set; } - public string Identifier { get; set; } = string.Empty; - public string DisplayName { get; set; } = string.Empty; - public bool IsActive { get; set; } - public bool IsAvailable { get; set; } - public Instant BegunAt { get; set; } - public Instant? EndedAt { get; set; } - public Instant? RenewalAt { get; set; } - public SubscriptionReferenceStatus Status { get; set; } - public Guid AccountId { get; set; } - - public static SubscriptionReference FromProtoValue(Proto.SubscriptionReferenceObject proto) - { - return new SubscriptionReference - { - Id = Guid.Parse(proto.Id), - Identifier = proto.Identifier, - DisplayName = proto.DisplayName, - IsActive = proto.IsActive, - IsAvailable = proto.IsAvailable, - BegunAt = proto.BegunAt.ToInstant(), - EndedAt = proto.EndedAt?.ToInstant(), - RenewalAt = proto.RenewalAt?.ToInstant(), - Status = (SubscriptionReferenceStatus)proto.Status, - AccountId = Guid.Parse(proto.AccountId), - CreatedAt = proto.CreatedAt.ToInstant(), - UpdatedAt = proto.UpdatedAt.ToInstant(), - }; - } - - public Proto.SubscriptionReferenceObject ToProtoValue() - { - return new Proto.SubscriptionReferenceObject - { - Id = Id.ToString(), - Identifier = Identifier, - DisplayName = DisplayName, - IsActive = IsActive, - IsAvailable = IsAvailable, - BegunAt = BegunAt.ToTimestamp(), - EndedAt = EndedAt?.ToTimestamp(), - RenewalAt = RenewalAt?.ToTimestamp(), - AccountId = AccountId.ToString(), - CreatedAt = CreatedAt.ToTimestamp(), - UpdatedAt = UpdatedAt.ToTimestamp(), - Status = Status switch - { - SubscriptionReferenceStatus.Unpaid => Proto.SubscriptionStatus.Unpaid, - SubscriptionReferenceStatus.Active => Proto.SubscriptionStatus.Active, - SubscriptionReferenceStatus.Expired => Proto.SubscriptionStatus.Expired, - SubscriptionReferenceStatus.Cancelled => Proto.SubscriptionStatus.Cancelled, - _ => Proto.SubscriptionStatus.Unpaid - } - }; - } -} - -public enum SubscriptionReferenceStatus -{ - Unpaid = 0, - Active = 1, - Expired = 2, - Cancelled = 3 -} \ No newline at end of file diff --git a/DysonNetwork.Shared/DysonNetwork.Shared.csproj b/DysonNetwork.Shared/DysonNetwork.Shared.csproj index 6b0aca0..c48dec0 100644 --- a/DysonNetwork.Shared/DysonNetwork.Shared.csproj +++ b/DysonNetwork.Shared/DysonNetwork.Shared.csproj @@ -7,6 +7,7 @@ + @@ -27,6 +28,7 @@ + diff --git a/DysonNetwork.Shared/Http/KestrelConfiguration.cs b/DysonNetwork.Shared/Http/KestrelConfiguration.cs index 9868d9b..c2f1790 100644 --- a/DysonNetwork.Shared/Http/KestrelConfiguration.cs +++ b/DysonNetwork.Shared/Http/KestrelConfiguration.cs @@ -23,7 +23,7 @@ public static class KestrelConfiguration if (enableGrpc) { // gRPC - var grpcPort = int.Parse(configuration.GetValue("GRPC_PORT", "5001")); + var grpcPort = int.Parse(configuration.GetValue("GRPC_PORT", "5001")); options.ListenAnyIP(grpcPort, listenOptions => { listenOptions.Protocols = HttpProtocols.Http2; @@ -34,7 +34,7 @@ public static class KestrelConfiguration } - var httpPorts = configuration.GetValue("HTTP_PORTS", "6000") + var httpPorts = configuration.GetValue("HTTP_PORTS", "6000") .Split(',', StringSplitOptions.RemoveEmptyEntries) .Select(p => int.Parse(p.Trim())) .ToArray(); diff --git a/DysonNetwork.Pass/Account/AbuseReport.cs b/DysonNetwork.Shared/Models/AbuseReport.cs similarity index 80% rename from DysonNetwork.Pass/Account/AbuseReport.cs rename to DysonNetwork.Shared/Models/AbuseReport.cs index bc14691..14a5977 100644 --- a/DysonNetwork.Pass/Account/AbuseReport.cs +++ b/DysonNetwork.Shared/Models/AbuseReport.cs @@ -1,8 +1,7 @@ using System.ComponentModel.DataAnnotations; -using DysonNetwork.Shared.Data; using NodaTime; -namespace DysonNetwork.Pass.Account; +namespace DysonNetwork.Shared.Models; public enum AbuseReportType { @@ -16,7 +15,7 @@ public enum AbuseReportType Other } -public class AbuseReport : ModelBase +public class SnAbuseReport : ModelBase { public Guid Id { get; set; } = Guid.NewGuid(); [MaxLength(4096)] public string ResourceIdentifier { get; set; } = null!; @@ -27,5 +26,5 @@ public class AbuseReport : ModelBase [MaxLength(8192)] public string? Resolution { get; set; } public Guid AccountId { get; set; } - public Account Account { get; set; } = null!; + public SnAccount Account { get; set; } = null!; } \ No newline at end of file diff --git a/DysonNetwork.Pass/Account/Account.cs b/DysonNetwork.Shared/Models/Account.cs similarity index 80% rename from DysonNetwork.Pass/Account/Account.cs rename to DysonNetwork.Shared/Models/Account.cs index 8d627c8..f63677d 100644 --- a/DysonNetwork.Pass/Account/Account.cs +++ b/DysonNetwork.Shared/Models/Account.cs @@ -1,18 +1,15 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Text.Json.Serialization; -using DysonNetwork.Pass.Wallet; -using DysonNetwork.Shared.Data; using Microsoft.EntityFrameworkCore; using NodaTime; using NodaTime.Serialization.Protobuf; using OtpNet; -using VerificationMark = DysonNetwork.Shared.Data.VerificationMark; -namespace DysonNetwork.Pass.Account; +namespace DysonNetwork.Shared.Models; [Index(nameof(Name), IsUnique = true)] -public class Account : ModelBase +public class SnAccount : ModelBase { public Guid Id { get; set; } = Guid.NewGuid(); [MaxLength(256)] public string Name { get; set; } = string.Empty; @@ -25,23 +22,23 @@ public class Account : ModelBase // The ID is the BotAccount ID in the DysonNetwork.Develop public Guid? AutomatedId { get; set; } - public AccountProfile Profile { get; set; } = null!; - public ICollection Contacts { get; set; } = new List(); - public ICollection Badges { get; set; } = new List(); + public SnAccountProfile Profile { get; set; } = null!; + public ICollection Contacts { get; set; } = []; + public ICollection Badges { get; set; } = []; - [JsonIgnore] public ICollection AuthFactors { get; set; } = new List(); - [JsonIgnore] public ICollection Connections { get; set; } = new List(); - [JsonIgnore] public ICollection Sessions { get; set; } = new List(); - [JsonIgnore] public ICollection Challenges { get; set; } = new List(); + [JsonIgnore] public ICollection AuthFactors { get; set; } = []; + [JsonIgnore] public ICollection Connections { get; set; } = []; + [JsonIgnore] public ICollection Sessions { get; set; } = []; + [JsonIgnore] public ICollection Challenges { get; set; } = []; - [JsonIgnore] public ICollection OutgoingRelationships { get; set; } = new List(); - [JsonIgnore] public ICollection IncomingRelationships { get; set; } = new List(); + [JsonIgnore] public ICollection OutgoingRelationships { get; set; } = []; + [JsonIgnore] public ICollection IncomingRelationships { get; set; } = []; [NotMapped] public SubscriptionReferenceObject? PerkSubscription { get; set; } - public Shared.Proto.Account ToProtoValue() + public Proto.Account ToProtoValue() { - var proto = new Shared.Proto.Account + var proto = new Proto.Account { Id = Id.ToString(), Name = Name, @@ -69,9 +66,9 @@ public class Account : ModelBase } - public static Account FromProtoValue(Shared.Proto.Account proto) + public static SnAccount FromProtoValue(Proto.Account proto) { - var account = new Account + var account = new SnAccount { Id = Guid.Parse(proto.Id), Name = proto.Name, @@ -86,14 +83,14 @@ public class Account : ModelBase CreatedAt = proto.CreatedAt.ToInstant(), UpdatedAt = proto.UpdatedAt.ToInstant(), AutomatedId = proto.AutomatedId is not null ? Guid.Parse(proto.AutomatedId) : null, - Profile = AccountProfile.FromProtoValue(proto.Profile) + Profile = SnAccountProfile.FromProtoValue(proto.Profile) }; foreach (var contactProto in proto.Contacts) account.Contacts.Add(AccountContact.FromProtoValue(contactProto)); foreach (var badgeProto in proto.Badges) - account.Badges.Add(AccountBadge.FromProtoValue(badgeProto)); + account.Badges.Add(SnAccountBadge.FromProtoValue(badgeProto)); return account; } @@ -145,7 +142,7 @@ public abstract class Leveling } } -public class AccountProfile : ModelBase, IIdentifiedResource +public class SnAccountProfile : ModelBase, IIdentifiedResource { public Guid Id { get; set; } = Guid.NewGuid(); [MaxLength(256)] public string? FirstName { get; set; } @@ -160,8 +157,8 @@ public class AccountProfile : ModelBase, IIdentifiedResource public Instant? Birthday { get; set; } public Instant? LastSeenAt { get; set; } - [Column(TypeName = "jsonb")] public VerificationMark? Verification { get; set; } - [Column(TypeName = "jsonb")] public BadgeReferenceObject? ActiveBadge { get; set; } + [Column(TypeName = "jsonb")] public SnVerificationMark? Verification { get; set; } + [Column(TypeName = "jsonb")] public SnAccountBadgeRef? ActiveBadge { get; set; } public int Experience { get; set; } @@ -181,15 +178,15 @@ public class AccountProfile : ModelBase, IIdentifiedResource _ => 2 }; - [Column(TypeName = "jsonb")] public CloudFileReferenceObject? Picture { get; set; } - [Column(TypeName = "jsonb")] public CloudFileReferenceObject? Background { get; set; } + [Column(TypeName = "jsonb")] public SnCloudFileReferenceObject? Picture { get; set; } + [Column(TypeName = "jsonb")] public SnCloudFileReferenceObject? Background { get; set; } public Guid AccountId { get; set; } - [JsonIgnore] public Account Account { get; set; } = null!; + [JsonIgnore] public SnAccount Account { get; set; } = null!; - public Shared.Proto.AccountProfile ToProtoValue() + public Proto.AccountProfile ToProtoValue() { - var proto = new Shared.Proto.AccountProfile + var proto = new Proto.AccountProfile { Id = Id.ToString(), FirstName = FirstName ?? string.Empty, @@ -219,9 +216,9 @@ public class AccountProfile : ModelBase, IIdentifiedResource return proto; } - public static AccountProfile FromProtoValue(Shared.Proto.AccountProfile proto) + public static SnAccountProfile FromProtoValue(Proto.AccountProfile proto) { - var profile = new AccountProfile + var profile = new SnAccountProfile { Id = Guid.Parse(proto.Id), FirstName = proto.FirstName, @@ -234,12 +231,12 @@ public class AccountProfile : ModelBase, IIdentifiedResource Location = proto.Location, Birthday = proto.Birthday?.ToInstant(), LastSeenAt = proto.LastSeenAt?.ToInstant(), - Verification = proto.Verification is null ? null : VerificationMark.FromProtoValue(proto.Verification), - ActiveBadge = proto.ActiveBadge is null ? null : BadgeReferenceObject.FromProtoValue(proto.ActiveBadge), + Verification = proto.Verification is null ? null : SnVerificationMark.FromProtoValue(proto.Verification), + ActiveBadge = proto.ActiveBadge is null ? null : SnAccountBadgeRef.FromProtoValue(proto.ActiveBadge), Experience = proto.Experience, SocialCredits = proto.SocialCredits, - Picture = proto.Picture is null ? null : CloudFileReferenceObject.FromProtoValue(proto.Picture), - Background = proto.Background is null ? null : CloudFileReferenceObject.FromProtoValue(proto.Background), + Picture = proto.Picture is null ? null : SnCloudFileReferenceObject.FromProtoValue(proto.Picture), + Background = proto.Background is null ? null : SnCloudFileReferenceObject.FromProtoValue(proto.Background), AccountId = Guid.Parse(proto.AccountId), CreatedAt = proto.CreatedAt.ToInstant(), UpdatedAt = proto.UpdatedAt.ToInstant() @@ -267,11 +264,11 @@ public class AccountContact : ModelBase [MaxLength(1024)] public string Content { get; set; } = string.Empty; public Guid AccountId { get; set; } - [JsonIgnore] public Account Account { get; set; } = null!; + [JsonIgnore] public SnAccount Account { get; set; } = null!; - public Shared.Proto.AccountContact ToProtoValue() + public Proto.AccountContact ToProtoValue() { - var proto = new Shared.Proto.AccountContact + var proto = new Proto.AccountContact { Id = Id.ToString(), Type = Type switch @@ -292,7 +289,7 @@ public class AccountContact : ModelBase return proto; } - public static AccountContact FromProtoValue(Shared.Proto.AccountContact proto) + public static AccountContact FromProtoValue(Proto.AccountContact proto) { var contact = new AccountContact { @@ -331,7 +328,7 @@ public class AccountAuthFactor : ModelBase [JsonIgnore] [Column(TypeName = "jsonb")] - public Dictionary? Config { get; set; } = new(); + public Dictionary? Config { get; set; } = []; /// /// The trustworthy stands for how safe is this auth factor. @@ -344,7 +341,7 @@ public class AccountAuthFactor : ModelBase public Instant? ExpiredAt { get; set; } public Guid AccountId { get; set; } - [JsonIgnore] public Account Account { get; set; } = null!; + [JsonIgnore] public SnAccount Account { get; set; } = null!; public AccountAuthFactor HashSecret(int cost = 12) { @@ -394,12 +391,12 @@ public class AccountConnection : ModelBase public Guid Id { get; set; } = Guid.NewGuid(); [MaxLength(4096)] public string Provider { get; set; } = null!; [MaxLength(8192)] public string ProvidedIdentifier { get; set; } = null!; - [Column(TypeName = "jsonb")] public Dictionary? Meta { get; set; } = new(); + [Column(TypeName = "jsonb")] public Dictionary? Meta { get; set; } = []; [JsonIgnore][MaxLength(4096)] public string? AccessToken { get; set; } [JsonIgnore][MaxLength(4096)] public string? RefreshToken { get; set; } public Instant? LastUsedAt { get; set; } public Guid AccountId { get; set; } - public Account Account { get; set; } = null!; + public SnAccount Account { get; set; } = null!; } diff --git a/DysonNetwork.Pass/Account/Event.cs b/DysonNetwork.Shared/Models/AccountEvent.cs similarity index 82% rename from DysonNetwork.Pass/Account/Event.cs rename to DysonNetwork.Shared/Models/AccountEvent.cs index 8877851..23bd9fb 100644 --- a/DysonNetwork.Pass/Account/Event.cs +++ b/DysonNetwork.Shared/Models/AccountEvent.cs @@ -1,11 +1,10 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using DysonNetwork.Shared.Data; using DysonNetwork.Shared.Proto; using NodaTime; using NodaTime.Serialization.Protobuf; -namespace DysonNetwork.Pass.Account; +namespace DysonNetwork.Shared.Models; public enum StatusAttitude { @@ -14,7 +13,7 @@ public enum StatusAttitude Neutral } -public class Status : ModelBase +public class SnAccountStatus : ModelBase { public Guid Id { get; set; } = Guid.NewGuid(); public StatusAttitude Attitude { get; set; } @@ -33,11 +32,11 @@ public class Status : ModelBase public bool IsAutomated { get; set; } public Guid AccountId { get; set; } - public Account Account { get; set; } = null!; + public SnAccount Account { get; set; } = null!; - public Shared.Proto.AccountStatus ToProtoValue() + public AccountStatus ToProtoValue() { - var proto = new Shared.Proto.AccountStatus + var proto = new AccountStatus { Id = Id.ToString(), Attitude = Attitude switch @@ -60,9 +59,9 @@ public class Status : ModelBase return proto; } - public static Status FromProtoValue(Shared.Proto.AccountStatus proto) + public static SnAccountStatus FromProtoValue(AccountStatus proto) { - var status = new Status + var status = new SnAccountStatus { Id = Guid.Parse(proto.Id), Attitude = proto.Attitude switch @@ -96,21 +95,21 @@ public enum CheckInResultLevel Special } -public class CheckInResult : ModelBase +public class SnCheckInResult : ModelBase { public Guid Id { get; set; } = Guid.NewGuid(); public CheckInResultLevel Level { get; set; } public decimal? RewardPoints { get; set; } public int? RewardExperience { get; set; } - [Column(TypeName = "jsonb")] public ICollection Tips { get; set; } = new List(); + [Column(TypeName = "jsonb")] public ICollection Tips { get; set; } = new List(); public Guid AccountId { get; set; } - public Account Account { get; set; } = null!; + public SnAccount Account { get; set; } = null!; public Instant? BackdatedFrom { get; set; } } -public class FortuneTip +public class CheckInFortuneTip { public bool IsPositive { get; set; } public string Title { get; set; } = null!; @@ -123,6 +122,6 @@ public class FortuneTip public class DailyEventResponse { public Instant Date { get; set; } - public CheckInResult? CheckInResult { get; set; } - public ICollection Statuses { get; set; } = new List(); + public SnCheckInResult? CheckInResult { get; set; } + public ICollection Statuses { get; set; } = new List(); } diff --git a/DysonNetwork.Pass/Account/ActionLog.cs b/DysonNetwork.Shared/Models/ActionLog.cs similarity index 78% rename from DysonNetwork.Pass/Account/ActionLog.cs rename to DysonNetwork.Shared/Models/ActionLog.cs index ec3da76..35998ff 100644 --- a/DysonNetwork.Pass/Account/ActionLog.cs +++ b/DysonNetwork.Shared/Models/ActionLog.cs @@ -1,15 +1,12 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using System.Text.Json.Serialization; -using DysonNetwork.Shared.Data; using DysonNetwork.Shared.GeoIp; using DysonNetwork.Shared.Proto; using NodaTime.Serialization.Protobuf; -using Point = NetTopologySuite.Geometries.Point; -namespace DysonNetwork.Pass.Account; +namespace DysonNetwork.Shared.Models; -public class ActionLog : ModelBase +public class SnActionLog : ModelBase { public Guid Id { get; set; } = Guid.NewGuid(); [MaxLength(4096)] public string Action { get; set; } = null!; @@ -19,12 +16,12 @@ public class ActionLog : ModelBase [Column(TypeName = "jsonb")] public GeoPoint? Location { get; set; } public Guid AccountId { get; set; } - public Account Account { get; set; } = null!; + public SnAccount Account { get; set; } = null!; public Guid? SessionId { get; set; } - public Shared.Proto.ActionLog ToProtoValue() + public ActionLog ToProtoValue() { - var protoLog = new Shared.Proto.ActionLog + var protoLog = new ActionLog { Id = Id.ToString(), Action = Action, diff --git a/DysonNetwork.Sphere/Activity/Activity.cs b/DysonNetwork.Shared/Models/Activity.cs similarity index 79% rename from DysonNetwork.Sphere/Activity/Activity.cs rename to DysonNetwork.Shared/Models/Activity.cs index ab602a0..6ec3e02 100644 --- a/DysonNetwork.Sphere/Activity/Activity.cs +++ b/DysonNetwork.Shared/Models/Activity.cs @@ -1,17 +1,16 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using DysonNetwork.Shared.Data; using NodaTime; -namespace DysonNetwork.Sphere.Activity; +namespace DysonNetwork.Shared.Models; public interface IActivity { - public Activity ToActivity(); + public SnActivity ToActivity(); } [NotMapped] -public class Activity : ModelBase +public class SnActivity : ModelBase { public Guid Id { get; set; } [MaxLength(1024)] public string Type { get; set; } = null!; @@ -23,10 +22,10 @@ public class Activity : ModelBase // Outdated fields, for backward compability public int Visibility => 0; - public static Activity Empty() + public static SnActivity Empty() { var now = SystemClock.Instance.GetCurrentInstant(); - return new Activity + return new SnActivity { CreatedAt = now, UpdatedAt = now, diff --git a/DysonNetwork.Pass/Auth/ApiKey.cs b/DysonNetwork.Shared/Models/ApiKey.cs similarity index 72% rename from DysonNetwork.Pass/Auth/ApiKey.cs rename to DysonNetwork.Shared/Models/ApiKey.cs index 4a1781a..c296ad2 100644 --- a/DysonNetwork.Pass/Auth/ApiKey.cs +++ b/DysonNetwork.Shared/Models/ApiKey.cs @@ -1,28 +1,27 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Text.Json.Serialization; -using DysonNetwork.Shared.Data; using NodaTime.Serialization.Protobuf; -namespace DysonNetwork.Pass.Auth; +namespace DysonNetwork.Shared.Models; -public class ApiKey : ModelBase +public class SnApiKey : ModelBase { public Guid Id { get; set; } = Guid.NewGuid(); [MaxLength(1024)] public string Label { get; set; } = null!; public Guid AccountId { get; set; } - public Account.Account Account { get; set; } = null!; + public SnAccount Account { get; set; } = null!; public Guid SessionId { get; set; } - public AuthSession Session { get; set; } = null!; + public SnAuthSession Session { get; set; } = null!; [NotMapped] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public string? Key { get; set; } - public DysonNetwork.Shared.Proto.ApiKey ToProtoValue() + public Proto.ApiKey ToProtoValue() { - return new DysonNetwork.Shared.Proto.ApiKey + return new Proto.ApiKey { Id = Id.ToString(), Label = Label, @@ -34,9 +33,9 @@ public class ApiKey : ModelBase }; } - public static ApiKey FromProtoValue(DysonNetwork.Shared.Proto.ApiKey proto) + public static SnApiKey FromProtoValue(Proto.ApiKey proto) { - return new ApiKey + return new SnApiKey { Id = Guid.Parse(proto.Id), AccountId = Guid.Parse(proto.AccountId), diff --git a/DysonNetwork.Pass/Auth/AuthSession.cs b/DysonNetwork.Shared/Models/AuthSession.cs similarity index 77% rename from DysonNetwork.Pass/Auth/AuthSession.cs rename to DysonNetwork.Shared/Models/AuthSession.cs index 2d41ed5..fc7c8d4 100644 --- a/DysonNetwork.Pass/Auth/AuthSession.cs +++ b/DysonNetwork.Shared/Models/AuthSession.cs @@ -1,31 +1,29 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Text.Json.Serialization; -using DysonNetwork.Shared.Data; using DysonNetwork.Shared.GeoIp; using NodaTime; using NodaTime.Serialization.Protobuf; -using Point = NetTopologySuite.Geometries.Point; -namespace DysonNetwork.Pass.Auth; +namespace DysonNetwork.Shared.Models; -public class AuthSession : ModelBase +public class SnAuthSession : ModelBase { public Guid Id { get; set; } = Guid.NewGuid(); public Instant? LastGrantedAt { get; set; } public Instant? ExpiredAt { get; set; } public Guid AccountId { get; set; } - [JsonIgnore] public Account.Account Account { get; set; } = null!; + [JsonIgnore] public SnAccount Account { get; set; } = null!; // When the challenge is null, indicates the session is for an API Key public Guid? ChallengeId { get; set; } - public AuthChallenge? Challenge { get; set; } = null!; + public SnAuthChallenge? Challenge { get; set; } = null!; // Indicates the session is for an OIDC connection public Guid? AppId { get; set; } - public Shared.Proto.AuthSession ToProtoValue() => new() + public Proto.AuthSession ToProtoValue() => new() { Id = Id.ToString(), LastGrantedAt = LastGrantedAt?.ToTimestamp(), @@ -56,7 +54,7 @@ public enum ClientPlatform Linux } -public class AuthChallenge : ModelBase +public class SnAuthChallenge : ModelBase { public Guid Id { get; set; } = Guid.NewGuid(); public Instant? ExpiredAt { get; set; } @@ -73,24 +71,24 @@ public class AuthChallenge : ModelBase [Column(TypeName = "jsonb")] public GeoPoint? Location { get; set; } public Guid AccountId { get; set; } - [JsonIgnore] public Account.Account Account { get; set; } = null!; + [JsonIgnore] public SnAccount Account { get; set; } = null!; public Guid? ClientId { get; set; } - public AuthClient? Client { get; set; } = null!; + public SnAuthClient? Client { get; set; } = null!; - public AuthChallenge Normalize() + public SnAuthChallenge Normalize() { if (StepRemain == 0 && BlacklistFactors.Count == 0) StepRemain = StepTotal; return this; } - public Shared.Proto.AuthChallenge ToProtoValue() => new() + public Proto.AuthChallenge ToProtoValue() => new() { Id = Id.ToString(), ExpiredAt = ExpiredAt?.ToTimestamp(), StepRemain = StepRemain, StepTotal = StepTotal, FailedAttempts = FailedAttempts, - Type = (Shared.Proto.ChallengeType)Type, + Type = (Proto.ChallengeType)Type, BlacklistFactors = { BlacklistFactors.Select(x => x.ToString()) }, Audiences = { Audiences }, Scopes = { Scopes }, @@ -102,7 +100,7 @@ public class AuthChallenge : ModelBase }; } -public class AuthClient : ModelBase +public class SnAuthClient : ModelBase { public Guid Id { get; set; } = Guid.NewGuid(); public ClientPlatform Platform { get; set; } = ClientPlatform.Unidentified; @@ -111,16 +109,16 @@ public class AuthClient : ModelBase [MaxLength(1024)] public string DeviceId { get; set; } = string.Empty; public Guid AccountId { get; set; } - [JsonIgnore] public Account.Account Account { get; set; } = null!; + [JsonIgnore] public SnAccount Account { get; set; } = null!; } -public class AuthClientWithChallenge : AuthClient +public class SnAuthClientWithChallenge : SnAuthClient { - public List Challenges { get; set; } = []; + public List Challenges { get; set; } = []; - public static AuthClientWithChallenge FromClient(AuthClient client) + public static SnAuthClientWithChallenge FromClient(SnAuthClient client) { - return new AuthClientWithChallenge + return new SnAuthClientWithChallenge { Id = client.Id, Platform = client.Platform, diff --git a/DysonNetwork.Pass/Account/Badge.cs b/DysonNetwork.Shared/Models/Badge.cs similarity index 79% rename from DysonNetwork.Pass/Account/Badge.cs rename to DysonNetwork.Shared/Models/Badge.cs index 0e98bb6..2ce80b7 100644 --- a/DysonNetwork.Pass/Account/Badge.cs +++ b/DysonNetwork.Shared/Models/Badge.cs @@ -1,15 +1,14 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Text.Json.Serialization; -using DysonNetwork.Shared.Data; using DysonNetwork.Shared.Proto; using Google.Protobuf.WellKnownTypes; using NodaTime; using NodaTime.Serialization.Protobuf; -namespace DysonNetwork.Pass.Account; +namespace DysonNetwork.Shared.Models; -public class AccountBadge : ModelBase +public class SnAccountBadge : ModelBase { public Guid Id { get; set; } = Guid.NewGuid(); [MaxLength(1024)] public string Type { get; set; } = null!; @@ -20,11 +19,11 @@ public class AccountBadge : ModelBase public Instant? ExpiredAt { get; set; } public Guid AccountId { get; set; } - [JsonIgnore] public Account Account { get; set; } = null!; + [JsonIgnore] public SnAccount Account { get; set; } = null!; - public BadgeReferenceObject ToReference() + public SnAccountBadgeRef ToReference() { - return new BadgeReferenceObject + return new SnAccountBadgeRef { Id = Id, Type = Type, @@ -37,9 +36,9 @@ public class AccountBadge : ModelBase }; } - public Shared.Proto.AccountBadge ToProtoValue() + public AccountBadge ToProtoValue() { - var proto = new Shared.Proto.AccountBadge + var proto = new AccountBadge { Id = Id.ToString(), Type = Type, @@ -56,9 +55,9 @@ public class AccountBadge : ModelBase return proto; } - public static AccountBadge FromProtoValue(Shared.Proto.AccountBadge proto) + public static SnAccountBadge FromProtoValue(AccountBadge proto) { - var badge = new AccountBadge + var badge = new SnAccountBadge { Id = Guid.Parse(proto.Id), AccountId = Guid.Parse(proto.AccountId), @@ -75,20 +74,20 @@ public class AccountBadge : ModelBase } } -public class BadgeReferenceObject : ModelBase +public class SnAccountBadgeRef : ModelBase { public Guid Id { get; set; } public string Type { get; set; } = null!; public string? Label { get; set; } public string? Caption { get; set; } - public Dictionary Meta { get; set; } + public Dictionary Meta { get; set; } = new(); public Instant? ActivatedAt { get; set; } public Instant? ExpiredAt { get; set; } public Guid AccountId { get; set; } - public Shared.Proto.BadgeReferenceObject ToProtoValue() + public BadgeReferenceObject ToProtoValue() { - var proto = new Shared.Proto.BadgeReferenceObject + var proto = new BadgeReferenceObject { Id = Id.ToString(), Type = Type, @@ -104,9 +103,9 @@ public class BadgeReferenceObject : ModelBase } - public static BadgeReferenceObject FromProtoValue(Shared.Proto.BadgeReferenceObject proto) + public static SnAccountBadgeRef FromProtoValue(BadgeReferenceObject proto) { - var badge = new BadgeReferenceObject + var badge = new SnAccountBadgeRef { Id = Guid.Parse(proto.Id), Type = proto.Type, diff --git a/DysonNetwork.Develop/Identity/BotAccount.cs b/DysonNetwork.Shared/Models/BotAccount.cs similarity index 69% rename from DysonNetwork.Develop/Identity/BotAccount.cs rename to DysonNetwork.Shared/Models/BotAccount.cs index bad036a..eace5de 100644 --- a/DysonNetwork.Develop/Identity/BotAccount.cs +++ b/DysonNetwork.Shared/Models/BotAccount.cs @@ -1,12 +1,11 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using DysonNetwork.Develop.Project; using DysonNetwork.Shared.Data; using NodaTime.Serialization.Protobuf; -namespace DysonNetwork.Develop.Identity; +namespace DysonNetwork.Shared.Models; -public class BotAccount : ModelBase +public class SnBotAccount : ModelBase { public Guid Id { get; set; } = Guid.NewGuid(); [MaxLength(1024)] public string Slug { get; set; } = null!; @@ -14,19 +13,19 @@ public class BotAccount : ModelBase public bool IsActive { get; set; } = true; public Guid ProjectId { get; set; } - public DevProject Project { get; set; } = null!; + public SnDevProject Project { get; set; } = null!; - [NotMapped] public AccountReference? Account { get; set; } + [NotMapped] public SnAccount? Account { get; set; } /// /// This developer field is to serve the transparent info for user to know which developer /// published this robot. Not for relationships usage. /// - [NotMapped] public Developer? Developer { get; set; } + [NotMapped] public SnDeveloper? Developer { get; set; } - public Shared.Proto.BotAccount ToProtoValue() + public Proto.BotAccount ToProtoValue() { - var proto = new Shared.Proto.BotAccount + var proto = new Proto.BotAccount { Slug = Slug, IsActive = IsActive, @@ -38,9 +37,9 @@ public class BotAccount : ModelBase return proto; } - public static BotAccount FromProto(Shared.Proto.BotAccount proto) + public static SnBotAccount FromProto(Proto.BotAccount proto) { - var botAccount = new BotAccount + var botAccount = new SnBotAccount { Id = Guid.Parse(proto.AutomatedId), Slug = proto.Slug, diff --git a/DysonNetwork.Sphere/Chat/Message.cs b/DysonNetwork.Shared/Models/ChatMessage.cs similarity index 71% rename from DysonNetwork.Sphere/Chat/Message.cs rename to DysonNetwork.Shared/Models/ChatMessage.cs index f342968..75e3de1 100644 --- a/DysonNetwork.Sphere/Chat/Message.cs +++ b/DysonNetwork.Shared/Models/ChatMessage.cs @@ -1,12 +1,11 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Text.Json.Serialization; -using DysonNetwork.Shared.Data; using NodaTime; -namespace DysonNetwork.Sphere.Chat; +namespace DysonNetwork.Shared.Models; -public class Message : ModelBase, IIdentifiedResource +public class SnChatMessage : ModelBase, IIdentifiedResource { public Guid Id { get; set; } = Guid.NewGuid(); [MaxLength(1024)] public string Type { get; set; } = null!; @@ -16,19 +15,19 @@ public class Message : ModelBase, IIdentifiedResource [MaxLength(36)] public string Nonce { get; set; } = null!; public Instant? EditedAt { get; set; } - [Column(TypeName = "jsonb")] public List Attachments { get; set; } = []; + [Column(TypeName = "jsonb")] public List Attachments { get; set; } = []; - public ICollection Reactions { get; set; } = new List(); + public ICollection Reactions { get; set; } = new List(); public Guid? RepliedMessageId { get; set; } - public Message? RepliedMessage { get; set; } + public SnChatMessage? RepliedMessage { get; set; } public Guid? ForwardedMessageId { get; set; } - public Message? ForwardedMessage { get; set; } + public SnChatMessage? ForwardedMessage { get; set; } public Guid SenderId { get; set; } - public ChatMember Sender { get; set; } = null!; + public SnChatMember Sender { get; set; } = null!; public Guid ChatRoomId { get; set; } - [JsonIgnore] public ChatRoom ChatRoom { get; set; } = null!; + [JsonIgnore] public SnChatRoom ChatRoom { get; set; } = null!; public string ResourceIdentifier => $"message:{Id}"; @@ -36,9 +35,9 @@ public class Message : ModelBase, IIdentifiedResource /// Creates a shallow clone of this message for sync operations /// /// A new Message instance with copied properties - public Message Clone() + public SnChatMessage Clone() { - return new Message + return new SnChatMessage { Id = Id, Type = Type, @@ -67,13 +66,13 @@ public enum MessageReactionAttitude Negative, } -public class MessageReaction : ModelBase +public class SnChatMessageReaction : ModelBase { public Guid Id { get; set; } = Guid.NewGuid(); public Guid MessageId { get; set; } - [JsonIgnore] public Message Message { get; set; } = null!; + [JsonIgnore] public SnChatMessage Message { get; set; } = null!; public Guid SenderId { get; set; } - public ChatMember Sender { get; set; } = null!; + public SnChatMember Sender { get; set; } = null!; [MaxLength(256)] public string Symbol { get; set; } = null!; public MessageReactionAttitude Attitude { get; set; } diff --git a/DysonNetwork.Sphere/Chat/ChatRoom.cs b/DysonNetwork.Shared/Models/ChatRoom.cs similarity index 82% rename from DysonNetwork.Sphere/Chat/ChatRoom.cs rename to DysonNetwork.Shared/Models/ChatRoom.cs index 639493a..40a9a57 100644 --- a/DysonNetwork.Sphere/Chat/ChatRoom.cs +++ b/DysonNetwork.Shared/Models/ChatRoom.cs @@ -1,10 +1,9 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Text.Json.Serialization; -using DysonNetwork.Shared.Data; using NodaTime; -namespace DysonNetwork.Sphere.Chat; +namespace DysonNetwork.Shared.Models; public enum ChatRoomType { @@ -12,7 +11,7 @@ public enum ChatRoomType DirectMessage } -public class ChatRoom : ModelBase, IIdentifiedResource +public class SnChatRoom : ModelBase, IIdentifiedResource { public Guid Id { get; set; } [MaxLength(1024)] public string? Name { get; set; } @@ -25,13 +24,13 @@ public class ChatRoom : ModelBase, IIdentifiedResource [MaxLength(32)] public string? PictureId { get; set; } [MaxLength(32)] public string? BackgroundId { get; set; } - [Column(TypeName = "jsonb")] public CloudFileReferenceObject? Picture { get; set; } - [Column(TypeName = "jsonb")] public CloudFileReferenceObject? Background { get; set; } + [Column(TypeName = "jsonb")] public SnCloudFileReferenceObject? Picture { get; set; } + [Column(TypeName = "jsonb")] public SnCloudFileReferenceObject? Background { get; set; } - [JsonIgnore] public ICollection Members { get; set; } = new List(); + [JsonIgnore] public ICollection Members { get; set; } = new List(); public Guid? RealmId { get; set; } - public Realm.Realm? Realm { get; set; } + public SnRealm? Realm { get; set; } [NotMapped] [JsonPropertyName("members")] @@ -67,14 +66,14 @@ public class ChatTimeoutCause public Guid? SenderId { get; set; } } -public class ChatMember : ModelBase +public class SnChatMember : ModelBase { public Guid Id { get; set; } public Guid ChatRoomId { get; set; } - public ChatRoom ChatRoom { get; set; } = null!; + public SnChatRoom ChatRoom { get; set; } = null!; public Guid AccountId { get; set; } - [NotMapped] public AccountReference? Account { get; set; } - [NotMapped] public AccountStatusReference? Status { get; set; } + [NotMapped] public SnAccount? Account { get; set; } + [NotMapped] public SnAccountStatus? Status { get; set; } [MaxLength(1024)] public string? Nick { get; set; } @@ -106,7 +105,7 @@ public class ChatMemberTransmissionObject : ModelBase public Guid Id { get; set; } public Guid ChatRoomId { get; set; } public Guid AccountId { get; set; } - [NotMapped] public AccountReference Account { get; set; } = null!; + [NotMapped] public SnAccount Account { get; set; } = null!; [MaxLength(1024)] public string? Nick { get; set; } @@ -120,7 +119,7 @@ public class ChatMemberTransmissionObject : ModelBase public Instant? TimeoutUntil { get; set; } public ChatTimeoutCause? TimeoutCause { get; set; } - public static ChatMemberTransmissionObject FromEntity(ChatMember member) + public static ChatMemberTransmissionObject FromEntity(SnChatMember member) { return new ChatMemberTransmissionObject { diff --git a/DysonNetwork.Drive/Storage/CloudFile.cs b/DysonNetwork.Shared/Models/CloudFile.cs similarity index 89% rename from DysonNetwork.Drive/Storage/CloudFile.cs rename to DysonNetwork.Shared/Models/CloudFile.cs index 3469006..94b3295 100644 --- a/DysonNetwork.Drive/Storage/CloudFile.cs +++ b/DysonNetwork.Shared/Models/CloudFile.cs @@ -1,14 +1,13 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Text.Json.Serialization; -using DysonNetwork.Shared.Data; using DysonNetwork.Shared.Proto; using NodaTime; using NodaTime.Serialization.Protobuf; -namespace DysonNetwork.Drive.Storage; +namespace DysonNetwork.Shared.Models; -public class CloudFile : ModelBase, ICloudFile, IIdentifiedResource +public class SnCloudFile : ModelBase, ICloudFile, IIdentifiedResource { /// The id generated by TuS, basically just UUID remove the dash lines [MaxLength(32)] @@ -30,7 +29,7 @@ public class CloudFile : ModelBase, ICloudFile, IIdentifiedResource public FilePool? Pool { get; set; } public Guid? PoolId { get; set; } - [JsonIgnore] public FileBundle? Bundle { get; set; } + [JsonIgnore] public SnFileBundle? Bundle { get; set; } public Guid? BundleId { get; set; } /// @@ -56,14 +55,14 @@ public class CloudFile : ModelBase, ICloudFile, IIdentifiedResource [NotMapped] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public string? FastUploadLink { get; set; } - + public ICollection References { get; set; } = new List(); public Guid AccountId { get; set; } - public CloudFileReferenceObject ToReferenceObject() + public SnCloudFileReferenceObject ToReferenceObject() { - return new CloudFileReferenceObject + return new SnCloudFileReferenceObject { CreatedAt = CreatedAt, UpdatedAt = UpdatedAt, @@ -86,9 +85,9 @@ public class CloudFile : ModelBase, ICloudFile, IIdentifiedResource /// Converts the CloudFile to a protobuf message /// /// The protobuf message representation of this object - public Shared.Proto.CloudFile ToProtoValue() + public Proto.CloudFile ToProtoValue() { - var proto = new Shared.Proto.CloudFile + var proto = new Proto.CloudFile { Id = Id, Name = Name, @@ -114,7 +113,7 @@ public class CloudFileReference : ModelBase { public Guid Id { get; set; } = Guid.NewGuid(); [MaxLength(32)] public string FileId { get; set; } = null!; - public CloudFile File { get; set; } = null!; + public SnCloudFile File { get; set; } = null!; [MaxLength(1024)] public string Usage { get; set; } = null!; [MaxLength(1024)] public string ResourceId { get; set; } = null!; @@ -127,9 +126,9 @@ public class CloudFileReference : ModelBase /// Converts the CloudFileReference to a protobuf message /// /// The protobuf message representation of this object - public Shared.Proto.CloudFileReference ToProtoValue() + public Proto.CloudFileReference ToProtoValue() { - return new Shared.Proto.CloudFileReference + return new Proto.CloudFileReference { Id = Id.ToString(), FileId = FileId, diff --git a/DysonNetwork.Shared/Data/CloudFileReferenceObject.cs b/DysonNetwork.Shared/Models/CloudFileReferenceObject.cs similarity index 77% rename from DysonNetwork.Shared/Data/CloudFileReferenceObject.cs rename to DysonNetwork.Shared/Models/CloudFileReferenceObject.cs index 2420442..dad0421 100644 --- a/DysonNetwork.Shared/Data/CloudFileReferenceObject.cs +++ b/DysonNetwork.Shared/Models/CloudFileReferenceObject.cs @@ -1,6 +1,6 @@ using DysonNetwork.Shared.Proto; -namespace DysonNetwork.Shared.Data; +namespace DysonNetwork.Shared.Models; public enum ContentSensitiveMark { @@ -23,7 +23,7 @@ public enum ContentSensitiveMark /// The class that used in jsonb columns which referenced the cloud file. /// The aim of this class is to store some properties that won't change to a file to reduce the database load. /// -public class CloudFileReferenceObject : ModelBase, ICloudFile +public class SnCloudFileReferenceObject : ModelBase, ICloudFile { public string Id { get; set; } = null!; public string Name { get; set; } = string.Empty; @@ -35,9 +35,9 @@ public class CloudFileReferenceObject : ModelBase, ICloudFile public long Size { get; set; } public bool HasCompression { get; set; } = false; - public static CloudFileReferenceObject FromProtoValue(Proto.CloudFile proto) + public static SnCloudFileReferenceObject FromProtoValue(Proto.CloudFile proto) { - return new CloudFileReferenceObject + return new SnCloudFileReferenceObject { Id = proto.Id, Name = proto.Name, @@ -67,17 +67,14 @@ public class CloudFileReferenceObject : ModelBase, ICloudFile Size = Size, HasCompression = HasCompression, ContentType = MimeType ?? string.Empty, - Url = string.Empty // This should be set by the caller if needed + Url = string.Empty, + // Convert file metadata + FileMeta = GrpcTypeHelper.ConvertObjectToByteString(FileMeta), + // Convert user metadata + UserMeta = GrpcTypeHelper.ConvertObjectToByteString(UserMeta), + SensitiveMarks = GrpcTypeHelper.ConvertObjectToByteString(SensitiveMarks) }; - // Convert file metadata - proto.FileMeta = GrpcTypeHelper.ConvertObjectToByteString(FileMeta); - - // Convert user metadata - proto.UserMeta = GrpcTypeHelper.ConvertObjectToByteString(UserMeta); - - proto.SensitiveMarks = GrpcTypeHelper.ConvertObjectToByteString(SensitiveMarks); - return proto; } } \ No newline at end of file diff --git a/DysonNetwork.Develop/Identity/CustomApp.cs b/DysonNetwork.Shared/Models/CustomApp.cs similarity index 75% rename from DysonNetwork.Develop/Identity/CustomApp.cs rename to DysonNetwork.Shared/Models/CustomApp.cs index 444dcf8..d691a8c 100644 --- a/DysonNetwork.Develop/Identity/CustomApp.cs +++ b/DysonNetwork.Shared/Models/CustomApp.cs @@ -1,17 +1,13 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Text.Json.Serialization; -using DysonNetwork.Develop.Project; -using DysonNetwork.Shared.Data; -using DysonNetwork.Shared.Proto; -using Google.Protobuf; using Google.Protobuf.WellKnownTypes; using NodaTime.Serialization.Protobuf; using NodaTime; -using VerificationMark = DysonNetwork.Shared.Data.VerificationMark; +using SnVerificationMark = DysonNetwork.Shared.Models.SnVerificationMark; -namespace DysonNetwork.Develop.Identity; +namespace DysonNetwork.Shared.Models; public enum CustomAppStatus { @@ -21,7 +17,7 @@ public enum CustomAppStatus Suspended } -public class CustomApp : ModelBase, IIdentifiedResource +public class SnCustomApp : ModelBase, IIdentifiedResource { public Guid Id { get; set; } = Guid.NewGuid(); [MaxLength(1024)] public string Slug { get; set; } = null!; @@ -29,26 +25,26 @@ public class CustomApp : ModelBase, IIdentifiedResource [MaxLength(4096)] public string? Description { get; set; } public CustomAppStatus Status { get; set; } = CustomAppStatus.Developing; - [Column(TypeName = "jsonb")] public CloudFileReferenceObject? Picture { get; set; } - [Column(TypeName = "jsonb")] public CloudFileReferenceObject? Background { get; set; } + [Column(TypeName = "jsonb")] public SnCloudFileReferenceObject? Picture { get; set; } + [Column(TypeName = "jsonb")] public SnCloudFileReferenceObject? Background { get; set; } - [Column(TypeName = "jsonb")] public VerificationMark? Verification { get; set; } + [Column(TypeName = "jsonb")] public SnVerificationMark? Verification { get; set; } [Column(TypeName = "jsonb")] public CustomAppOauthConfig? OauthConfig { get; set; } [Column(TypeName = "jsonb")] public CustomAppLinks? Links { get; set; } - [JsonIgnore] public ICollection Secrets { get; set; } = new List(); + [JsonIgnore] public ICollection Secrets { get; set; } = new List(); public Guid ProjectId { get; set; } - public DevProject Project { get; set; } = null!; + public SnDevProject Project { get; set; } = null!; [NotMapped] - public Developer Developer => Project.Developer; + public SnDeveloper Developer => Project.Developer; [NotMapped] public string ResourceIdentifier => "custom-app:" + Id; - public Shared.Proto.CustomApp ToProto() + public Proto.CustomApp ToProto() { - return new Shared.Proto.CustomApp + return new Proto.CustomApp { Id = Id.ToString(), Slug = Slug, @@ -65,13 +61,13 @@ public class CustomApp : ModelBase, IIdentifiedResource Picture = Picture?.ToProtoValue(), Background = Background?.ToProtoValue(), Verification = Verification?.ToProtoValue(), - Links = Links is null ? null : new DysonNetwork.Shared.Proto.CustomAppLinks + Links = Links is null ? null : new Proto.CustomAppLinks { HomePage = Links.HomePage ?? string.Empty, PrivacyPolicy = Links.PrivacyPolicy ?? string.Empty, TermsOfService = Links.TermsOfService ?? string.Empty }, - OauthConfig = OauthConfig is null ? null : new DysonNetwork.Shared.Proto.CustomAppOauthConfig + OauthConfig = OauthConfig is null ? null : new Proto.CustomAppOauthConfig { ClientUri = OauthConfig.ClientUri ?? string.Empty, RedirectUris = { OauthConfig.RedirectUris ?? [] }, @@ -87,7 +83,7 @@ public class CustomApp : ModelBase, IIdentifiedResource }; } - public CustomApp FromProtoValue(Shared.Proto.CustomApp p) + public SnCustomApp FromProtoValue(Proto.CustomApp p) { Id = Guid.Parse(p.Id); Slug = p.Slug; @@ -104,9 +100,9 @@ public class CustomApp : ModelBase, IIdentifiedResource ProjectId = string.IsNullOrEmpty(p.ProjectId) ? Guid.Empty : Guid.Parse(p.ProjectId); CreatedAt = p.CreatedAt.ToInstant(); UpdatedAt = p.UpdatedAt.ToInstant(); - if (p.Picture is not null) Picture = CloudFileReferenceObject.FromProtoValue(p.Picture); - if (p.Background is not null) Background = CloudFileReferenceObject.FromProtoValue(p.Background); - if (p.Verification is not null) Verification = VerificationMark.FromProtoValue(p.Verification); + if (p.Picture is not null) Picture = SnCloudFileReferenceObject.FromProtoValue(p.Picture); + if (p.Background is not null) Background = SnCloudFileReferenceObject.FromProtoValue(p.Background); + if (p.Verification is not null) Verification = SnVerificationMark.FromProtoValue(p.Verification); if (p.Links is not null) { Links = new CustomAppLinks @@ -138,7 +134,7 @@ public class CustomAppOauthConfig public bool AllowOfflineAccess { get; set; } = false; } -public class CustomAppSecret : ModelBase +public class SnCustomAppSecret : ModelBase { public Guid Id { get; set; } = Guid.NewGuid(); [MaxLength(1024)] public string Secret { get; set; } = null!; @@ -147,12 +143,12 @@ public class CustomAppSecret : ModelBase public bool IsOidc { get; set; } = false; // Indicates if this secret is for OIDC/OAuth public Guid AppId { get; set; } - public CustomApp App { get; set; } = null!; + public SnCustomApp App { get; set; } = null!; - public static CustomAppSecret FromProtoValue(DysonNetwork.Shared.Proto.CustomAppSecret p) + public static SnCustomAppSecret FromProtoValue(Proto.CustomAppSecret p) { - return new CustomAppSecret + return new SnCustomAppSecret { Id = Guid.Parse(p.Id), Secret = p.Secret, @@ -163,9 +159,9 @@ public class CustomAppSecret : ModelBase }; } - public DysonNetwork.Shared.Proto.CustomAppSecret ToProto() + public Proto.CustomAppSecret ToProto() { - return new DysonNetwork.Shared.Proto.CustomAppSecret + return new Proto.CustomAppSecret { Id = Id.ToString(), Secret = Secret, diff --git a/DysonNetwork.Develop/Project/DevProject.cs b/DysonNetwork.Shared/Models/DevProject.cs similarity index 64% rename from DysonNetwork.Develop/Project/DevProject.cs rename to DysonNetwork.Shared/Models/DevProject.cs index 5566a43..a08fb0c 100644 --- a/DysonNetwork.Develop/Project/DevProject.cs +++ b/DysonNetwork.Shared/Models/DevProject.cs @@ -1,16 +1,14 @@ using System.ComponentModel.DataAnnotations; -using DysonNetwork.Develop.Identity; -using DysonNetwork.Shared.Data; -namespace DysonNetwork.Develop.Project; +namespace DysonNetwork.Shared.Models; -public class DevProject : ModelBase +public class SnDevProject : ModelBase { public Guid Id { get; set; } = Guid.NewGuid(); [MaxLength(1024)] public string Slug { get; set; } = string.Empty; [MaxLength(1024)] public string Name { get; set; } = string.Empty; [MaxLength(4096)] public string Description { get; set; } = string.Empty; - public Developer Developer { get; set; } = null!; + public SnDeveloper Developer { get; set; } = null!; public Guid DeveloperId { get; set; } } \ No newline at end of file diff --git a/DysonNetwork.Shared/Models/Developer.cs b/DysonNetwork.Shared/Models/Developer.cs new file mode 100644 index 0000000..a355533 --- /dev/null +++ b/DysonNetwork.Shared/Models/Developer.cs @@ -0,0 +1,14 @@ +using System.ComponentModel.DataAnnotations.Schema; +using System.Text.Json.Serialization; + +namespace DysonNetwork.Shared.Models; + +public class SnDeveloper +{ + public Guid Id { get; set; } = Guid.NewGuid(); + public Guid PublisherId { get; set; } + + [JsonIgnore] public List Projects { get; set; } = []; + + [NotMapped] public SnPublisher? Publisher { get; set; } +} diff --git a/DysonNetwork.Pass/Leveling/ExperienceRecord.cs b/DysonNetwork.Shared/Models/ExperienceRecord.cs similarity index 78% rename from DysonNetwork.Pass/Leveling/ExperienceRecord.cs rename to DysonNetwork.Shared/Models/ExperienceRecord.cs index 21ecc30..4d107ee 100644 --- a/DysonNetwork.Pass/Leveling/ExperienceRecord.cs +++ b/DysonNetwork.Shared/Models/ExperienceRecord.cs @@ -1,8 +1,7 @@ using System.ComponentModel.DataAnnotations; -using DysonNetwork.Shared.Data; using NodaTime.Serialization.Protobuf; -namespace DysonNetwork.Pass.Leveling; +namespace DysonNetwork.Shared.Models; public class ExperienceRecord : ModelBase { @@ -13,11 +12,11 @@ public class ExperienceRecord : ModelBase public double BonusMultiplier { get; set; } public Guid AccountId { get; set; } - public Account.Account Account { get; set; } = null!; + public SnAccount Account { get; set; } = null!; - public Shared.Proto.ExperienceRecord ToProto() + public Proto.ExperienceRecord ToProto() { - var proto = new Shared.Proto.ExperienceRecord + var proto = new Proto.ExperienceRecord { Id = Id.ToString(), ReasonType = ReasonType, diff --git a/DysonNetwork.Drive/Storage/FileBundle.cs b/DysonNetwork.Shared/Models/FileBundle.cs similarity index 82% rename from DysonNetwork.Drive/Storage/FileBundle.cs rename to DysonNetwork.Shared/Models/FileBundle.cs index 0ce43bf..76b2412 100644 --- a/DysonNetwork.Drive/Storage/FileBundle.cs +++ b/DysonNetwork.Shared/Models/FileBundle.cs @@ -1,12 +1,11 @@ using System.ComponentModel.DataAnnotations; -using DysonNetwork.Shared.Data; using Microsoft.EntityFrameworkCore; using NodaTime; -namespace DysonNetwork.Drive.Storage; +namespace DysonNetwork.Shared.Models; [Index(nameof(Slug), IsUnique = true)] -public class FileBundle : ModelBase +public class SnFileBundle : ModelBase { public Guid Id { get; set; } = Guid.NewGuid(); [MaxLength(1024)] public string Slug { get; set; } = null!; @@ -14,13 +13,13 @@ public class FileBundle : ModelBase [MaxLength(8192)] public string? Description { get; set; } [MaxLength(256)] public string? Passcode { get; set; } - public List Files { get; set; } = new(); + public List Files { get; set; } = new(); public Instant? ExpiredAt { get; set; } public Guid AccountId { get; set; } - public FileBundle HashPasscode() + public SnFileBundle HashPasscode() { if (string.IsNullOrEmpty(Passcode)) return this; Passcode = BCrypt.Net.BCrypt.HashPassword(Passcode); diff --git a/DysonNetwork.Drive/Storage/FilePool.cs b/DysonNetwork.Shared/Models/FilePool.cs similarity index 98% rename from DysonNetwork.Drive/Storage/FilePool.cs rename to DysonNetwork.Shared/Models/FilePool.cs index 302f620..4bf7c75 100644 --- a/DysonNetwork.Drive/Storage/FilePool.cs +++ b/DysonNetwork.Shared/Models/FilePool.cs @@ -4,7 +4,7 @@ using System.Text.Json.Serialization; using DysonNetwork.Shared.Data; using NodaTime; -namespace DysonNetwork.Drive.Storage; +namespace DysonNetwork.Shared.Models; public class RemoteStorageConfig { diff --git a/DysonNetwork.Shared/Data/ICloudFile.cs b/DysonNetwork.Shared/Models/ICloudFile.cs similarity index 97% rename from DysonNetwork.Shared/Data/ICloudFile.cs rename to DysonNetwork.Shared/Models/ICloudFile.cs index 68c25f3..fc88ddb 100644 --- a/DysonNetwork.Shared/Data/ICloudFile.cs +++ b/DysonNetwork.Shared/Models/ICloudFile.cs @@ -1,6 +1,6 @@ using NodaTime; -namespace DysonNetwork.Shared.Data; +namespace DysonNetwork.Shared.Models; /// /// Common interface for cloud file entities that can be used in file operations. diff --git a/DysonNetwork.Pass/Account/MagicSpell.cs b/DysonNetwork.Shared/Models/MagicSpell.cs similarity index 84% rename from DysonNetwork.Pass/Account/MagicSpell.cs rename to DysonNetwork.Shared/Models/MagicSpell.cs index 200a33f..111d027 100644 --- a/DysonNetwork.Pass/Account/MagicSpell.cs +++ b/DysonNetwork.Shared/Models/MagicSpell.cs @@ -1,11 +1,10 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Text.Json.Serialization; -using DysonNetwork.Shared.Data; using Microsoft.EntityFrameworkCore; using NodaTime; -namespace DysonNetwork.Pass.Account; +namespace DysonNetwork.Shared.Models; public enum MagicSpellType { @@ -17,7 +16,7 @@ public enum MagicSpellType } [Index(nameof(Spell), IsUnique = true)] -public class MagicSpell : ModelBase +public class SnMagicSpell : ModelBase { public Guid Id { get; set; } = Guid.NewGuid(); [JsonIgnore] [MaxLength(1024)] public string Spell { get; set; } = null!; @@ -27,5 +26,5 @@ public class MagicSpell : ModelBase [Column(TypeName = "jsonb")] public Dictionary Meta { get; set; } = new(); public Guid? AccountId { get; set; } - public Account? Account { get; set; } + public SnAccount? Account { get; set; } } \ No newline at end of file diff --git a/DysonNetwork.Shared/Data/ModelBase.cs b/DysonNetwork.Shared/Models/ModelBase.cs similarity index 87% rename from DysonNetwork.Shared/Data/ModelBase.cs rename to DysonNetwork.Shared/Models/ModelBase.cs index 641a19e..cfbef0f 100644 --- a/DysonNetwork.Shared/Data/ModelBase.cs +++ b/DysonNetwork.Shared/Models/ModelBase.cs @@ -1,6 +1,6 @@ using NodaTime; -namespace DysonNetwork.Shared.Data; +namespace DysonNetwork.Shared.Models; public interface IIdentifiedResource { diff --git a/DysonNetwork.Shared/Models/Notification.cs b/DysonNetwork.Shared/Models/Notification.cs new file mode 100644 index 0000000..9c3bbd5 --- /dev/null +++ b/DysonNetwork.Shared/Models/Notification.cs @@ -0,0 +1,39 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using Microsoft.EntityFrameworkCore; +using NodaTime; + +namespace DysonNetwork.Shared.Models; + +public class SnNotification : ModelBase +{ + public Guid Id { get; set; } = Guid.NewGuid(); + [MaxLength(1024)] public string Topic { get; set; } = null!; + [MaxLength(1024)] public string? Title { get; set; } + [MaxLength(2048)] public string? Subtitle { get; set; } + [MaxLength(4096)] public string? Content { get; set; } + [Column(TypeName = "jsonb")] public Dictionary Meta { get; set; } = new(); + public int Priority { get; set; } = 10; + public Instant? ViewedAt { get; set; } + + public Guid AccountId { get; set; } +} + +public enum PushProvider +{ + Apple, + Google +} + +[Index(nameof(AccountId), nameof(DeviceId), nameof(DeletedAt), IsUnique = true)] +public class SnNotificationPushSubscription : ModelBase +{ + public Guid Id { get; set; } = Guid.NewGuid(); + public Guid AccountId { get; set; } + [MaxLength(8192)] public string DeviceId { get; set; } = null!; + [MaxLength(8192)] public string DeviceToken { get; set; } = null!; + public PushProvider Provider { get; set; } + + public int CountDelivered { get; set; } + public Instant? LastUsedAt { get; set; } +} \ No newline at end of file diff --git a/DysonNetwork.Pass/Wallet/Payment.cs b/DysonNetwork.Shared/Models/Payment.cs similarity index 81% rename from DysonNetwork.Pass/Wallet/Payment.cs rename to DysonNetwork.Shared/Models/Payment.cs index bee8cbc..ebb09fb 100644 --- a/DysonNetwork.Pass/Wallet/Payment.cs +++ b/DysonNetwork.Shared/Models/Payment.cs @@ -1,11 +1,10 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Globalization; -using DysonNetwork.Shared.Data; using NodaTime; using NodaTime.Serialization.Protobuf; -namespace DysonNetwork.Pass.Wallet; +namespace DysonNetwork.Shared.Models; public class WalletCurrency { @@ -22,7 +21,7 @@ public enum OrderStatus Expired } -public class Order : ModelBase +public class SnWalletOrder : ModelBase { public const string InternalAppIdentifier = "internal"; @@ -37,14 +36,14 @@ public class Order : ModelBase public Instant ExpiredAt { get; set; } public Guid? PayeeWalletId { get; set; } - public Wallet? PayeeWallet { get; set; } = null!; + public SnWallet? PayeeWallet { get; set; } = null!; public Guid? TransactionId { get; set; } - public Transaction? Transaction { get; set; } + public SnWalletTransaction? Transaction { get; set; } - public Shared.Proto.Order ToProtoValue() => new() + public Proto.Order ToProtoValue() => new() { Id = Id.ToString(), - Status = (Shared.Proto.OrderStatus)Status, + Status = (Proto.OrderStatus)Status, Currency = Currency, Remarks = Remarks, AppIdentifier = AppIdentifier, @@ -59,7 +58,7 @@ public class Order : ModelBase Transaction = Transaction?.ToProtoValue(), }; - public static Order FromProtoValue(Shared.Proto.Order proto) => new() + public static SnWalletOrder FromProtoValue(Proto.Order proto) => new() { Id = Guid.Parse(proto.Id), Status = (OrderStatus)proto.Status, @@ -74,7 +73,7 @@ public class Order : ModelBase ExpiredAt = proto.ExpiredAt.ToInstant(), PayeeWalletId = proto.PayeeWalletId is not null ? Guid.Parse(proto.PayeeWalletId) : null, TransactionId = proto.TransactionId is not null ? Guid.Parse(proto.TransactionId) : null, - Transaction = proto.Transaction is not null ? Transaction.FromProtoValue(proto.Transaction) : null, + Transaction = proto.Transaction is not null ? SnWalletTransaction.FromProtoValue(proto.Transaction) : null, }; } @@ -85,7 +84,7 @@ public enum TransactionType Order } -public class Transaction : ModelBase +public class SnWalletTransaction : ModelBase { public Guid Id { get; set; } = Guid.NewGuid(); [MaxLength(128)] public string Currency { get; set; } = null!; @@ -96,24 +95,24 @@ public class Transaction : ModelBase // When the payer is null, it's pay from the system public Guid? PayerWalletId { get; set; } - public Wallet? PayerWallet { get; set; } + public SnWallet? PayerWallet { get; set; } // When the payee is null, it's pay for the system public Guid? PayeeWalletId { get; set; } - public Wallet? PayeeWallet { get; set; } + public SnWallet? PayeeWallet { get; set; } - public Shared.Proto.Transaction ToProtoValue() => new() + public Proto.Transaction ToProtoValue() => new() { Id = Id.ToString(), Currency = Currency, Amount = Amount.ToString(CultureInfo.InvariantCulture), Remarks = Remarks, - Type = (Shared.Proto.TransactionType)Type, + Type = (Proto.TransactionType)Type, PayerWalletId = PayerWalletId?.ToString(), PayeeWalletId = PayeeWalletId?.ToString(), }; - public static Transaction FromProtoValue(Shared.Proto.Transaction proto) => new() + public static SnWalletTransaction FromProtoValue(Proto.Transaction proto) => new() { Id = Guid.Parse(proto.Id), Currency = proto.Currency, diff --git a/DysonNetwork.Pass/Permission/Permission.cs b/DysonNetwork.Shared/Models/Permission.cs similarity index 77% rename from DysonNetwork.Pass/Permission/Permission.cs rename to DysonNetwork.Shared/Models/Permission.cs index 531cc7c..8cd7a62 100644 --- a/DysonNetwork.Pass/Permission/Permission.cs +++ b/DysonNetwork.Shared/Models/Permission.cs @@ -2,11 +2,10 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Text.Json; using System.Text.Json.Serialization; -using DysonNetwork.Shared.Data; using Microsoft.EntityFrameworkCore; using NodaTime; -namespace DysonNetwork.Pass.Permission; +namespace DysonNetwork.Shared.Models; /// The permission node model provides the infrastructure of permission control in Dyson Network. /// It based on the ABAC permission model. @@ -20,7 +19,7 @@ namespace DysonNetwork.Pass.Permission; /// and when the permission node has a GroupId, the actor will be set to the group, but it won't work on checking /// expect the member of that permission group inherent the permission from the group. [Index(nameof(Key), nameof(Area), nameof(Actor))] -public class PermissionNode : ModelBase, IDisposable +public class SnPermissionNode : ModelBase, IDisposable { public Guid Id { get; set; } = Guid.NewGuid(); [MaxLength(1024)] public string Actor { get; set; } = null!; @@ -31,7 +30,7 @@ public class PermissionNode : ModelBase, IDisposable public Instant? AffectedAt { get; set; } = null; public Guid? GroupId { get; set; } = null; - [JsonIgnore] public PermissionGroup? Group { get; set; } = null; + [JsonIgnore] public SnPermissionGroup? Group { get; set; } = null; public void Dispose() { @@ -40,19 +39,19 @@ public class PermissionNode : ModelBase, IDisposable } } -public class PermissionGroup : ModelBase +public class SnPermissionGroup : ModelBase { public Guid Id { get; set; } = Guid.NewGuid(); [MaxLength(1024)] public string Key { get; set; } = null!; - public ICollection Nodes { get; set; } = new List(); - [JsonIgnore] public ICollection Members { get; set; } = new List(); + public ICollection Nodes { get; set; } = []; + [JsonIgnore] public ICollection Members { get; set; } = []; } -public class PermissionGroupMember : ModelBase +public class SnPermissionGroupMember : ModelBase { public Guid GroupId { get; set; } - public PermissionGroup Group { get; set; } = null!; + public SnPermissionGroup Group { get; set; } = null!; [MaxLength(1024)] public string Actor { get; set; } = null!; public Instant? ExpiredAt { get; set; } diff --git a/DysonNetwork.Sphere/Poll/Poll.cs b/DysonNetwork.Shared/Models/Poll.cs similarity index 72% rename from DysonNetwork.Sphere/Poll/Poll.cs rename to DysonNetwork.Shared/Models/Poll.cs index fac9b6a..17b221e 100644 --- a/DysonNetwork.Sphere/Poll/Poll.cs +++ b/DysonNetwork.Shared/Models/Poll.cs @@ -5,12 +5,12 @@ using System.Text.Json.Serialization; using DysonNetwork.Shared.Data; using NodaTime; -namespace DysonNetwork.Sphere.Poll; +namespace DysonNetwork.Shared.Models; -public class Poll : ModelBase +public class SnPoll : ModelBase { public Guid Id { get; set; } = Guid.NewGuid(); - public List Questions { get; set; } = new(); + public List Questions { get; set; } = new(); [MaxLength(1024)] public string? Title { get; set; } [MaxLength(4096)] public string? Description { get; set; } @@ -19,7 +19,7 @@ public class Poll : ModelBase public bool IsAnonymous { get; set; } public Guid PublisherId { get; set; } - [JsonIgnore] public Publisher.Publisher? Publisher { get; set; } + [JsonIgnore] public SnPublisher? Publisher { get; set; } } public enum PollQuestionType @@ -31,12 +31,12 @@ public enum PollQuestionType FreeText } -public class PollQuestion : ModelBase +public class SnPollQuestion : ModelBase { public Guid Id { get; set; } = Guid.NewGuid(); public PollQuestionType Type { get; set; } - [Column(TypeName = "jsonb")] public List? Options { get; set; } + [Column(TypeName = "jsonb")] public List? Options { get; set; } [MaxLength(1024)] public string Title { get; set; } = null!; [MaxLength(4096)] public string? Description { get; set; } @@ -44,10 +44,10 @@ public class PollQuestion : ModelBase public bool IsRequired { get; set; } public Guid PollId { get; set; } - [JsonIgnore] public Poll Poll { get; set; } = null!; + [JsonIgnore] public SnPoll Poll { get; set; } = null!; } -public class PollOption +public class SnPollOption { public Guid Id { get; set; } = Guid.NewGuid(); [Required][MaxLength(1024)] public string Label { get; set; } = null!; @@ -55,13 +55,13 @@ public class PollOption public int Order { get; set; } = 0; } -public class PollAnswer : ModelBase +public class SnPollAnswer : ModelBase { public Guid Id { get; set; } = Guid.NewGuid(); [Column(TypeName = "jsonb")] public Dictionary Answer { get; set; } = null!; public Guid AccountId { get; set; } public Guid PollId { get; set; } - [JsonIgnore] public Poll? Poll { get; set; } - [NotMapped] public AccountReference? Account { get; set; } + [JsonIgnore] public SnPoll? Poll { get; set; } + [NotMapped] public SnAccount? Account { get; set; } } diff --git a/DysonNetwork.Sphere/Post/Post.cs b/DysonNetwork.Shared/Models/Post.cs similarity index 71% rename from DysonNetwork.Sphere/Post/Post.cs rename to DysonNetwork.Shared/Models/Post.cs index b3efa55..5e3ac6b 100644 --- a/DysonNetwork.Sphere/Post/Post.cs +++ b/DysonNetwork.Shared/Models/Post.cs @@ -1,12 +1,10 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Text.Json.Serialization; -using DysonNetwork.Shared.Data; -using DysonNetwork.Sphere.Activity; using NodaTime; using NpgsqlTypes; -namespace DysonNetwork.Sphere.Post; +namespace DysonNetwork.Shared.Models; public enum PostType { @@ -29,7 +27,7 @@ public enum PostPinMode ReplyPage, } -public class Post : ModelBase, IIdentifiedResource, IActivity +public class SnPost : ModelBase, IIdentifiedResource, IActivity { public Guid Id { get; set; } [MaxLength(1024)] public string? Title { get; set; } @@ -61,34 +59,34 @@ public class Post : ModelBase, IIdentifiedResource, IActivity public bool ForwardedGone { get; set; } public Guid? RepliedPostId { get; set; } - public Post? RepliedPost { get; set; } + public SnPost? RepliedPost { get; set; } public Guid? ForwardedPostId { get; set; } - public Post? ForwardedPost { get; set; } + public SnPost? ForwardedPost { get; set; } public Guid? RealmId { get; set; } - public Realm.Realm? Realm { get; set; } + public SnRealm? Realm { get; set; } - [Column(TypeName = "jsonb")] public List Attachments { get; set; } = []; + [Column(TypeName = "jsonb")] public List Attachments { get; set; } = []; [JsonIgnore] public NpgsqlTsVector SearchVector { get; set; } = null!; public Guid PublisherId { get; set; } - public Publisher.Publisher Publisher { get; set; } = null!; + public SnPublisher Publisher { get; set; } = null!; - public ICollection Awards { get; set; } = null!; - [JsonIgnore] public ICollection Reactions { get; set; } = new List(); - public ICollection Tags { get; set; } = new List(); - public ICollection Categories { get; set; } = new List(); - [JsonIgnore] public ICollection Collections { get; set; } = new List(); + public ICollection Awards { get; set; } = null!; + [JsonIgnore] public ICollection Reactions { get; set; } = new List(); + public ICollection Tags { get; set; } = new List(); + public ICollection Categories { get; set; } = new List(); + [JsonIgnore] public ICollection Collections { get; set; } = new List(); [JsonIgnore] public bool Empty => Content == null && Attachments.Count == 0 && ForwardedPostId == null; [NotMapped] public bool IsTruncated { get; set; } = false; public string ResourceIdentifier => $"post:{Id}"; - public Activity.Activity ToActivity() + public SnActivity ToActivity() { - return new Activity.Activity() + return new SnActivity() { CreatedAt = PublishedAt ?? CreatedAt, UpdatedAt = UpdatedAt, @@ -101,55 +99,55 @@ public class Post : ModelBase, IIdentifiedResource, IActivity } } -public class PostTag : ModelBase +public class SnPostTag : ModelBase { public Guid Id { get; set; } [MaxLength(128)] public string Slug { get; set; } = null!; [MaxLength(256)] public string? Name { get; set; } - [JsonIgnore] public ICollection Posts { get; set; } = new List(); + [JsonIgnore] public ICollection Posts { get; set; } = new List(); [NotMapped] public int? Usage { get; set; } } -public class PostCategory : ModelBase +public class SnPostCategory : ModelBase { public Guid Id { get; set; } [MaxLength(128)] public string Slug { get; set; } = null!; [MaxLength(256)] public string? Name { get; set; } - [JsonIgnore] public ICollection Posts { get; set; } = new List(); + [JsonIgnore] public ICollection Posts { get; set; } = new List(); [NotMapped] public int? Usage { get; set; } } -public class PostCategorySubscription : ModelBase +public class SnPostCategorySubscription : ModelBase { public Guid Id { get; set; } public Guid AccountId { get; set; } public Guid? CategoryId { get; set; } - public PostCategory? Category { get; set; } + public SnPostCategory? Category { get; set; } public Guid? TagId { get; set; } - public PostTag? Tag { get; set; } + public SnPostTag? Tag { get; set; } } -public class PostCollection : ModelBase +public class SnPostCollection : ModelBase { public Guid Id { get; set; } [MaxLength(128)] public string Slug { get; set; } = null!; [MaxLength(256)] public string? Name { get; set; } [MaxLength(4096)] public string? Description { get; set; } - public Publisher.Publisher Publisher { get; set; } = null!; + public SnPublisher Publisher { get; set; } = null!; - public ICollection Posts { get; set; } = new List(); + public ICollection Posts { get; set; } = new List(); } -public class PostFeaturedRecord : ModelBase +public class SnPostFeaturedRecord : ModelBase { public Guid Id { get; set; } public Guid PostId { get; set; } - public Post Post { get; set; } = null!; + public SnPost Post { get; set; } = null!; public Instant? FeaturedAt { get; set; } public int SocialCredits { get; set; } } @@ -161,18 +159,18 @@ public enum PostReactionAttitude Negative, } -public class PostReaction : ModelBase +public class SnPostReaction : ModelBase { public Guid Id { get; set; } [MaxLength(256)] public string Symbol { get; set; } = null!; public PostReactionAttitude Attitude { get; set; } public Guid PostId { get; set; } - [JsonIgnore] public Post Post { get; set; } = null!; + [JsonIgnore] public SnPost Post { get; set; } = null!; public Guid AccountId { get; set; } } -public class PostAward : ModelBase +public class SnPostAward : ModelBase { public Guid Id { get; set; } public decimal Amount { get; set; } @@ -180,7 +178,7 @@ public class PostAward : ModelBase [MaxLength(4096)] public string? Message { get; set; } public Guid PostId { get; set; } - [JsonIgnore] public Post Post { get; set; } = null!; + [JsonIgnore] public SnPost Post { get; set; } = null!; public Guid AccountId { get; set; } } diff --git a/DysonNetwork.Sphere/Publisher/Publisher.cs b/DysonNetwork.Shared/Models/Publisher.cs similarity index 71% rename from DysonNetwork.Sphere/Publisher/Publisher.cs rename to DysonNetwork.Shared/Models/Publisher.cs index 52b56fd..b141cb8 100644 --- a/DysonNetwork.Sphere/Publisher/Publisher.cs +++ b/DysonNetwork.Shared/Models/Publisher.cs @@ -1,15 +1,12 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Text.Json.Serialization; -using DysonNetwork.Shared.Data; -using DysonNetwork.Sphere.Post; +using DysonNetwork.Shared.Proto; using Microsoft.EntityFrameworkCore; using NodaTime; using NodaTime.Serialization.Protobuf; -using VerificationMark = DysonNetwork.Shared.Data.VerificationMark; -using Account = DysonNetwork.Shared.Data.AccountReference; -namespace DysonNetwork.Sphere.Publisher; +namespace DysonNetwork.Shared.Models; public enum PublisherType { @@ -18,7 +15,7 @@ public enum PublisherType } [Index(nameof(Name), IsUnique = true)] -public class Publisher : ModelBase, IIdentifiedResource +public class SnPublisher : ModelBase, IIdentifiedResource { public Guid Id { get; set; } = Guid.NewGuid(); public PublisherType Type { get; set; } @@ -30,30 +27,30 @@ public class Publisher : ModelBase, IIdentifiedResource [MaxLength(32)] public string? PictureId { get; set; } [MaxLength(32)] public string? BackgroundId { get; set; } - [Column(TypeName = "jsonb")] public CloudFileReferenceObject? Picture { get; set; } - [Column(TypeName = "jsonb")] public CloudFileReferenceObject? Background { get; set; } + [Column(TypeName = "jsonb")] public SnCloudFileReferenceObject? Picture { get; set; } + [Column(TypeName = "jsonb")] public SnCloudFileReferenceObject? Background { get; set; } - [Column(TypeName = "jsonb")] public VerificationMark? Verification { get; set; } + [Column(TypeName = "jsonb")] public SnVerificationMark? Verification { get; set; } - [JsonIgnore] public ICollection Posts { get; set; } = new List(); - [JsonIgnore] public ICollection Polls { get; set; } = new List(); - [JsonIgnore] public ICollection Collections { get; set; } = new List(); - [JsonIgnore] public ICollection Members { get; set; } = new List(); - [JsonIgnore] public ICollection Features { get; set; } = new List(); + [JsonIgnore] public ICollection Posts { get; set; } = []; + [JsonIgnore] public ICollection Polls { get; set; } = []; + [JsonIgnore] public ICollection Collections { get; set; } = []; + [JsonIgnore] public ICollection Members { get; set; } = []; + [JsonIgnore] public ICollection Features { get; set; } = []; [JsonIgnore] - public ICollection Subscriptions { get; set; } = new List(); + public ICollection Subscriptions { get; set; } = []; public Guid? AccountId { get; set; } public Guid? RealmId { get; set; } - [JsonIgnore] public Realm.Realm? Realm { get; set; } + [JsonIgnore] public SnRealm? Realm { get; set; } [NotMapped] public Account? Account { get; set; } public string ResourceIdentifier => $"publisher:{Id}"; - public Shared.Proto.Publisher ToProto(AppDatabase db) + public Proto.Publisher ToProto() { - var p = new Shared.Proto.Publisher() + var p = new Proto.Publisher() { Id = Id.ToString(), Type = Type == PublisherType.Individual @@ -69,7 +66,7 @@ public class Publisher : ModelBase, IIdentifiedResource }; if (Picture is not null) { - p.Picture = new Shared.Proto.CloudFile + p.Picture = new Proto.CloudFile { Id = Picture.Id, Name = Picture.Name, @@ -81,7 +78,7 @@ public class Publisher : ModelBase, IIdentifiedResource if (Background is not null) { - p.Background = new Shared.Proto.CloudFile + p.Background = new Proto.CloudFile { Id = Background.Id, Name = Background.Name, @@ -103,10 +100,10 @@ public enum PublisherMemberRole Viewer = 25 } -public class PublisherMember : ModelBase +public class SnPublisherMember : ModelBase { public Guid PublisherId { get; set; } - [JsonIgnore] public Publisher Publisher { get; set; } = null!; + [JsonIgnore] public SnPublisher Publisher { get; set; } = null!; public Guid AccountId { get; set; } [NotMapped] public Account? Account { get; set; } @@ -114,9 +111,9 @@ public class PublisherMember : ModelBase public Instant? JoinedAt { get; set; } - public Shared.Proto.PublisherMember ToProto() + public Proto.PublisherMember ToProto() { - return new Shared.Proto.PublisherMember() + return new Proto.PublisherMember() { PublisherId = PublisherId.ToString(), AccountId = AccountId.ToString(), @@ -145,7 +142,7 @@ public class PublisherSubscription : ModelBase public Guid Id { get; set; } public Guid PublisherId { get; set; } - [JsonIgnore] public Publisher Publisher { get; set; } = null!; + [JsonIgnore] public SnPublisher Publisher { get; set; } = null!; public Guid AccountId { get; set; } public PublisherSubscriptionStatus Status { get; set; } = PublisherSubscriptionStatus.Active; @@ -159,7 +156,7 @@ public class PublisherFeature : ModelBase public Instant? ExpiredAt { get; set; } public Guid PublisherId { get; set; } - public Publisher Publisher { get; set; } = null!; + public SnPublisher Publisher { get; set; } = null!; } public abstract class PublisherFeatureFlag diff --git a/DysonNetwork.Pass/Account/Punishment.cs b/DysonNetwork.Shared/Models/Punishment.cs similarity index 79% rename from DysonNetwork.Pass/Account/Punishment.cs rename to DysonNetwork.Shared/Models/Punishment.cs index fc40493..0decdb7 100644 --- a/DysonNetwork.Pass/Account/Punishment.cs +++ b/DysonNetwork.Shared/Models/Punishment.cs @@ -1,9 +1,8 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using DysonNetwork.Shared.Data; using NodaTime; -namespace DysonNetwork.Pass.Account; +namespace DysonNetwork.Shared.Models; public enum PunishmentType { @@ -14,7 +13,7 @@ public enum PunishmentType Strike } -public class Punishment : ModelBase +public class SnAccountPunishment : ModelBase { public Guid Id { get; set; } = Guid.NewGuid(); [MaxLength(8192)] public string Reason { get; set; } = string.Empty; @@ -24,5 +23,5 @@ public class Punishment : ModelBase [Column(TypeName = "jsonb")] public List? BlockedPermissions { get; set; } public Guid AccountId { get; set; } - public Account Account { get; set; } = null!; + public SnAccount Account { get; set; } = null!; } \ No newline at end of file diff --git a/DysonNetwork.Sphere/Realm/Realm.cs b/DysonNetwork.Shared/Models/Realm.cs similarity index 59% rename from DysonNetwork.Sphere/Realm/Realm.cs rename to DysonNetwork.Shared/Models/Realm.cs index 8d733d4..59e968e 100644 --- a/DysonNetwork.Sphere/Realm/Realm.cs +++ b/DysonNetwork.Shared/Models/Realm.cs @@ -1,15 +1,13 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Text.Json.Serialization; -using DysonNetwork.Shared.Data; -using DysonNetwork.Sphere.Chat; using Microsoft.EntityFrameworkCore; using NodaTime; -namespace DysonNetwork.Sphere.Realm; +namespace DysonNetwork.Shared.Models; [Index(nameof(Slug), IsUnique = true)] -public class Realm : ModelBase, IIdentifiedResource +public class SnRealm : ModelBase, IIdentifiedResource { public Guid Id { get; set; } [MaxLength(1024)] public string Slug { get; set; } = string.Empty; @@ -22,13 +20,13 @@ public class Realm : ModelBase, IIdentifiedResource [MaxLength(32)] public string? PictureId { get; set; } [MaxLength(32)] public string? BackgroundId { get; set; } - [Column(TypeName = "jsonb")] public CloudFileReferenceObject? Picture { get; set; } - [Column(TypeName = "jsonb")] public CloudFileReferenceObject? Background { get; set; } + [Column(TypeName = "jsonb")] public SnCloudFileReferenceObject? Picture { get; set; } + [Column(TypeName = "jsonb")] public SnCloudFileReferenceObject? Background { get; set; } - [Column(TypeName = "jsonb")] public VerificationMark? Verification { get; set; } + [Column(TypeName = "jsonb")] public SnVerificationMark? Verification { get; set; } - [JsonIgnore] public ICollection Members { get; set; } = new List(); - [JsonIgnore] public ICollection ChatRooms { get; set; } = new List(); + [JsonIgnore] public ICollection Members { get; set; } = new List(); + [JsonIgnore] public ICollection ChatRooms { get; set; } = new List(); public Guid AccountId { get; set; } @@ -42,13 +40,13 @@ public abstract class RealmMemberRole public const int Normal = 0; } -public class RealmMember : ModelBase +public class SnRealmMember : ModelBase { public Guid RealmId { get; set; } - public Realm Realm { get; set; } = null!; + public SnRealm Realm { get; set; } = null!; public Guid AccountId { get; set; } - [NotMapped] public AccountReference? Account { get; set; } - [NotMapped] public AccountStatusReference? Status { get; set; } + [NotMapped] public SnAccount? Account { get; set; } + [NotMapped] public SnAccountStatus? Status { get; set; } public int Role { get; set; } = RealmMemberRole.Normal; public Instant? JoinedAt { get; set; } diff --git a/DysonNetwork.Sphere/Chat/RealtimeCall.cs b/DysonNetwork.Shared/Models/RealtimeCall.cs similarity index 79% rename from DysonNetwork.Sphere/Chat/RealtimeCall.cs rename to DysonNetwork.Shared/Models/RealtimeCall.cs index eaa5042..223f4f2 100644 --- a/DysonNetwork.Sphere/Chat/RealtimeCall.cs +++ b/DysonNetwork.Shared/Models/RealtimeCall.cs @@ -1,23 +1,19 @@ -using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations.Schema; using System.Text.Json; -using System.Text.Json.Serialization; -using DysonNetwork.Shared.Data; -using DysonNetwork.Sphere.Chat.Realtime; + using NodaTime; -namespace DysonNetwork.Sphere.Chat; +namespace DysonNetwork.Shared.Models; -public class RealtimeCall : ModelBase +public class SnRealtimeCall : ModelBase { public Guid Id { get; set; } = Guid.NewGuid(); public Instant? EndedAt { get; set; } public Guid SenderId { get; set; } - public ChatMember Sender { get; set; } = null!; + public SnChatMember Sender { get; set; } = null!; public Guid RoomId { get; set; } - public ChatRoom Room { get; set; } = null!; + public SnChatRoom Room { get; set; } = null!; /// /// Provider name (e.g., "cloudflare", "agora", "twilio") diff --git a/DysonNetwork.Pass/Account/Relationship.cs b/DysonNetwork.Shared/Models/Relationship.cs similarity index 69% rename from DysonNetwork.Pass/Account/Relationship.cs rename to DysonNetwork.Shared/Models/Relationship.cs index 9c605ee..80a3199 100644 --- a/DysonNetwork.Pass/Account/Relationship.cs +++ b/DysonNetwork.Shared/Models/Relationship.cs @@ -1,9 +1,7 @@ -using DysonNetwork.Shared.Data; -using DysonNetwork.Shared.Proto; using NodaTime; using NodaTime.Serialization.Protobuf; -namespace DysonNetwork.Pass.Account; +namespace DysonNetwork.Shared.Models; public enum RelationshipStatus : short { @@ -12,18 +10,18 @@ public enum RelationshipStatus : short Blocked = -100 } -public class Relationship : ModelBase +public class SnAccountRelationship : ModelBase { public Guid AccountId { get; set; } - public Account Account { get; set; } = null!; + public SnAccount Account { get; set; } = null!; public Guid RelatedId { get; set; } - public Account Related { get; set; } = null!; + public SnAccount Related { get; set; } = null!; public Instant? ExpiredAt { get; set; } public RelationshipStatus Status { get; set; } = RelationshipStatus.Pending; - public Shared.Proto.Relationship ToProtoValue() => new() + public Proto.Relationship ToProtoValue() => new() { AccountId = AccountId.ToString(), RelatedId = RelatedId.ToString(), diff --git a/DysonNetwork.Pass/Credit/SocialCreditRecord.cs b/DysonNetwork.Shared/Models/SocialCreditRecord.cs similarity index 76% rename from DysonNetwork.Pass/Credit/SocialCreditRecord.cs rename to DysonNetwork.Shared/Models/SocialCreditRecord.cs index ba309d7..7eff4e8 100644 --- a/DysonNetwork.Pass/Credit/SocialCreditRecord.cs +++ b/DysonNetwork.Shared/Models/SocialCreditRecord.cs @@ -1,9 +1,8 @@ using System.ComponentModel.DataAnnotations; -using DysonNetwork.Shared.Data; using NodaTime; using NodaTime.Serialization.Protobuf; -namespace DysonNetwork.Pass.Credit; +namespace DysonNetwork.Shared.Models; public class SocialCreditRecord : ModelBase { @@ -14,11 +13,11 @@ public class SocialCreditRecord : ModelBase public Instant? ExpiredAt { get; set; } public Guid AccountId { get; set; } - public Account.Account Account { get; set; } = null!; + public SnAccount Account { get; set; } = null!; - public Shared.Proto.SocialCreditRecord ToProto() + public Proto.SocialCreditRecord ToProto() { - var proto = new Shared.Proto.SocialCreditRecord + var proto = new Proto.SocialCreditRecord { Id = Id.ToString(), ReasonType = ReasonType, diff --git a/DysonNetwork.Sphere/Sticker/Sticker.cs b/DysonNetwork.Shared/Models/Sticker.cs similarity index 73% rename from DysonNetwork.Sphere/Sticker/Sticker.cs rename to DysonNetwork.Shared/Models/Sticker.cs index c145656..753c14f 100644 --- a/DysonNetwork.Sphere/Sticker/Sticker.cs +++ b/DysonNetwork.Shared/Models/Sticker.cs @@ -1,13 +1,12 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Text.Json.Serialization; -using DysonNetwork.Shared.Data; using Microsoft.EntityFrameworkCore; -namespace DysonNetwork.Sphere.Sticker; +namespace DysonNetwork.Shared.Models; [Index(nameof(Slug))] // The slug index shouldn't be unique, the sticker slug can be repeated across packs. -public class Sticker : ModelBase, IIdentifiedResource +public class SnSticker : ModelBase, IIdentifiedResource { public Guid Id { get; set; } = Guid.NewGuid(); [MaxLength(128)] public string Slug { get; set; } = null!; @@ -15,12 +14,12 @@ public class Sticker : ModelBase, IIdentifiedResource // Outdated fields, for backward compability [MaxLength(32)] public string? ImageId { get; set; } - [Column(TypeName = "jsonb")] public CloudFileReferenceObject? Image { get; set; } = null!; + [Column(TypeName = "jsonb")] public SnCloudFileReferenceObject? Image { get; set; } = null!; public Guid PackId { get; set; } [JsonIgnore] public StickerPack Pack { get; set; } = null!; - public string ResourceIdentifier => $"sticker:{Id}"; + public string ResourceIdentifier => $"sticker/{Id}"; } [Index(nameof(Prefix), IsUnique = true)] @@ -31,11 +30,11 @@ public class StickerPack : ModelBase [MaxLength(4096)] public string Description { get; set; } = string.Empty; [MaxLength(128)] public string Prefix { get; set; } = null!; - public List Stickers { get; set; } = []; + public List Stickers { get; set; } = []; [JsonIgnore] public List Ownerships { get; set; } = []; public Guid PublisherId { get; set; } - public Publisher.Publisher Publisher { get; set; } = null!; + public SnPublisher Publisher { get; set; } = null!; } public class StickerPackOwnership : ModelBase @@ -45,5 +44,5 @@ public class StickerPackOwnership : ModelBase public Guid PackId { get; set; } public StickerPack Pack { get; set; } = null!; public Guid AccountId { get; set; } - [NotMapped] public AccountReference Account { get; set; } = null!; + [NotMapped] public SnAccount Account { get; set; } = null!; } diff --git a/DysonNetwork.Pass/Wallet/Subscription.cs b/DysonNetwork.Shared/Models/Subscription.cs similarity index 93% rename from DysonNetwork.Pass/Wallet/Subscription.cs rename to DysonNetwork.Shared/Models/Subscription.cs index 0952ff9..5eae90c 100644 --- a/DysonNetwork.Pass/Wallet/Subscription.cs +++ b/DysonNetwork.Shared/Models/Subscription.cs @@ -1,12 +1,11 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Globalization; -using DysonNetwork.Shared.Data; using Microsoft.EntityFrameworkCore; using NodaTime; using NodaTime.Serialization.Protobuf; -namespace DysonNetwork.Pass.Wallet; +namespace DysonNetwork.Shared.Models; public record class SubscriptionTypeData( string Identifier, @@ -105,7 +104,7 @@ public enum SubscriptionStatus /// The paid subscription in another word. /// [Index(nameof(Identifier))] -public class Subscription : ModelBase +public class SnSubscription : ModelBase { public Guid Id { get; set; } = Guid.NewGuid(); public Instant BegunAt { get; set; } @@ -141,7 +140,7 @@ public class Subscription : ModelBase public Instant? RenewalAt { get; set; } public Guid AccountId { get; set; } - public Account.Account Account { get; set; } = null!; + public SnAccount Account { get; set; } = null!; [NotMapped] public bool IsAvailable @@ -202,7 +201,7 @@ public class Subscription : ModelBase }; } - public Shared.Proto.Subscription ToProtoValue() => new() + public Proto.Subscription ToProtoValue() => new() { Id = Id.ToString(), BegunAt = BegunAt.ToTimestamp(), @@ -210,7 +209,7 @@ public class Subscription : ModelBase Identifier = Identifier, IsActive = IsActive, IsFreeTrial = IsFreeTrial, - Status = (Shared.Proto.SubscriptionStatus)Status, + Status = (Proto.SubscriptionStatus)Status, PaymentMethod = PaymentMethod, PaymentDetails = PaymentDetails.ToProtoValue(), BasePrice = BasePrice.ToString(CultureInfo.InvariantCulture), @@ -224,7 +223,7 @@ public class Subscription : ModelBase UpdatedAt = UpdatedAt.ToTimestamp() }; - public static Subscription FromProtoValue(Shared.Proto.Subscription proto) => new() + public static SnSubscription FromProtoValue(Proto.Subscription proto) => new() { Id = Guid.Parse(proto.Id), BegunAt = proto.BegunAt.ToInstant(), @@ -272,7 +271,7 @@ public class SubscriptionReferenceObject : ModelBase ? name : null; - public Shared.Proto.SubscriptionReferenceObject ToProtoValue() => new() + public Proto.SubscriptionReferenceObject ToProtoValue() => new() { Id = Id.ToString(), Identifier = Identifier, @@ -281,7 +280,7 @@ public class SubscriptionReferenceObject : ModelBase IsActive = IsActive, IsAvailable = IsAvailable, IsFreeTrial = IsFreeTrial, - Status = (Shared.Proto.SubscriptionStatus)Status, + Status = (Proto.SubscriptionStatus)Status, BasePrice = BasePrice.ToString(CultureInfo.CurrentCulture), FinalPrice = FinalPrice.ToString(CultureInfo.CurrentCulture), RenewalAt = RenewalAt?.ToTimestamp(), @@ -291,7 +290,7 @@ public class SubscriptionReferenceObject : ModelBase UpdatedAt = UpdatedAt.ToTimestamp() }; - public static SubscriptionReferenceObject FromProtoValue(Shared.Proto.SubscriptionReferenceObject proto) => new() + public static SubscriptionReferenceObject FromProtoValue(Proto.SubscriptionReferenceObject proto) => new() { Id = Guid.Parse(proto.Id), Identifier = proto.Identifier, @@ -315,13 +314,13 @@ public class PaymentDetails public string Currency { get; set; } = null!; public string? OrderId { get; set; } - public Shared.Proto.PaymentDetails ToProtoValue() => new() + public Proto.PaymentDetails ToProtoValue() => new() { Currency = Currency, OrderId = OrderId, }; - public static PaymentDetails FromProtoValue(Shared.Proto.PaymentDetails proto) => new() + public static PaymentDetails FromProtoValue(Proto.PaymentDetails proto) => new() { Currency = proto.Currency, OrderId = proto.OrderId, @@ -375,7 +374,7 @@ public class Coupon : ModelBase /// public int? MaxUsage { get; set; } - public Shared.Proto.Coupon ToProtoValue() => new() + public Proto.Coupon ToProtoValue() => new() { Id = Id.ToString(), Identifier = Identifier, @@ -389,7 +388,7 @@ public class Coupon : ModelBase UpdatedAt = UpdatedAt.ToTimestamp() }; - public static Coupon FromProtoValue(Shared.Proto.Coupon proto) => new() + public static Coupon FromProtoValue(Proto.Coupon proto) => new() { Id = Guid.Parse(proto.Id), Identifier = proto.Identifier, diff --git a/DysonNetwork.Shared/Data/VerificationMark.cs b/DysonNetwork.Shared/Models/VerificationMark.cs similarity index 93% rename from DysonNetwork.Shared/Data/VerificationMark.cs rename to DysonNetwork.Shared/Models/VerificationMark.cs index 912abd1..a0b4b90 100644 --- a/DysonNetwork.Shared/Data/VerificationMark.cs +++ b/DysonNetwork.Shared/Models/VerificationMark.cs @@ -1,13 +1,13 @@ using System.ComponentModel.DataAnnotations; -namespace DysonNetwork.Shared.Data; +namespace DysonNetwork.Shared.Models; /// /// The verification info of a resource /// stands, for it is really an individual or organization or a company in the real world. /// Besides, it can also be use for mark parody or fake. /// -public class VerificationMark +public class SnVerificationMark { public VerificationMarkType Type { get; set; } [MaxLength(1024)] public string? Title { get; set; } @@ -38,9 +38,9 @@ public class VerificationMark } - public static VerificationMark FromProtoValue(Shared.Proto.VerificationMark proto) + public static SnVerificationMark FromProtoValue(Proto.VerificationMark proto) { - return new VerificationMark + return new SnVerificationMark { Type = proto.Type switch { diff --git a/DysonNetwork.Pass/Wallet/Wallet.cs b/DysonNetwork.Shared/Models/Wallet.cs similarity index 59% rename from DysonNetwork.Pass/Wallet/Wallet.cs rename to DysonNetwork.Shared/Models/Wallet.cs index d85134d..69bc65a 100644 --- a/DysonNetwork.Pass/Wallet/Wallet.cs +++ b/DysonNetwork.Shared/Models/Wallet.cs @@ -1,23 +1,21 @@ using System.ComponentModel.DataAnnotations; using System.Globalization; using System.Text.Json.Serialization; -using DysonNetwork.Shared.Data; -using NodaTime.Serialization.Protobuf; -namespace DysonNetwork.Pass.Wallet; +namespace DysonNetwork.Shared.Models; -public class Wallet : ModelBase +public class SnWallet : ModelBase { public Guid Id { get; set; } = Guid.NewGuid(); - public ICollection Pockets { get; set; } = new List(); + public ICollection Pockets { get; set; } = new List(); public Guid AccountId { get; set; } - public Account.Account Account { get; set; } = null!; + public SnAccount Account { get; set; } = null!; - public Shared.Proto.Wallet ToProtoValue() + public Proto.Wallet ToProtoValue() { - var proto = new Shared.Proto.Wallet + var proto = new Proto.Wallet { Id = Id.ToString(), AccountId = AccountId.ToString(), @@ -31,24 +29,24 @@ public class Wallet : ModelBase return proto; } - public static Wallet FromProtoValue(Shared.Proto.Wallet proto) => new() + public static SnWallet FromProtoValue(Proto.Wallet proto) => new() { Id = Guid.Parse(proto.Id), AccountId = Guid.Parse(proto.AccountId), - Pockets = proto.Pockets.Select(WalletPocket.FromProtoValue).ToList(), + Pockets = [.. proto.Pockets.Select(SnWalletPocket.FromProtoValue)], }; } -public class WalletPocket : ModelBase +public class SnWalletPocket : ModelBase { public Guid Id { get; set; } = Guid.NewGuid(); [MaxLength(128)] public string Currency { get; set; } = null!; public decimal Amount { get; set; } public Guid WalletId { get; set; } - [JsonIgnore] public Wallet Wallet { get; set; } = null!; + [JsonIgnore] public SnWallet Wallet { get; set; } = null!; - public Shared.Proto.WalletPocket ToProtoValue() => new() + public Proto.WalletPocket ToProtoValue() => new() { Id = Id.ToString(), Currency = Currency, @@ -56,7 +54,7 @@ public class WalletPocket : ModelBase WalletId = WalletId.ToString(), }; - public static WalletPocket FromProtoValue(Shared.Proto.WalletPocket proto) => new() + public static SnWalletPocket FromProtoValue(Proto.WalletPocket proto) => new() { Id = Guid.Parse(proto.Id), Currency = proto.Currency, diff --git a/DysonNetwork.Shared/Data/WebSocket.cs b/DysonNetwork.Shared/Models/WebSocket.cs similarity index 91% rename from DysonNetwork.Shared/Data/WebSocket.cs rename to DysonNetwork.Shared/Models/WebSocket.cs index c50bf85..f240579 100644 --- a/DysonNetwork.Shared/Data/WebSocket.cs +++ b/DysonNetwork.Shared/Models/WebSocket.cs @@ -1,4 +1,4 @@ -namespace DysonNetwork.Shared.Data; +namespace DysonNetwork.Shared.Models; public abstract class WebSocketPacketType { diff --git a/DysonNetwork.Shared/Data/WebSocketPacket.cs b/DysonNetwork.Shared/Models/WebSocketPacket.cs similarity index 89% rename from DysonNetwork.Shared/Data/WebSocketPacket.cs rename to DysonNetwork.Shared/Models/WebSocketPacket.cs index 260337b..7d4137e 100644 --- a/DysonNetwork.Shared/Data/WebSocketPacket.cs +++ b/DysonNetwork.Shared/Models/WebSocketPacket.cs @@ -1,10 +1,8 @@ using System.Text.Json; using System.Text.Json.Serialization; using DysonNetwork.Shared.Proto; -using NodaTime; -using NodaTime.Serialization.SystemTextJson; -namespace DysonNetwork.Shared.Data; +namespace DysonNetwork.Shared.Models; public class WebSocketPacket { @@ -57,9 +55,9 @@ public class WebSocketPacket return System.Text.Encoding.UTF8.GetBytes(json); } - public Shared.Proto.WebSocketPacket ToProtoValue() + public Proto.WebSocketPacket ToProtoValue() { - return new Shared.Proto.WebSocketPacket + return new Proto.WebSocketPacket { Type = Type, Data = GrpcTypeHelper.ConvertObjectToByteString(Data), @@ -67,7 +65,7 @@ public class WebSocketPacket }; } - public static WebSocketPacket FromProtoValue(Shared.Proto.WebSocketPacket packet) + public static WebSocketPacket FromProtoValue(Proto.WebSocketPacket packet) { return new WebSocketPacket { diff --git a/DysonNetwork.Shared/Proto/GrpcClientHelper.cs b/DysonNetwork.Shared/Proto/GrpcClientHelper.cs index ddb79de..68689e4 100644 --- a/DysonNetwork.Shared/Proto/GrpcClientHelper.cs +++ b/DysonNetwork.Shared/Proto/GrpcClientHelper.cs @@ -1,6 +1,4 @@ -using System.Net; using Grpc.Net.Client; -using System.Security.Cryptography.X509Certificates; using Grpc.Core; namespace DysonNetwork.Shared.Proto; diff --git a/DysonNetwork.Shared/Registry/AccountClientHelper.cs b/DysonNetwork.Shared/Registry/AccountClientHelper.cs index edbc356..4d6cd57 100644 --- a/DysonNetwork.Shared/Registry/AccountClientHelper.cs +++ b/DysonNetwork.Shared/Registry/AccountClientHelper.cs @@ -1,4 +1,5 @@ using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using DysonNetwork.Shared.Proto; namespace DysonNetwork.Shared.Registry; @@ -35,13 +36,13 @@ public class AccountClientHelper(AccountService.AccountServiceClient accounts) return response.Accounts.ToList(); } - public async Task> GetAccountStatusBatch(List ids) + public async Task> GetAccountStatusBatch(List ids) { var request = new GetAccountBatchRequest(); request.Id.AddRange(ids.Select(id => id.ToString())); var response = await accounts.GetAccountStatusBatchAsync(request); return response.Statuses - .Select(AccountStatusReference.FromProtoValue) + .Select(SnAccountStatus.FromProtoValue) .ToDictionary(s => s.AccountId, s => s); } } \ No newline at end of file diff --git a/DysonNetwork.Shared/Registry/ServiceInjectionHelper.cs b/DysonNetwork.Shared/Registry/ServiceInjectionHelper.cs index d948adf..bd7441a 100644 --- a/DysonNetwork.Shared/Registry/ServiceInjectionHelper.cs +++ b/DysonNetwork.Shared/Registry/ServiceInjectionHelper.cs @@ -1,5 +1,4 @@ using DysonNetwork.Shared.Proto; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; namespace DysonNetwork.Shared.Registry; diff --git a/DysonNetwork.Sphere/Activity/ActivityService.cs b/DysonNetwork.Sphere/Activity/ActivityService.cs index 6b427e6..7702af6 100644 --- a/DysonNetwork.Sphere/Activity/ActivityService.cs +++ b/DysonNetwork.Sphere/Activity/ActivityService.cs @@ -1,3 +1,4 @@ +using DysonNetwork.Shared.Models; using DysonNetwork.Shared.Proto; using DysonNetwork.Sphere.Discovery; using DysonNetwork.Sphere.Post; @@ -17,7 +18,7 @@ public class ActivityService( AccountService.AccountServiceClient accounts ) { - private static double CalculateHotRank(Post.Post post, Instant now) + private static double CalculateHotRank(SnPost post, Instant now) { var performanceScore = post.Upvotes - post.Downvotes + post.RepliesCount + (int)post.AwardedScore / 10; var postTime = post.PublishedAt ?? post.CreatedAt; @@ -163,7 +164,7 @@ public class ActivityService( return await pick(); } - private static List RankPosts(List posts, int take) + private static List RankPosts(List posts, int take) { var now = SystemClock.Instance.GetCurrentInstant(); return posts @@ -175,7 +176,7 @@ public class ActivityService( // return posts.Take(take).ToList(); } - private async Task> GetPopularPublishers(int take) + private async Task> GetPopularPublishers(int take) { var now = SystemClock.Instance.GetCurrentInstant(); var recent = now.Minus(Duration.FromDays(7)); @@ -268,11 +269,11 @@ public class ActivityService( : null; } - private async Task> GetAndProcessPosts( - IQueryable baseQuery, + private async Task> GetAndProcessPosts( + IQueryable baseQuery, Account? currentUser = null, List? userFriends = null, - List? userPublishers = null, + List? userPublishers = null, bool trackViews = true) { var posts = await baseQuery.ToListAsync(); @@ -294,7 +295,7 @@ public class ActivityService( return posts; } - private IQueryable BuildPostsQuery( + private IQueryable BuildPostsQuery( Instant? cursor, List? filteredPublishersId = null, List? userRealms = null @@ -322,7 +323,7 @@ public class ActivityService( return query; } - private async Task?> GetFilteredPublishers( + private async Task?> GetFilteredPublishers( string? filter, Account currentUser, List userFriends) @@ -338,7 +339,7 @@ public class ActivityService( }; } - private static double CalculatePopularity(List posts) + private static double CalculatePopularity(List posts) { var score = posts.Sum(p => p.Upvotes - p.Downvotes); var postCount = posts.Count; diff --git a/DysonNetwork.Sphere/Activity/DiscoveryActivity.cs b/DysonNetwork.Sphere/Activity/DiscoveryActivity.cs index 6111589..7d6d869 100644 --- a/DysonNetwork.Sphere/Activity/DiscoveryActivity.cs +++ b/DysonNetwork.Sphere/Activity/DiscoveryActivity.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using DysonNetwork.Shared.Models; using NodaTime; namespace DysonNetwork.Sphere.Activity; diff --git a/DysonNetwork.Sphere/AppDatabase.cs b/DysonNetwork.Sphere/AppDatabase.cs index f5e7806..dc5588e 100644 --- a/DysonNetwork.Sphere/AppDatabase.cs +++ b/DysonNetwork.Sphere/AppDatabase.cs @@ -1,11 +1,7 @@ using System.Linq.Expressions; using System.Reflection; using DysonNetwork.Shared.Data; -using DysonNetwork.Sphere.Chat; -using DysonNetwork.Sphere.Post; -using DysonNetwork.Sphere.Publisher; -using DysonNetwork.Sphere.Realm; -using DysonNetwork.Sphere.Sticker; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Design; using Microsoft.EntityFrameworkCore.Query; @@ -24,34 +20,34 @@ public class AppDatabase( IConfiguration configuration ) : DbContext(options) { - public DbSet Publishers { get; set; } = null!; + public DbSet Publishers { get; set; } = null!; public DbSet PublisherMembers { get; set; } = null!; public DbSet PublisherSubscriptions { get; set; } = null!; public DbSet PublisherFeatures { get; set; } = null!; - public DbSet Posts { get; set; } = null!; - public DbSet PostReactions { get; set; } = null!; - public DbSet PostAwards { get; set; } = null!; - public DbSet PostTags { get; set; } = null!; - public DbSet PostCategories { get; set; } = null!; - public DbSet PostCollections { get; set; } = null!; - public DbSet PostFeaturedRecords { get; set; } = null!; - public DbSet PostCategorySubscriptions { get; set; } = null!; + public DbSet Posts { get; set; } = null!; + public DbSet PostReactions { get; set; } = null!; + public DbSet PostAwards { get; set; } = null!; + public DbSet PostTags { get; set; } = null!; + public DbSet PostCategories { get; set; } = null!; + public DbSet PostCollections { get; set; } = null!; + public DbSet PostFeaturedRecords { get; set; } = null!; + public DbSet PostCategorySubscriptions { get; set; } = null!; - public DbSet Polls { get; set; } = null!; - public DbSet PollQuestions { get; set; } = null!; - public DbSet PollAnswers { get; set; } = null!; + public DbSet Polls { get; set; } = null!; + public DbSet PollQuestions { get; set; } = null!; + public DbSet PollAnswers { get; set; } = null!; - public DbSet Realms { get; set; } = null!; - public DbSet RealmMembers { get; set; } = null!; + public DbSet Realms { get; set; } = null!; + public DbSet RealmMembers { get; set; } = null!; - public DbSet ChatRooms { get; set; } = null!; - public DbSet ChatMembers { get; set; } = null!; - public DbSet ChatMessages { get; set; } = null!; - public DbSet ChatRealtimeCall { get; set; } = null!; - public DbSet ChatReactions { get; set; } = null!; + public DbSet ChatRooms { get; set; } = null!; + public DbSet ChatMembers { get; set; } = null!; + public DbSet ChatMessages { get; set; } = null!; + public DbSet ChatRealtimeCall { get; set; } = null!; + public DbSet ChatReactions { get; set; } = null!; - public DbSet Stickers { get; set; } = null!; + public DbSet Stickers { get; set; } = null!; public DbSet StickerPacks { get; set; } = null!; public DbSet StickerPackOwnerships { get; set; } = null!; @@ -89,67 +85,67 @@ public class AppDatabase( .HasForeignKey(ps => ps.PublisherId) .OnDelete(DeleteBehavior.Cascade); - modelBuilder.Entity() + modelBuilder.Entity() .HasGeneratedTsVectorColumn(p => p.SearchVector, "simple", p => new { p.Title, p.Description, p.Content }) .HasIndex(p => p.SearchVector) .HasMethod("GIN"); - modelBuilder.Entity() + modelBuilder.Entity() .HasOne(p => p.RepliedPost) .WithMany() .HasForeignKey(p => p.RepliedPostId) .OnDelete(DeleteBehavior.Restrict); - modelBuilder.Entity() + modelBuilder.Entity() .HasOne(p => p.ForwardedPost) .WithMany() .HasForeignKey(p => p.ForwardedPostId) .OnDelete(DeleteBehavior.Restrict); - modelBuilder.Entity() + modelBuilder.Entity() .HasMany(p => p.Tags) .WithMany(t => t.Posts) .UsingEntity(j => j.ToTable("post_tag_links")); - modelBuilder.Entity() + modelBuilder.Entity() .HasMany(p => p.Categories) .WithMany(c => c.Posts) .UsingEntity(j => j.ToTable("post_category_links")); - modelBuilder.Entity() + modelBuilder.Entity() .HasMany(p => p.Collections) .WithMany(c => c.Posts) .UsingEntity(j => j.ToTable("post_collection_links")); - modelBuilder.Entity() + modelBuilder.Entity() .HasKey(pm => new { pm.RealmId, pm.AccountId }); - modelBuilder.Entity() + modelBuilder.Entity() .HasOne(pm => pm.Realm) .WithMany(p => p.Members) .HasForeignKey(pm => pm.RealmId) .OnDelete(DeleteBehavior.Cascade); - modelBuilder.Entity() + modelBuilder.Entity() .HasKey(pm => new { pm.Id }); - modelBuilder.Entity() + modelBuilder.Entity() .HasAlternateKey(pm => new { pm.ChatRoomId, pm.AccountId }); - modelBuilder.Entity() + modelBuilder.Entity() .HasOne(pm => pm.ChatRoom) .WithMany(p => p.Members) .HasForeignKey(pm => pm.ChatRoomId) .OnDelete(DeleteBehavior.Cascade); - modelBuilder.Entity() + modelBuilder.Entity() .HasOne(m => m.ForwardedMessage) .WithMany() .HasForeignKey(m => m.ForwardedMessageId) .OnDelete(DeleteBehavior.Restrict); - modelBuilder.Entity() + modelBuilder.Entity() .HasOne(m => m.RepliedMessage) .WithMany() .HasForeignKey(m => m.RepliedMessageId) .OnDelete(DeleteBehavior.Restrict); - modelBuilder.Entity() + modelBuilder.Entity() .HasOne(m => m.Room) .WithMany() .HasForeignKey(m => m.RoomId) .OnDelete(DeleteBehavior.Cascade); - modelBuilder.Entity() + modelBuilder.Entity() .HasOne(m => m.Sender) .WithMany() .HasForeignKey(m => m.SenderId) diff --git a/DysonNetwork.Sphere/Chat/ChatController.cs b/DysonNetwork.Sphere/Chat/ChatController.cs index bb33c16..4800d34 100644 --- a/DysonNetwork.Sphere/Chat/ChatController.cs +++ b/DysonNetwork.Sphere/Chat/ChatController.cs @@ -2,7 +2,7 @@ using System.ComponentModel.DataAnnotations; using System.Text.RegularExpressions; using DysonNetwork.Shared.Auth; using DysonNetwork.Shared.Content; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using DysonNetwork.Shared.Proto; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; @@ -33,7 +33,7 @@ public partial class ChatController( public class ChatSummaryResponse { public int UnreadCount { get; set; } - public Message? LastMessage { get; set; } + public SnChatMessage? LastMessage { get; set; } } [HttpGet("summary")] @@ -71,7 +71,7 @@ public partial class ChatController( } [HttpGet("{roomId:guid}/messages")] - public async Task>> ListMessages(Guid roomId, [FromQuery] int offset, + public async Task>> ListMessages(Guid roomId, [FromQuery] int offset, [FromQuery] int take = 20) { var currentUser = HttpContext.Items["CurrentUser"] as Account; @@ -114,7 +114,7 @@ public partial class ChatController( } [HttpGet("{roomId:guid}/messages/{messageId:guid}")] - public async Task> GetMessage(Guid roomId, Guid messageId) + public async Task> GetMessage(Guid roomId, Guid messageId) { var currentUser = HttpContext.Items["CurrentUser"] as Account; @@ -165,7 +165,7 @@ public partial class ChatController( if (member == null || member.Role < ChatMemberRole.Member) return StatusCode(403, "You need to be a normal member to send messages here."); - var message = new Message + var message = new SnChatMessage { Type = "text", SenderId = member.Id, @@ -182,7 +182,7 @@ public partial class ChatController( var queryResponse = await files.GetFileBatchAsync(queryRequest); message.Attachments = queryResponse.Files .OrderBy(f => request.AttachmentsId.IndexOf(f.Id)) - .Select(CloudFileReferenceObject.FromProtoValue) + .Select(SnCloudFileReferenceObject.FromProtoValue) .ToList(); } diff --git a/DysonNetwork.Sphere/Chat/ChatRoomController.cs b/DysonNetwork.Sphere/Chat/ChatRoomController.cs index 895539d..4e69267 100644 --- a/DysonNetwork.Sphere/Chat/ChatRoomController.cs +++ b/DysonNetwork.Sphere/Chat/ChatRoomController.cs @@ -3,7 +3,6 @@ using Microsoft.EntityFrameworkCore; using System.ComponentModel.DataAnnotations; using DysonNetwork.Shared; using DysonNetwork.Shared.Auth; -using DysonNetwork.Shared.Data; using DysonNetwork.Shared.Proto; using DysonNetwork.Shared.Registry; using DysonNetwork.Sphere.Localization; @@ -12,6 +11,7 @@ using Grpc.Core; using Microsoft.AspNetCore.Authorization; using Microsoft.Extensions.Localization; using NodaTime; +using DysonNetwork.Shared.Models; namespace DysonNetwork.Sphere.Chat; @@ -31,7 +31,7 @@ public class ChatRoomController( ) : ControllerBase { [HttpGet("{id:guid}")] - public async Task> GetChatRoom(Guid id) + public async Task> GetChatRoom(Guid id) { var chatRoom = await db.ChatRooms .Where(c => c.Id == id) @@ -48,7 +48,7 @@ public class ChatRoomController( [HttpGet] [Authorize] - public async Task>> ListJoinedChatRooms() + public async Task>> ListJoinedChatRooms() { if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized(); @@ -74,7 +74,7 @@ public class ChatRoomController( [HttpPost("direct")] [Authorize] - public async Task> CreateDirectMessage([FromBody] DirectMessageRequest request) + public async Task> CreateDirectMessage([FromBody] DirectMessageRequest request) { if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized(); @@ -106,11 +106,11 @@ public class ChatRoomController( return BadRequest("You already have a DM with this user."); // Create new DM chat room - var dmRoom = new ChatRoom + var dmRoom = new SnChatRoom { Type = ChatRoomType.DirectMessage, IsPublic = false, - Members = new List + Members = new List { new() { @@ -148,7 +148,7 @@ public class ChatRoomController( [HttpGet("direct/{accountId:guid}")] [Authorize] - public async Task> GetDirectChatRoom(Guid accountId) + public async Task> GetDirectChatRoom(Guid accountId) { if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized(); @@ -178,19 +178,19 @@ public class ChatRoomController( [HttpPost] [Authorize] [RequiredPermission("global", "chat.create")] - public async Task> CreateChatRoom(ChatRoomRequest request) + public async Task> CreateChatRoom(ChatRoomRequest request) { if (HttpContext.Items["CurrentUser"] is not Shared.Proto.Account currentUser) return Unauthorized(); if (request.Name is null) return BadRequest("You cannot create a chat room without a name."); - var chatRoom = new ChatRoom + var chatRoom = new SnChatRoom { Name = request.Name, Description = request.Description ?? string.Empty, IsCommunity = request.IsCommunity ?? false, IsPublic = request.IsPublic ?? false, Type = ChatRoomType.Group, - Members = new List + Members = new List { new() { @@ -215,7 +215,7 @@ public class ChatRoomController( { var fileResponse = await files.GetFileAsync(new GetFileRequest { Id = request.PictureId }); if (fileResponse == null) return BadRequest("Invalid picture id, unable to find the file on cloud."); - chatRoom.Picture = CloudFileReferenceObject.FromProtoValue(fileResponse); + chatRoom.Picture = SnCloudFileReferenceObject.FromProtoValue(fileResponse); await fileRefs.CreateReferenceAsync(new CreateReferenceRequest { @@ -236,7 +236,7 @@ public class ChatRoomController( { var fileResponse = await files.GetFileAsync(new GetFileRequest { Id = request.BackgroundId }); if (fileResponse == null) return BadRequest("Invalid background id, unable to find the file on cloud."); - chatRoom.Background = CloudFileReferenceObject.FromProtoValue(fileResponse); + chatRoom.Background = SnCloudFileReferenceObject.FromProtoValue(fileResponse); await fileRefs.CreateReferenceAsync(new CreateReferenceRequest { @@ -290,7 +290,7 @@ public class ChatRoomController( [HttpPatch("{id:guid}")] - public async Task> UpdateChatRoom(Guid id, [FromBody] ChatRoomRequest request) + public async Task> UpdateChatRoom(Guid id, [FromBody] ChatRoomRequest request) { if (HttpContext.Items["CurrentUser"] is not Shared.Proto.Account currentUser) return Unauthorized(); @@ -341,7 +341,7 @@ public class ChatRoomController( ResourceId = chatRoom.ResourceIdentifier }); - chatRoom.Picture = CloudFileReferenceObject.FromProtoValue(fileResponse); + chatRoom.Picture = SnCloudFileReferenceObject.FromProtoValue(fileResponse); } catch (RpcException ex) when (ex.StatusCode == Grpc.Core.StatusCode.NotFound) { @@ -371,7 +371,7 @@ public class ChatRoomController( ResourceId = chatRoom.ResourceIdentifier }); - chatRoom.Background = CloudFileReferenceObject.FromProtoValue(fileResponse); + chatRoom.Background = SnCloudFileReferenceObject.FromProtoValue(fileResponse); } catch (RpcException ex) when (ex.StatusCode == Grpc.Core.StatusCode.NotFound) { @@ -468,7 +468,7 @@ public class ChatRoomController( [HttpGet("{roomId:guid}/members/me")] [Authorize] - public async Task> GetRoomIdentity(Guid roomId) + public async Task> GetRoomIdentity(Guid roomId) { if (HttpContext.Items["CurrentUser"] is not Shared.Proto.Account currentUser) return Unauthorized(); @@ -484,7 +484,7 @@ public class ChatRoomController( } [HttpGet("{roomId:guid}/members")] - public async Task>> ListMembers(Guid roomId, + public async Task>> ListMembers(Guid roomId, [FromQuery] int take = 20, [FromQuery] int offset = 0, [FromQuery] bool withStatus = false @@ -561,7 +561,7 @@ public class ChatRoomController( [HttpPost("invites/{roomId:guid}")] [Authorize] - public async Task> InviteMember(Guid roomId, + public async Task> InviteMember(Guid roomId, [FromBody] ChatMemberRequest request) { if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized(); @@ -620,7 +620,7 @@ public class ChatRoomController( if (hasExistingMember) return BadRequest("This user has been joined the chat cannot be invited again."); - var newMember = new ChatMember + var newMember = new SnChatMember { AccountId = Guid.Parse(relatedUser.Id), ChatRoomId = roomId, @@ -651,7 +651,7 @@ public class ChatRoomController( [HttpGet("invites")] [Authorize] - public async Task>> ListChatInvites() + public async Task>> ListChatInvites() { if (HttpContext.Items["CurrentUser"] is not Shared.Proto.Account currentUser) return Unauthorized(); var accountId = Guid.Parse(currentUser.Id); @@ -674,7 +674,7 @@ public class ChatRoomController( [HttpPost("invites/{roomId:guid}/accept")] [Authorize] - public async Task> AcceptChatInvite(Guid roomId) + public async Task> AcceptChatInvite(Guid roomId) { if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized(); var accountId = Guid.Parse(currentUser.Id); @@ -731,7 +731,7 @@ public class ChatRoomController( [HttpPatch("{roomId:guid}/members/me/notify")] [Authorize] - public async Task> UpdateChatMemberNotify( + public async Task> UpdateChatMemberNotify( Guid roomId, [FromBody] ChatMemberNotifyRequest request ) @@ -763,7 +763,7 @@ public class ChatRoomController( [HttpPatch("{roomId:guid}/members/{memberId:guid}/role")] [Authorize] - public async Task> UpdateChatMemberRole(Guid roomId, Guid memberId, [FromBody] int newRole) + public async Task> UpdateChatMemberRole(Guid roomId, Guid memberId, [FromBody] int newRole) { if (newRole >= ChatMemberRole.Owner) return BadRequest("Unable to set chat member to owner or greater role."); if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized(); @@ -885,7 +885,7 @@ public class ChatRoomController( [HttpPost("{roomId:guid}/members/me")] [Authorize] - public async Task> JoinChatRoom(Guid roomId) + public async Task> JoinChatRoom(Guid roomId) { if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized(); @@ -901,7 +901,7 @@ public class ChatRoomController( if (existingMember != null) return BadRequest("You are already a member of this chat room."); - var newMember = new ChatMember + var newMember = new SnChatMember { AccountId = Guid.Parse(currentUser.Id), ChatRoomId = roomId, @@ -966,7 +966,7 @@ public class ChatRoomController( return NoContent(); } - private async Task _SendInviteNotify(ChatMember member, Account sender) + private async Task _SendInviteNotify(SnChatMember member, Account sender) { var account = await accounts.GetAccountAsync(new GetAccountRequest { Id = member.AccountId.ToString() }); CultureService.SetCultureInfo(account); diff --git a/DysonNetwork.Sphere/Chat/ChatRoomService.cs b/DysonNetwork.Sphere/Chat/ChatRoomService.cs index a3a0ada..b6d6efb 100644 --- a/DysonNetwork.Sphere/Chat/ChatRoomService.cs +++ b/DysonNetwork.Sphere/Chat/ChatRoomService.cs @@ -1,8 +1,9 @@ using DysonNetwork.Shared.Cache; +using DysonNetwork.Shared.Models; using DysonNetwork.Shared.Registry; using Microsoft.EntityFrameworkCore; using NodaTime; -using Account = DysonNetwork.Shared.Data.AccountReference; +using Account = DysonNetwork.Shared.Data.SnAccount; namespace DysonNetwork.Sphere.Chat; @@ -16,10 +17,10 @@ public class ChatRoomService( private const string RoomMembersCacheKeyPrefix = "chatroom:members:"; private const string ChatMemberCacheKey = "chatroom:{0}:member:{1}"; - public async Task> ListRoomMembers(Guid roomId) + public async Task> ListRoomMembers(Guid roomId) { var cacheKey = RoomMembersCacheKeyPrefix + roomId; - var cachedMembers = await cache.GetAsync>(cacheKey); + var cachedMembers = await cache.GetAsync>(cacheKey); if (cachedMembers != null) return cachedMembers; @@ -38,10 +39,10 @@ public class ChatRoomService( return members; } - public async Task GetRoomMember(Guid accountId, Guid chatRoomId) + public async Task GetRoomMember(Guid accountId, Guid chatRoomId) { var cacheKey = string.Format(ChatMemberCacheKey, accountId, chatRoomId); - var member = await cache.GetAsync(cacheKey); + var member = await cache.GetAsync(cacheKey); if (member is not null) return member; member = await db.ChatMembers @@ -66,7 +67,7 @@ public class ChatRoomService( await cache.RemoveGroupAsync(chatRoomGroup); } - public async Task> SortChatRoomByLastMessage(List rooms) + public async Task> SortChatRoomByLastMessage(List rooms) { var roomIds = rooms.Select(r => r.Id).ToList(); var lastMessages = await db.ChatMessages @@ -83,7 +84,7 @@ public class ChatRoomService( return sortedRooms; } - public async Task> LoadDirectMessageMembers(List rooms, Guid userId) + public async Task> LoadDirectMessageMembers(List rooms, Guid userId) { var directRoomsId = rooms .Where(r => r.Type == ChatRoomType.DirectMessage) @@ -91,7 +92,7 @@ public class ChatRoomService( .ToList(); if (directRoomsId.Count == 0) return rooms; - List members = directRoomsId.Count != 0 + List members = directRoomsId.Count != 0 ? await db.ChatMembers .Where(m => directRoomsId.Contains(m.ChatRoomId)) .Where(m => m.AccountId != userId) @@ -100,7 +101,7 @@ public class ChatRoomService( : []; members = await LoadMemberAccounts(members); - Dictionary> directMembers = new(); + Dictionary> directMembers = new(); foreach (var member in members) { if (!directMembers.ContainsKey(member.ChatRoomId)) @@ -116,7 +117,7 @@ public class ChatRoomService( }).ToList(); } - public async Task LoadDirectMessageMembers(ChatRoom room, Guid userId) + public async Task LoadDirectMessageMembers(SnChatRoom room, Guid userId) { if (room.Type != ChatRoomType.DirectMessage) return room; var members = await db.ChatMembers @@ -143,14 +144,14 @@ public class ChatRoomService( return member?.Role >= maxRequiredRole; } - public async Task LoadMemberAccount(ChatMember member) + public async Task LoadMemberAccount(SnChatMember member) { var account = await accountsHelper.GetAccount(member.AccountId); member.Account = Account.FromProtoValue(account); return member; } - public async Task> LoadMemberAccounts(ICollection members) + public async Task> LoadMemberAccounts(ICollection members) { var accountIds = members.Select(m => m.AccountId).ToList(); var accounts = (await accountsHelper.GetAccountBatch(accountIds)).ToDictionary(a => Guid.Parse(a.Id), a => a); diff --git a/DysonNetwork.Sphere/Chat/ChatService.cs b/DysonNetwork.Sphere/Chat/ChatService.cs index d5384e3..7ef4447 100644 --- a/DysonNetwork.Sphere/Chat/ChatService.cs +++ b/DysonNetwork.Sphere/Chat/ChatService.cs @@ -1,5 +1,5 @@ using System.Text.RegularExpressions; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using DysonNetwork.Shared.Proto; using DysonNetwork.Sphere.Chat.Realtime; using DysonNetwork.Sphere.WebReader; @@ -29,7 +29,7 @@ public partial class ChatService( /// This method is designed to be called from a background task /// /// The message to process link previews for - private async Task ProcessMessageLinkPreviewAsync(Message message) + private async Task ProcessMessageLinkPreviewAsync(SnChatMessage message) { try { @@ -66,7 +66,7 @@ public partial class ChatService( logger.LogDebug($"Updated message {message.Id} with {embedsList.Count} link previews"); // Create and store sync message for link preview update - var syncMessage = new Message + var syncMessage = new SnChatMessage { Type = "messages.update.links", ChatRoomId = dbMessage.ChatRoomId, @@ -114,7 +114,7 @@ public partial class ChatService( /// The message to process /// The web reader service /// The message with link previews added to its meta data - public async Task PreviewMessageLinkAsync(Message message, WebReaderService? webReader = null) + public async Task PreviewMessageLinkAsync(SnChatMessage message, WebReaderService? webReader = null) { if (string.IsNullOrEmpty(message.Content)) return message; @@ -172,9 +172,9 @@ public partial class ChatService( } private async Task DeliverWebSocketMessage( - Message message, + SnChatMessage message, string type, - List members, + List members, IServiceScope scope ) { @@ -195,7 +195,7 @@ public partial class ChatService( logger.LogInformation($"Delivered message to {request.UserIds.Count} accounts."); } - public async Task SendMessageAsync(Message message, ChatMember sender, ChatRoom room) + public async Task SendMessageAsync(SnChatMessage message, SnChatMember sender, SnChatRoom room) { if (string.IsNullOrWhiteSpace(message.Nonce)) message.Nonce = Guid.NewGuid().ToString(); message.CreatedAt = SystemClock.Instance.GetCurrentInstant(); @@ -230,9 +230,9 @@ public partial class ChatService( } private async Task DeliverMessageAsync( - Message message, - ChatMember sender, - ChatRoom room, + SnChatMessage message, + SnChatMember sender, + SnChatRoom room, string type = WebSocketPacketType.MessageNew, bool notify = true ) @@ -254,11 +254,11 @@ public partial class ChatService( } private async Task SendPushNotificationsAsync( - Message message, - ChatMember sender, - ChatRoom room, + SnChatMessage message, + SnChatMember sender, + SnChatRoom room, string type, - List members, + List members, IServiceScope scope ) { @@ -292,7 +292,7 @@ public partial class ChatService( logger.LogInformation($"Delivered message to {accountsToNotify.Count} accounts."); } - private PushNotification BuildNotification(Message message, ChatMember sender, ChatRoom room, string roomSubject, + private PushNotification BuildNotification(SnChatMessage message, SnChatMember sender, SnChatRoom room, string roomSubject, string type) { var metaDict = new Dictionary @@ -325,7 +325,7 @@ public partial class ChatService( return notification; } - private string BuildNotificationBody(Message message, string type) + private string BuildNotificationBody(SnChatMessage message, string type) { if (message.DeletedAt is not null) return "Deleted a message"; @@ -356,7 +356,7 @@ public partial class ChatService( } } - private List FilterAccountsForNotification(List members, Message message, ChatMember sender) + private List FilterAccountsForNotification(List members, SnChatMessage message, SnChatMember sender) { var now = SystemClock.Instance.GetCurrentInstant(); @@ -377,7 +377,7 @@ public partial class ChatService( return accountsToNotify.Where(a => a.Id != sender.AccountId.ToString()).ToList(); } - private async Task CreateFileReferencesForMessageAsync(Message message) + private async Task CreateFileReferencesForMessageAsync(SnChatMessage message) { var files = message.Attachments.Distinct().ToList(); if (files.Count == 0) return; @@ -391,7 +391,7 @@ public partial class ChatService( await fileRefs.CreateReferenceBatchAsync(request); } - private async Task UpdateFileReferencesForMessageAsync(Message message, List attachmentsId) + private async Task UpdateFileReferencesForMessageAsync(SnChatMessage message, List attachmentsId) { // Delete existing references for this message await fileRefs.DeleteResourceReferencesAsync( @@ -411,10 +411,10 @@ public partial class ChatService( var queryRequest = new GetFileBatchRequest(); queryRequest.Ids.AddRange(attachmentsId); var queryResult = await filesClient.GetFileBatchAsync(queryRequest); - message.Attachments = queryResult.Files.Select(CloudFileReferenceObject.FromProtoValue).ToList(); + message.Attachments = queryResult.Files.Select(SnCloudFileReferenceObject.FromProtoValue).ToList(); } - private async Task DeleteFileReferencesForMessageAsync(Message message) + private async Task DeleteFileReferencesForMessageAsync(SnChatMessage message) { var messageResourceId = $"message:{message.Id}"; await fileRefs.DeleteResourceReferencesAsync( @@ -474,7 +474,7 @@ public partial class ChatService( ); } - public async Task> ListLastMessageForUser(Guid userId) + public async Task> ListLastMessageForUser(Guid userId) { var userRooms = await db.ChatMembers .Where(m => m.LeaveAt == null && m.JoinedAt != null) @@ -517,9 +517,9 @@ public partial class ChatService( return messages; } - public async Task CreateCallAsync(ChatRoom room, ChatMember sender) + public async Task CreateCallAsync(SnChatRoom room, SnChatMember sender) { - var call = new RealtimeCall + var call = new SnRealtimeCall { RoomId = room.Id, SenderId = sender.Id, @@ -547,7 +547,7 @@ public partial class ChatService( db.ChatRealtimeCall.Add(call); await db.SaveChangesAsync(); - await SendMessageAsync(new Message + await SendMessageAsync(new SnChatMessage { Type = "call.start", ChatRoomId = room.Id, @@ -561,7 +561,7 @@ public partial class ChatService( return call; } - public async Task EndCallAsync(Guid roomId, ChatMember sender) + public async Task EndCallAsync(Guid roomId, SnChatMember sender) { var call = await GetCallOngoingAsync(roomId); if (call is null) throw new InvalidOperationException("No ongoing call was not found."); @@ -592,7 +592,7 @@ public partial class ChatService( db.ChatRealtimeCall.Update(call); await db.SaveChangesAsync(); - await SendMessageAsync(new Message + await SendMessageAsync(new SnChatMessage { Type = "call.ended", ChatRoomId = call.RoomId, @@ -605,7 +605,7 @@ public partial class ChatService( }, call.Sender, call.Room); } - public async Task GetCallOngoingAsync(Guid roomId) + public async Task GetCallOngoingAsync(Guid roomId) { return await db.ChatRealtimeCall .Where(c => c.RoomId == roomId) @@ -660,8 +660,8 @@ public partial class ChatService( } - public async Task UpdateMessageAsync( - Message message, + public async Task UpdateMessageAsync( + SnChatMessage message, Dictionary? meta = null, string? content = null, Guid? repliedMessageId = null, @@ -705,7 +705,7 @@ public partial class ChatService( await db.SaveChangesAsync(); // Create and store sync message for the update - var syncMessage = new Message + var syncMessage = new SnChatMessage { Type = "messages.update", ChatRoomId = message.ChatRoomId, @@ -751,7 +751,7 @@ public partial class ChatService( /// Soft deletes a message and notifies other chat members /// /// The message to delete - public async Task DeleteMessageAsync(Message message) + public async Task DeleteMessageAsync(SnChatMessage message) { // Only allow deleting regular text messages if (message.Type != "text") @@ -770,7 +770,7 @@ public partial class ChatService( await db.SaveChangesAsync(); // Create and store sync message for the deletion - var syncMessage = new Message + var syncMessage = new SnChatMessage { Type = "messages.delete", ChatRoomId = message.ChatRoomId, @@ -805,6 +805,6 @@ public partial class ChatService( public class SyncResponse { - public List Messages { get; set; } = []; + public List Messages { get; set; } = []; public Instant CurrentTimestamp { get; set; } } diff --git a/DysonNetwork.Sphere/Chat/RealtimeCallController.cs b/DysonNetwork.Sphere/Chat/RealtimeCallController.cs index dd5db3e..cea1ba1 100644 --- a/DysonNetwork.Sphere/Chat/RealtimeCallController.cs +++ b/DysonNetwork.Sphere/Chat/RealtimeCallController.cs @@ -1,3 +1,4 @@ +using DysonNetwork.Shared.Models; using DysonNetwork.Shared.Proto; using DysonNetwork.Sphere.Chat.Realtime; using Livekit.Server.Sdk.Dotnet; @@ -46,7 +47,7 @@ public class RealtimeCallController( [HttpGet("{roomId:guid}")] [Authorize] - public async Task> GetOngoingCall(Guid roomId) + public async Task> GetOngoingCall(Guid roomId) { if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized(); @@ -145,7 +146,7 @@ public class RealtimeCallController( [HttpPost("{roomId:guid}")] [Authorize] - public async Task> StartCall(Guid roomId) + public async Task> StartCall(Guid roomId) { if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized(); @@ -165,7 +166,7 @@ public class RealtimeCallController( [HttpDelete("{roomId:guid}")] [Authorize] - public async Task> EndCall(Guid roomId) + public async Task> EndCall(Guid roomId) { if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized(); @@ -250,7 +251,7 @@ public class CallParticipant /// /// The participant's profile in the chat /// - public ChatMember? Profile { get; set; } + public SnChatMember? Profile { get; set; } /// /// When the participant joined the call diff --git a/DysonNetwork.Sphere/Discovery/DiscoveryController.cs b/DysonNetwork.Sphere/Discovery/DiscoveryController.cs index fe07add..59ba95b 100644 --- a/DysonNetwork.Sphere/Discovery/DiscoveryController.cs +++ b/DysonNetwork.Sphere/Discovery/DiscoveryController.cs @@ -7,7 +7,7 @@ namespace DysonNetwork.Sphere.Discovery; public class DiscoveryController(DiscoveryService discoveryService) : ControllerBase { [HttpGet("realms")] - public Task> GetPublicRealms( + public Task> GetPublicRealms( [FromQuery] string? query, [FromQuery] int take = 10, [FromQuery] int offset = 0 diff --git a/DysonNetwork.Sphere/Discovery/DiscoveryService.cs b/DysonNetwork.Sphere/Discovery/DiscoveryService.cs index 3e563a3..ac6ec65 100644 --- a/DysonNetwork.Sphere/Discovery/DiscoveryService.cs +++ b/DysonNetwork.Sphere/Discovery/DiscoveryService.cs @@ -4,7 +4,7 @@ namespace DysonNetwork.Sphere.Discovery; public class DiscoveryService(AppDatabase appDatabase) { - public Task> GetCommunityRealmAsync( + public Task> GetCommunityRealmAsync( string? query, int take = 10, int offset = 0, diff --git a/DysonNetwork.Sphere/Migrations/20250717135738_InitialMigration.Designer.cs b/DysonNetwork.Sphere/Migrations/20250717135738_InitialMigration.Designer.cs index b7934f5..a5cacfb 100644 --- a/DysonNetwork.Sphere/Migrations/20250717135738_InitialMigration.Designer.cs +++ b/DysonNetwork.Sphere/Migrations/20250717135738_InitialMigration.Designer.cs @@ -1,9 +1,8 @@ // using System; using System.Collections.Generic; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using DysonNetwork.Sphere; -using DysonNetwork.Sphere.Chat; using DysonNetwork.Sphere.WebReader; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; @@ -116,7 +115,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -151,7 +150,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(1024)") .HasColumnName("name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -188,7 +187,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property>("Attachments") + b.Property>("Attachments") .IsRequired() .HasColumnType("jsonb") .HasColumnName("attachments"); @@ -379,7 +378,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -402,7 +401,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(1024)") .HasColumnName("name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -424,7 +423,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); @@ -499,7 +498,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property>("Attachments") + b.Property>("Attachments") .IsRequired() .HasColumnType("jsonb") .HasColumnName("attachments"); @@ -792,7 +791,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("account_id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -826,7 +825,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(256)") .HasColumnName("nick"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -847,7 +846,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); @@ -997,7 +996,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("account_id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -1034,7 +1033,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(1024)") .HasColumnName("name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -1053,7 +1052,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); @@ -1184,7 +1183,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("deleted_at"); - b.Property("Image") + b.Property("Image") .HasColumnType("jsonb") .HasColumnName("image"); diff --git a/DysonNetwork.Sphere/Migrations/20250717135738_InitialMigration.cs b/DysonNetwork.Sphere/Migrations/20250717135738_InitialMigration.cs index 8726790..10a0fc7 100644 --- a/DysonNetwork.Sphere/Migrations/20250717135738_InitialMigration.cs +++ b/DysonNetwork.Sphere/Migrations/20250717135738_InitialMigration.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; -using DysonNetwork.Shared.Data; -using DysonNetwork.Sphere.Chat; +using DysonNetwork.Shared.Models; using DysonNetwork.Sphere.WebReader; using Microsoft.EntityFrameworkCore.Migrations; using NodaTime; @@ -64,9 +63,9 @@ namespace DysonNetwork.Sphere.Migrations is_public = table.Column(type: "boolean", nullable: false), picture_id = table.Column(type: "character varying(32)", maxLength: 32, nullable: true), background_id = table.Column(type: "character varying(32)", maxLength: 32, nullable: true), - picture = table.Column(type: "jsonb", nullable: true), - background = table.Column(type: "jsonb", nullable: true), - verification = table.Column(type: "jsonb", nullable: true), + picture = table.Column(type: "jsonb", nullable: true), + background = table.Column(type: "jsonb", nullable: true), + verification = table.Column(type: "jsonb", nullable: true), account_id = table.Column(type: "uuid", nullable: false), created_at = table.Column(type: "timestamp with time zone", nullable: false), updated_at = table.Column(type: "timestamp with time zone", nullable: false), @@ -104,8 +103,8 @@ namespace DysonNetwork.Sphere.Migrations is_public = table.Column(type: "boolean", nullable: false), picture_id = table.Column(type: "character varying(32)", maxLength: 32, nullable: true), background_id = table.Column(type: "character varying(32)", maxLength: 32, nullable: true), - picture = table.Column(type: "jsonb", nullable: true), - background = table.Column(type: "jsonb", nullable: true), + picture = table.Column(type: "jsonb", nullable: true), + background = table.Column(type: "jsonb", nullable: true), realm_id = table.Column(type: "uuid", nullable: true), created_at = table.Column(type: "timestamp with time zone", nullable: false), updated_at = table.Column(type: "timestamp with time zone", nullable: false), @@ -132,9 +131,9 @@ namespace DysonNetwork.Sphere.Migrations bio = table.Column(type: "character varying(4096)", maxLength: 4096, nullable: true), picture_id = table.Column(type: "character varying(32)", maxLength: 32, nullable: true), background_id = table.Column(type: "character varying(32)", maxLength: 32, nullable: true), - picture = table.Column(type: "jsonb", nullable: true), - background = table.Column(type: "jsonb", nullable: true), - verification = table.Column(type: "jsonb", nullable: true), + picture = table.Column(type: "jsonb", nullable: true), + background = table.Column(type: "jsonb", nullable: true), + verification = table.Column(type: "jsonb", nullable: true), account_id = table.Column(type: "uuid", nullable: true), realm_id = table.Column(type: "uuid", nullable: true), created_at = table.Column(type: "timestamp with time zone", nullable: false), @@ -244,9 +243,9 @@ namespace DysonNetwork.Sphere.Migrations name = table.Column(type: "character varying(1024)", maxLength: 1024, nullable: false), description = table.Column(type: "character varying(4096)", maxLength: 4096, nullable: true), status = table.Column(type: "integer", nullable: false), - picture = table.Column(type: "jsonb", nullable: true), - background = table.Column(type: "jsonb", nullable: true), - verification = table.Column(type: "jsonb", nullable: true), + picture = table.Column(type: "jsonb", nullable: true), + background = table.Column(type: "jsonb", nullable: true), + verification = table.Column(type: "jsonb", nullable: true), publisher_id = table.Column(type: "uuid", nullable: false), created_at = table.Column(type: "timestamp with time zone", nullable: false), updated_at = table.Column(type: "timestamp with time zone", nullable: false), @@ -308,7 +307,7 @@ namespace DysonNetwork.Sphere.Migrations downvotes = table.Column(type: "integer", nullable: false), replied_post_id = table.Column(type: "uuid", nullable: true), forwarded_post_id = table.Column(type: "uuid", nullable: true), - attachments = table.Column>(type: "jsonb", nullable: false), + attachments = table.Column>(type: "jsonb", nullable: false), search_vector = table.Column(type: "tsvector", nullable: false) .Annotation("Npgsql:TsVectorConfig", "simple") .Annotation("Npgsql:TsVectorProperties", new[] { "title", "description", "content" }), @@ -471,7 +470,7 @@ namespace DysonNetwork.Sphere.Migrations members_mentioned = table.Column>(type: "jsonb", nullable: true), nonce = table.Column(type: "character varying(36)", maxLength: 36, nullable: false), edited_at = table.Column(type: "timestamp with time zone", nullable: true), - attachments = table.Column>(type: "jsonb", nullable: false), + attachments = table.Column>(type: "jsonb", nullable: false), replied_message_id = table.Column(type: "uuid", nullable: true), forwarded_message_id = table.Column(type: "uuid", nullable: true), sender_id = table.Column(type: "uuid", nullable: false), @@ -669,7 +668,7 @@ namespace DysonNetwork.Sphere.Migrations id = table.Column(type: "uuid", nullable: false), slug = table.Column(type: "character varying(128)", maxLength: 128, nullable: false), image_id = table.Column(type: "character varying(32)", maxLength: 32, nullable: true), - image = table.Column(type: "jsonb", nullable: true), + image = table.Column(type: "jsonb", nullable: true), pack_id = table.Column(type: "uuid", nullable: false), created_at = table.Column(type: "timestamp with time zone", nullable: false), updated_at = table.Column(type: "timestamp with time zone", nullable: false), diff --git a/DysonNetwork.Sphere/Migrations/20250731065135_AddCheckInBackdated.Designer.cs b/DysonNetwork.Sphere/Migrations/20250731065135_AddCheckInBackdated.Designer.cs index a8ff363..872332f 100644 --- a/DysonNetwork.Sphere/Migrations/20250731065135_AddCheckInBackdated.Designer.cs +++ b/DysonNetwork.Sphere/Migrations/20250731065135_AddCheckInBackdated.Designer.cs @@ -1,9 +1,8 @@ // using System; using System.Collections.Generic; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using DysonNetwork.Sphere; -using DysonNetwork.Sphere.Chat; using DysonNetwork.Sphere.WebReader; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; @@ -116,7 +115,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -151,7 +150,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(1024)") .HasColumnName("name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -188,7 +187,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property>("Attachments") + b.Property>("Attachments") .IsRequired() .HasColumnType("jsonb") .HasColumnName("attachments"); @@ -379,7 +378,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -402,7 +401,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(1024)") .HasColumnName("name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -424,7 +423,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); @@ -499,7 +498,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property>("Attachments") + b.Property>("Attachments") .IsRequired() .HasColumnType("jsonb") .HasColumnName("attachments"); @@ -792,7 +791,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("account_id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -826,7 +825,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(256)") .HasColumnName("nick"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -847,7 +846,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); @@ -997,7 +996,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("account_id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -1034,7 +1033,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(1024)") .HasColumnName("name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -1053,7 +1052,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); @@ -1184,7 +1183,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("deleted_at"); - b.Property("Image") + b.Property("Image") .HasColumnType("jsonb") .HasColumnName("image"); diff --git a/DysonNetwork.Sphere/Migrations/20250802095248_AddPoll.Designer.cs b/DysonNetwork.Sphere/Migrations/20250802095248_AddPoll.Designer.cs index e5748f5..6259820 100644 --- a/DysonNetwork.Sphere/Migrations/20250802095248_AddPoll.Designer.cs +++ b/DysonNetwork.Sphere/Migrations/20250802095248_AddPoll.Designer.cs @@ -2,10 +2,8 @@ using System; using System.Collections.Generic; using System.Text.Json; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using DysonNetwork.Sphere; -using DysonNetwork.Sphere.Chat; -using DysonNetwork.Sphere.Poll; using DysonNetwork.Sphere.WebReader; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; @@ -118,7 +116,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -153,7 +151,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(1024)") .HasColumnName("name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -190,7 +188,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property>("Attachments") + b.Property>("Attachments") .IsRequired() .HasColumnType("jsonb") .HasColumnName("attachments"); @@ -381,7 +379,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -404,7 +402,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(1024)") .HasColumnName("name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -426,7 +424,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); @@ -605,7 +603,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("boolean") .HasColumnName("is_required"); - b.Property>("Options") + b.Property>("Options") .HasColumnType("jsonb") .HasColumnName("options"); @@ -647,7 +645,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property>("Attachments") + b.Property>("Attachments") .IsRequired() .HasColumnType("jsonb") .HasColumnName("attachments"); @@ -940,7 +938,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("account_id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -974,7 +972,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(256)") .HasColumnName("nick"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -995,7 +993,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); @@ -1145,7 +1143,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("account_id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -1182,7 +1180,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(1024)") .HasColumnName("name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -1201,7 +1199,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); @@ -1332,7 +1330,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("deleted_at"); - b.Property("Image") + b.Property("Image") .HasColumnType("jsonb") .HasColumnName("image"); diff --git a/DysonNetwork.Sphere/Migrations/20250802095248_AddPoll.cs b/DysonNetwork.Sphere/Migrations/20250802095248_AddPoll.cs index b1b454f..3c3e997 100644 --- a/DysonNetwork.Sphere/Migrations/20250802095248_AddPoll.cs +++ b/DysonNetwork.Sphere/Migrations/20250802095248_AddPoll.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; using System.Text.Json; -using DysonNetwork.Sphere.Poll; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore.Migrations; using NodaTime; @@ -68,7 +68,7 @@ namespace DysonNetwork.Sphere.Migrations { id = table.Column(type: "uuid", nullable: false), type = table.Column(type: "integer", nullable: false), - options = table.Column>(type: "jsonb", nullable: true), + options = table.Column>(type: "jsonb", nullable: true), title = table.Column(type: "character varying(1024)", maxLength: 1024, nullable: false), description = table.Column(type: "character varying(4096)", maxLength: 4096, nullable: true), order = table.Column(type: "integer", nullable: false), diff --git a/DysonNetwork.Sphere/Migrations/20250805183629_AddStickerOwnerships.Designer.cs b/DysonNetwork.Sphere/Migrations/20250805183629_AddStickerOwnerships.Designer.cs index b80197e..da15722 100644 --- a/DysonNetwork.Sphere/Migrations/20250805183629_AddStickerOwnerships.Designer.cs +++ b/DysonNetwork.Sphere/Migrations/20250805183629_AddStickerOwnerships.Designer.cs @@ -2,10 +2,8 @@ using System; using System.Collections.Generic; using System.Text.Json; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using DysonNetwork.Sphere; -using DysonNetwork.Sphere.Chat; -using DysonNetwork.Sphere.Poll; using DysonNetwork.Sphere.WebReader; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; @@ -118,7 +116,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -153,7 +151,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(1024)") .HasColumnName("name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -190,7 +188,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property>("Attachments") + b.Property>("Attachments") .IsRequired() .HasColumnType("jsonb") .HasColumnName("attachments"); @@ -381,7 +379,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -404,7 +402,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(1024)") .HasColumnName("name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -426,7 +424,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); @@ -605,7 +603,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("boolean") .HasColumnName("is_required"); - b.Property>("Options") + b.Property>("Options") .HasColumnType("jsonb") .HasColumnName("options"); @@ -647,7 +645,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property>("Attachments") + b.Property>("Attachments") .IsRequired() .HasColumnType("jsonb") .HasColumnName("attachments"); @@ -940,7 +938,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("account_id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -974,7 +972,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(256)") .HasColumnName("nick"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -995,7 +993,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); @@ -1145,7 +1143,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("account_id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -1182,7 +1180,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(1024)") .HasColumnName("name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -1201,7 +1199,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); @@ -1332,7 +1330,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("deleted_at"); - b.Property("Image") + b.Property("Image") .HasColumnType("jsonb") .HasColumnName("image"); diff --git a/DysonNetwork.Sphere/Migrations/20250807162646_RemoveDevelopers.Designer.cs b/DysonNetwork.Sphere/Migrations/20250807162646_RemoveDevelopers.Designer.cs index b676dc0..ce70ac6 100644 --- a/DysonNetwork.Sphere/Migrations/20250807162646_RemoveDevelopers.Designer.cs +++ b/DysonNetwork.Sphere/Migrations/20250807162646_RemoveDevelopers.Designer.cs @@ -2,10 +2,8 @@ using System; using System.Collections.Generic; using System.Text.Json; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using DysonNetwork.Sphere; -using DysonNetwork.Sphere.Chat; -using DysonNetwork.Sphere.Poll; using DysonNetwork.Sphere.WebReader; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; @@ -118,7 +116,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -153,7 +151,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(1024)") .HasColumnName("name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -190,7 +188,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property>("Attachments") + b.Property>("Attachments") .IsRequired() .HasColumnType("jsonb") .HasColumnName("attachments"); @@ -485,7 +483,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("boolean") .HasColumnName("is_required"); - b.Property>("Options") + b.Property>("Options") .HasColumnType("jsonb") .HasColumnName("options"); @@ -527,7 +525,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property>("Attachments") + b.Property>("Attachments") .IsRequired() .HasColumnType("jsonb") .HasColumnName("attachments"); @@ -820,7 +818,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("account_id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -854,7 +852,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(256)") .HasColumnName("nick"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -875,7 +873,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); @@ -1025,7 +1023,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("account_id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -1062,7 +1060,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(1024)") .HasColumnName("name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -1081,7 +1079,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); @@ -1150,7 +1148,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("deleted_at"); - b.Property("Image") + b.Property("Image") .HasColumnType("jsonb") .HasColumnName("image"); diff --git a/DysonNetwork.Sphere/Migrations/20250807162646_RemoveDevelopers.cs b/DysonNetwork.Sphere/Migrations/20250807162646_RemoveDevelopers.cs index eb5679a..f855427 100644 --- a/DysonNetwork.Sphere/Migrations/20250807162646_RemoveDevelopers.cs +++ b/DysonNetwork.Sphere/Migrations/20250807162646_RemoveDevelopers.cs @@ -1,5 +1,5 @@ using System; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore.Migrations; using NodaTime; @@ -35,16 +35,16 @@ namespace DysonNetwork.Sphere.Migrations { id = table.Column(type: "uuid", nullable: false), publisher_id = table.Column(type: "uuid", nullable: false), - background = table.Column(type: "jsonb", nullable: true), + background = table.Column(type: "jsonb", nullable: true), created_at = table.Column(type: "timestamp with time zone", nullable: false), deleted_at = table.Column(type: "timestamp with time zone", nullable: true), description = table.Column(type: "character varying(4096)", maxLength: 4096, nullable: true), name = table.Column(type: "character varying(1024)", maxLength: 1024, nullable: false), - picture = table.Column(type: "jsonb", nullable: true), + picture = table.Column(type: "jsonb", nullable: true), slug = table.Column(type: "character varying(1024)", maxLength: 1024, nullable: false), status = table.Column(type: "integer", nullable: false), updated_at = table.Column(type: "timestamp with time zone", nullable: false), - verification = table.Column(type: "jsonb", nullable: true) + verification = table.Column(type: "jsonb", nullable: true) }, constraints: table => { diff --git a/DysonNetwork.Sphere/Migrations/20250812041519_AddPostFeaturedRecord.Designer.cs b/DysonNetwork.Sphere/Migrations/20250812041519_AddPostFeaturedRecord.Designer.cs index dec33e7..47ab6cf 100644 --- a/DysonNetwork.Sphere/Migrations/20250812041519_AddPostFeaturedRecord.Designer.cs +++ b/DysonNetwork.Sphere/Migrations/20250812041519_AddPostFeaturedRecord.Designer.cs @@ -2,10 +2,8 @@ using System; using System.Collections.Generic; using System.Text.Json; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using DysonNetwork.Sphere; -using DysonNetwork.Sphere.Chat; -using DysonNetwork.Sphere.Poll; using DysonNetwork.Sphere.WebReader; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; @@ -118,7 +116,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -153,7 +151,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(1024)") .HasColumnName("name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -190,7 +188,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property>("Attachments") + b.Property>("Attachments") .IsRequired() .HasColumnType("jsonb") .HasColumnName("attachments"); @@ -485,7 +483,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("boolean") .HasColumnName("is_required"); - b.Property>("Options") + b.Property>("Options") .HasColumnType("jsonb") .HasColumnName("options"); @@ -527,7 +525,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property>("Attachments") + b.Property>("Attachments") .IsRequired() .HasColumnType("jsonb") .HasColumnName("attachments"); @@ -860,7 +858,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("account_id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -894,7 +892,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(256)") .HasColumnName("nick"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -915,7 +913,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); @@ -1065,7 +1063,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("account_id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -1102,7 +1100,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(1024)") .HasColumnName("name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -1121,7 +1119,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); @@ -1190,7 +1188,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("deleted_at"); - b.Property("Image") + b.Property("Image") .HasColumnType("jsonb") .HasColumnName("image"); diff --git a/DysonNetwork.Sphere/Migrations/20250814183405_AddRealmPost.Designer.cs b/DysonNetwork.Sphere/Migrations/20250814183405_AddRealmPost.Designer.cs index 64233c2..b22d059 100644 --- a/DysonNetwork.Sphere/Migrations/20250814183405_AddRealmPost.Designer.cs +++ b/DysonNetwork.Sphere/Migrations/20250814183405_AddRealmPost.Designer.cs @@ -2,10 +2,8 @@ using System; using System.Collections.Generic; using System.Text.Json; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using DysonNetwork.Sphere; -using DysonNetwork.Sphere.Chat; -using DysonNetwork.Sphere.Poll; using DysonNetwork.Sphere.WebReader; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; @@ -118,7 +116,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -153,7 +151,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(1024)") .HasColumnName("name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -190,7 +188,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property>("Attachments") + b.Property>("Attachments") .IsRequired() .HasColumnType("jsonb") .HasColumnName("attachments"); @@ -485,7 +483,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("boolean") .HasColumnName("is_required"); - b.Property>("Options") + b.Property>("Options") .HasColumnType("jsonb") .HasColumnName("options"); @@ -527,7 +525,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property>("Attachments") + b.Property>("Attachments") .IsRequired() .HasColumnType("jsonb") .HasColumnName("attachments"); @@ -867,7 +865,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("account_id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -901,7 +899,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(256)") .HasColumnName("nick"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -922,7 +920,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); @@ -1072,7 +1070,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("account_id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -1109,7 +1107,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(1024)") .HasColumnName("name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -1128,7 +1126,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); @@ -1197,7 +1195,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("deleted_at"); - b.Property("Image") + b.Property("Image") .HasColumnType("jsonb") .HasColumnName("image"); diff --git a/DysonNetwork.Sphere/Migrations/20250815041220_AddPostSlug.Designer.cs b/DysonNetwork.Sphere/Migrations/20250815041220_AddPostSlug.Designer.cs index 622f952..44f364e 100644 --- a/DysonNetwork.Sphere/Migrations/20250815041220_AddPostSlug.Designer.cs +++ b/DysonNetwork.Sphere/Migrations/20250815041220_AddPostSlug.Designer.cs @@ -2,10 +2,8 @@ using System; using System.Collections.Generic; using System.Text.Json; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using DysonNetwork.Sphere; -using DysonNetwork.Sphere.Chat; -using DysonNetwork.Sphere.Poll; using DysonNetwork.Sphere.WebReader; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; @@ -118,7 +116,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -153,7 +151,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(1024)") .HasColumnName("name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -190,7 +188,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property>("Attachments") + b.Property>("Attachments") .IsRequired() .HasColumnType("jsonb") .HasColumnName("attachments"); @@ -485,7 +483,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("boolean") .HasColumnName("is_required"); - b.Property>("Options") + b.Property>("Options") .HasColumnType("jsonb") .HasColumnName("options"); @@ -527,7 +525,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property>("Attachments") + b.Property>("Attachments") .IsRequired() .HasColumnType("jsonb") .HasColumnName("attachments"); @@ -867,7 +865,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("account_id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -901,7 +899,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(256)") .HasColumnName("nick"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -922,7 +920,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); @@ -1072,7 +1070,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("account_id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -1109,7 +1107,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(1024)") .HasColumnName("name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -1128,7 +1126,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); @@ -1197,7 +1195,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("deleted_at"); - b.Property("Image") + b.Property("Image") .HasColumnType("jsonb") .HasColumnName("image"); diff --git a/DysonNetwork.Sphere/Migrations/20250819175925_AddPostParentGone.Designer.cs b/DysonNetwork.Sphere/Migrations/20250819175925_AddPostParentGone.Designer.cs index 4fbc835..24ade42 100644 --- a/DysonNetwork.Sphere/Migrations/20250819175925_AddPostParentGone.Designer.cs +++ b/DysonNetwork.Sphere/Migrations/20250819175925_AddPostParentGone.Designer.cs @@ -2,10 +2,8 @@ using System; using System.Collections.Generic; using System.Text.Json; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using DysonNetwork.Sphere; -using DysonNetwork.Sphere.Chat; -using DysonNetwork.Sphere.Poll; using DysonNetwork.Sphere.WebReader; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; @@ -118,7 +116,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -153,7 +151,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(1024)") .HasColumnName("name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -190,7 +188,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property>("Attachments") + b.Property>("Attachments") .IsRequired() .HasColumnType("jsonb") .HasColumnName("attachments"); @@ -485,7 +483,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("boolean") .HasColumnName("is_required"); - b.Property>("Options") + b.Property>("Options") .HasColumnType("jsonb") .HasColumnName("options"); @@ -527,7 +525,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property>("Attachments") + b.Property>("Attachments") .IsRequired() .HasColumnType("jsonb") .HasColumnName("attachments"); @@ -875,7 +873,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("account_id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -909,7 +907,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(256)") .HasColumnName("nick"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -930,7 +928,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); @@ -1080,7 +1078,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("account_id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -1117,7 +1115,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(1024)") .HasColumnName("name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -1136,7 +1134,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); @@ -1205,7 +1203,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("deleted_at"); - b.Property("Image") + b.Property("Image") .HasColumnType("jsonb") .HasColumnName("image"); diff --git a/DysonNetwork.Sphere/Migrations/20250820060654_AddWebFeedSubscription.Designer.cs b/DysonNetwork.Sphere/Migrations/20250820060654_AddWebFeedSubscription.Designer.cs index 7031acd..0f6ede2 100644 --- a/DysonNetwork.Sphere/Migrations/20250820060654_AddWebFeedSubscription.Designer.cs +++ b/DysonNetwork.Sphere/Migrations/20250820060654_AddWebFeedSubscription.Designer.cs @@ -2,10 +2,8 @@ using System; using System.Collections.Generic; using System.Text.Json; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using DysonNetwork.Sphere; -using DysonNetwork.Sphere.Chat; -using DysonNetwork.Sphere.Poll; using DysonNetwork.Sphere.WebReader; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; @@ -118,7 +116,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -153,7 +151,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(1024)") .HasColumnName("name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -190,7 +188,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property>("Attachments") + b.Property>("Attachments") .IsRequired() .HasColumnType("jsonb") .HasColumnName("attachments"); @@ -485,7 +483,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("boolean") .HasColumnName("is_required"); - b.Property>("Options") + b.Property>("Options") .HasColumnType("jsonb") .HasColumnName("options"); @@ -527,7 +525,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property>("Attachments") + b.Property>("Attachments") .IsRequired() .HasColumnType("jsonb") .HasColumnName("attachments"); @@ -875,7 +873,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("account_id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -909,7 +907,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(256)") .HasColumnName("nick"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -930,7 +928,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); @@ -1080,7 +1078,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("account_id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -1117,7 +1115,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(1024)") .HasColumnName("name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -1136,7 +1134,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); @@ -1205,7 +1203,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("deleted_at"); - b.Property("Image") + b.Property("Image") .HasColumnType("jsonb") .HasColumnName("image"); diff --git a/DysonNetwork.Sphere/Migrations/20250825045548_AddPostPin.Designer.cs b/DysonNetwork.Sphere/Migrations/20250825045548_AddPostPin.Designer.cs index 93116b7..ba3e9e0 100644 --- a/DysonNetwork.Sphere/Migrations/20250825045548_AddPostPin.Designer.cs +++ b/DysonNetwork.Sphere/Migrations/20250825045548_AddPostPin.Designer.cs @@ -2,10 +2,8 @@ using System; using System.Collections.Generic; using System.Text.Json; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using DysonNetwork.Sphere; -using DysonNetwork.Sphere.Chat; -using DysonNetwork.Sphere.Poll; using DysonNetwork.Sphere.WebReader; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; @@ -118,7 +116,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -153,7 +151,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(1024)") .HasColumnName("name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -190,7 +188,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property>("Attachments") + b.Property>("Attachments") .IsRequired() .HasColumnType("jsonb") .HasColumnName("attachments"); @@ -485,7 +483,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("boolean") .HasColumnName("is_required"); - b.Property>("Options") + b.Property>("Options") .HasColumnType("jsonb") .HasColumnName("options"); @@ -527,7 +525,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property>("Attachments") + b.Property>("Attachments") .IsRequired() .HasColumnType("jsonb") .HasColumnName("attachments"); @@ -879,7 +877,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("account_id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -913,7 +911,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(256)") .HasColumnName("nick"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -934,7 +932,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); @@ -1084,7 +1082,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("account_id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -1121,7 +1119,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(1024)") .HasColumnName("name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -1140,7 +1138,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); @@ -1209,7 +1207,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("deleted_at"); - b.Property("Image") + b.Property("Image") .HasColumnType("jsonb") .HasColumnName("image"); diff --git a/DysonNetwork.Sphere/Migrations/20250825054901_AddPostCategoryTagSubscription.Designer.cs b/DysonNetwork.Sphere/Migrations/20250825054901_AddPostCategoryTagSubscription.Designer.cs index 8426a52..3b59048 100644 --- a/DysonNetwork.Sphere/Migrations/20250825054901_AddPostCategoryTagSubscription.Designer.cs +++ b/DysonNetwork.Sphere/Migrations/20250825054901_AddPostCategoryTagSubscription.Designer.cs @@ -2,10 +2,8 @@ using System; using System.Collections.Generic; using System.Text.Json; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using DysonNetwork.Sphere; -using DysonNetwork.Sphere.Chat; -using DysonNetwork.Sphere.Poll; using DysonNetwork.Sphere.WebReader; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; @@ -118,7 +116,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -153,7 +151,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(1024)") .HasColumnName("name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -190,7 +188,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property>("Attachments") + b.Property>("Attachments") .IsRequired() .HasColumnType("jsonb") .HasColumnName("attachments"); @@ -485,7 +483,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("boolean") .HasColumnName("is_required"); - b.Property>("Options") + b.Property>("Options") .HasColumnType("jsonb") .HasColumnName("options"); @@ -527,7 +525,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property>("Attachments") + b.Property>("Attachments") .IsRequired() .HasColumnType("jsonb") .HasColumnName("attachments"); @@ -922,7 +920,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("account_id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -956,7 +954,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(256)") .HasColumnName("nick"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -977,7 +975,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); @@ -1127,7 +1125,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("account_id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -1164,7 +1162,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(1024)") .HasColumnName("name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -1183,7 +1181,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); @@ -1252,7 +1250,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("deleted_at"); - b.Property("Image") + b.Property("Image") .HasColumnType("jsonb") .HasColumnName("image"); diff --git a/DysonNetwork.Sphere/Migrations/20250904162157_AddPostAwardScore.Designer.cs b/DysonNetwork.Sphere/Migrations/20250904162157_AddPostAwardScore.Designer.cs index 1934f27..d82928e 100644 --- a/DysonNetwork.Sphere/Migrations/20250904162157_AddPostAwardScore.Designer.cs +++ b/DysonNetwork.Sphere/Migrations/20250904162157_AddPostAwardScore.Designer.cs @@ -2,10 +2,8 @@ using System; using System.Collections.Generic; using System.Text.Json; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using DysonNetwork.Sphere; -using DysonNetwork.Sphere.Chat; -using DysonNetwork.Sphere.Poll; using DysonNetwork.Sphere.WebReader; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; @@ -118,7 +116,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -153,7 +151,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(1024)") .HasColumnName("name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -190,7 +188,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property>("Attachments") + b.Property>("Attachments") .IsRequired() .HasColumnType("jsonb") .HasColumnName("attachments"); @@ -485,7 +483,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("boolean") .HasColumnName("is_required"); - b.Property>("Options") + b.Property>("Options") .HasColumnType("jsonb") .HasColumnName("options"); @@ -527,7 +525,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property>("Attachments") + b.Property>("Attachments") .IsRequired() .HasColumnType("jsonb") .HasColumnName("attachments"); @@ -975,7 +973,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("account_id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -1009,7 +1007,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(256)") .HasColumnName("nick"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -1030,7 +1028,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); @@ -1180,7 +1178,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("account_id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -1217,7 +1215,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(1024)") .HasColumnName("name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -1236,7 +1234,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); @@ -1305,7 +1303,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("deleted_at"); - b.Property("Image") + b.Property("Image") .HasColumnType("jsonb") .HasColumnName("image"); diff --git a/DysonNetwork.Sphere/Migrations/20250907070000_RemoveNetTopo.Designer.cs b/DysonNetwork.Sphere/Migrations/20250907070000_RemoveNetTopo.Designer.cs index c943397..8cfa241 100644 --- a/DysonNetwork.Sphere/Migrations/20250907070000_RemoveNetTopo.Designer.cs +++ b/DysonNetwork.Sphere/Migrations/20250907070000_RemoveNetTopo.Designer.cs @@ -2,10 +2,8 @@ using System; using System.Collections.Generic; using System.Text.Json; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using DysonNetwork.Sphere; -using DysonNetwork.Sphere.Chat; -using DysonNetwork.Sphere.Poll; using DysonNetwork.Sphere.WebReader; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; @@ -117,7 +115,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -152,7 +150,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(1024)") .HasColumnName("name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -189,7 +187,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property>("Attachments") + b.Property>("Attachments") .IsRequired() .HasColumnType("jsonb") .HasColumnName("attachments"); @@ -484,7 +482,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("boolean") .HasColumnName("is_required"); - b.Property>("Options") + b.Property>("Options") .HasColumnType("jsonb") .HasColumnName("options"); @@ -526,7 +524,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property>("Attachments") + b.Property>("Attachments") .IsRequired() .HasColumnType("jsonb") .HasColumnName("attachments"); @@ -974,7 +972,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("account_id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -1008,7 +1006,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(256)") .HasColumnName("nick"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -1029,7 +1027,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); @@ -1179,7 +1177,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("account_id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -1216,7 +1214,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(1024)") .HasColumnName("name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -1235,7 +1233,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); @@ -1304,7 +1302,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("deleted_at"); - b.Property("Image") + b.Property("Image") .HasColumnType("jsonb") .HasColumnName("image"); diff --git a/DysonNetwork.Sphere/Migrations/20250907142032_AddPostEmbedView.Designer.cs b/DysonNetwork.Sphere/Migrations/20250907142032_AddPostEmbedView.Designer.cs index bb57852..c7c8591 100644 --- a/DysonNetwork.Sphere/Migrations/20250907142032_AddPostEmbedView.Designer.cs +++ b/DysonNetwork.Sphere/Migrations/20250907142032_AddPostEmbedView.Designer.cs @@ -2,11 +2,8 @@ using System; using System.Collections.Generic; using System.Text.Json; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using DysonNetwork.Sphere; -using DysonNetwork.Sphere.Chat; -using DysonNetwork.Sphere.Poll; -using DysonNetwork.Sphere.Post; using DysonNetwork.Sphere.WebReader; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; @@ -118,7 +115,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -153,7 +150,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(1024)") .HasColumnName("name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -190,7 +187,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property>("Attachments") + b.Property>("Attachments") .IsRequired() .HasColumnType("jsonb") .HasColumnName("attachments"); @@ -485,7 +482,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("boolean") .HasColumnName("is_required"); - b.Property>("Options") + b.Property>("Options") .HasColumnType("jsonb") .HasColumnName("options"); @@ -527,7 +524,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property>("Attachments") + b.Property>("Attachments") .IsRequired() .HasColumnType("jsonb") .HasColumnName("attachments"); @@ -979,7 +976,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("account_id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -1013,7 +1010,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(256)") .HasColumnName("nick"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -1034,7 +1031,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); @@ -1184,7 +1181,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("account_id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -1221,7 +1218,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(1024)") .HasColumnName("name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -1240,7 +1237,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); @@ -1309,7 +1306,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("deleted_at"); - b.Property("Image") + b.Property("Image") .HasColumnType("jsonb") .HasColumnName("image"); diff --git a/DysonNetwork.Sphere/Migrations/20250907142032_AddPostEmbedView.cs b/DysonNetwork.Sphere/Migrations/20250907142032_AddPostEmbedView.cs index 98aaa90..03e7f58 100644 --- a/DysonNetwork.Sphere/Migrations/20250907142032_AddPostEmbedView.cs +++ b/DysonNetwork.Sphere/Migrations/20250907142032_AddPostEmbedView.cs @@ -1,4 +1,4 @@ -using DysonNetwork.Sphere.Post; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable diff --git a/DysonNetwork.Sphere/Migrations/20250907150520_AddPollAnonymousOrNot.Designer.cs b/DysonNetwork.Sphere/Migrations/20250907150520_AddPollAnonymousOrNot.Designer.cs index be4bf27..e19df8b 100644 --- a/DysonNetwork.Sphere/Migrations/20250907150520_AddPollAnonymousOrNot.Designer.cs +++ b/DysonNetwork.Sphere/Migrations/20250907150520_AddPollAnonymousOrNot.Designer.cs @@ -2,11 +2,8 @@ using System; using System.Collections.Generic; using System.Text.Json; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using DysonNetwork.Sphere; -using DysonNetwork.Sphere.Chat; -using DysonNetwork.Sphere.Poll; -using DysonNetwork.Sphere.Post; using DysonNetwork.Sphere.WebReader; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; @@ -118,7 +115,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -153,7 +150,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(1024)") .HasColumnName("name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -190,7 +187,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property>("Attachments") + b.Property>("Attachments") .IsRequired() .HasColumnType("jsonb") .HasColumnName("attachments"); @@ -489,7 +486,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("boolean") .HasColumnName("is_required"); - b.Property>("Options") + b.Property>("Options") .HasColumnType("jsonb") .HasColumnName("options"); @@ -531,7 +528,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property>("Attachments") + b.Property>("Attachments") .IsRequired() .HasColumnType("jsonb") .HasColumnName("attachments"); @@ -983,7 +980,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("account_id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -1017,7 +1014,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(256)") .HasColumnName("nick"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -1038,7 +1035,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); @@ -1188,7 +1185,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("account_id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -1225,7 +1222,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(1024)") .HasColumnName("name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -1244,7 +1241,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); @@ -1313,7 +1310,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("deleted_at"); - b.Property("Image") + b.Property("Image") .HasColumnType("jsonb") .HasColumnName("image"); diff --git a/DysonNetwork.Sphere/Migrations/AppDatabaseModelSnapshot.cs b/DysonNetwork.Sphere/Migrations/AppDatabaseModelSnapshot.cs index ee707f3..a5d3a1a 100644 --- a/DysonNetwork.Sphere/Migrations/AppDatabaseModelSnapshot.cs +++ b/DysonNetwork.Sphere/Migrations/AppDatabaseModelSnapshot.cs @@ -2,11 +2,8 @@ using System; using System.Collections.Generic; using System.Text.Json; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using DysonNetwork.Sphere; -using DysonNetwork.Sphere.Chat; -using DysonNetwork.Sphere.Poll; -using DysonNetwork.Sphere.Post; using DysonNetwork.Sphere.WebReader; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; @@ -115,7 +112,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -150,7 +147,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(1024)") .HasColumnName("name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -187,7 +184,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property>("Attachments") + b.Property>("Attachments") .IsRequired() .HasColumnType("jsonb") .HasColumnName("attachments"); @@ -486,7 +483,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("boolean") .HasColumnName("is_required"); - b.Property>("Options") + b.Property>("Options") .HasColumnType("jsonb") .HasColumnName("options"); @@ -528,7 +525,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("id"); - b.Property>("Attachments") + b.Property>("Attachments") .IsRequired() .HasColumnType("jsonb") .HasColumnName("attachments"); @@ -980,7 +977,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("account_id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -1014,7 +1011,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(256)") .HasColumnName("nick"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -1035,7 +1032,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); @@ -1185,7 +1182,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("uuid") .HasColumnName("account_id"); - b.Property("Background") + b.Property("Background") .HasColumnType("jsonb") .HasColumnName("background"); @@ -1222,7 +1219,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("character varying(1024)") .HasColumnName("name"); - b.Property("Picture") + b.Property("Picture") .HasColumnType("jsonb") .HasColumnName("picture"); @@ -1241,7 +1238,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("updated_at"); - b.Property("Verification") + b.Property("Verification") .HasColumnType("jsonb") .HasColumnName("verification"); @@ -1310,7 +1307,7 @@ namespace DysonNetwork.Sphere.Migrations .HasColumnType("timestamp with time zone") .HasColumnName("deleted_at"); - b.Property("Image") + b.Property("Image") .HasColumnType("jsonb") .HasColumnName("image"); diff --git a/DysonNetwork.Sphere/Poll/PollController.cs b/DysonNetwork.Sphere/Poll/PollController.cs index e56e2ce..d11dfec 100644 --- a/DysonNetwork.Sphere/Poll/PollController.cs +++ b/DysonNetwork.Sphere/Poll/PollController.cs @@ -1,6 +1,7 @@ using System.ComponentModel.DataAnnotations; using System.Text.Json; using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using DysonNetwork.Shared.Proto; using DysonNetwork.Shared.Registry; using Microsoft.AspNetCore.Authorization; @@ -46,7 +47,7 @@ public class PollController( [HttpPost("{id:guid}/answer")] [Authorize] - public async Task> AnswerPoll(Guid id, [FromBody] PollAnswerRequest request) + public async Task> AnswerPoll(Guid id, [FromBody] PollAnswerRequest request) { if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized(); var accountId = Guid.Parse(currentUser.Id); @@ -78,7 +79,7 @@ public class PollController( } [HttpGet("{id:guid}/feedback")] - public async Task>> GetPollFeedback( + public async Task>> GetPollFeedback( Guid id, [FromQuery] int offset = 0, [FromQuery] int take = 20 @@ -91,7 +92,7 @@ public class PollController( .FirstOrDefaultAsync(p => p.Id == id); if (poll is null) return NotFound("Poll not found"); - if (!await pub.IsMemberWithRole(poll.PublisherId, accountId, Publisher.PublisherMemberRole.Viewer)) + if (!await pub.IsMemberWithRole(poll.PublisherId, accountId, Shared.Models.PublisherMemberRole.Viewer)) return StatusCode(403, "You need to be a viewer to view this poll's feedback."); var answerQuery = db.PollAnswers @@ -117,7 +118,7 @@ public class PollController( { var protoValue = answeredAccounts.FirstOrDefault(a => a.Id == answer.AccountId.ToString()); if (protoValue is not null) - answer.Account = AccountReference.FromProtoValue(protoValue); + answer.Account = SnAccount.FromProtoValue(protoValue); } } @@ -177,14 +178,14 @@ public class PollController( public Guid Id { get; set; } = Guid.NewGuid(); public PollQuestionType Type { get; set; } - public List? Options { get; set; } + public List? Options { get; set; } [MaxLength(1024)] public string Title { get; set; } = null!; [MaxLength(4096)] public string? Description { get; set; } public int Order { get; set; } = 0; public bool IsRequired { get; set; } - public PollQuestion ToQuestion() => new() + public SnPollQuestion ToQuestion() => new() { Id = Id, Type = Type, @@ -207,7 +208,7 @@ public class PollController( var publisher = await pub.GetPublisherByName(pubName); if (publisher is null) return BadRequest("Publisher was not found."); - if (!await pub.IsMemberWithRole(publisher.Id, accountId, Publisher.PublisherMemberRole.Editor)) + if (!await pub.IsMemberWithRole(publisher.Id, accountId, Shared.Models.PublisherMemberRole.Editor)) return StatusCode(403, "You need at least be an editor to create polls as this publisher."); var poll = new Poll @@ -253,7 +254,7 @@ public class PollController( if (poll == null) return NotFound("Poll not found"); // Check if user is an editor of the publisher that owns the poll - if (!await pub.IsMemberWithRole(poll.PublisherId, accountId, Publisher.PublisherMemberRole.Editor)) + if (!await pub.IsMemberWithRole(poll.PublisherId, accountId, Shared.Models.PublisherMemberRole.Editor)) return StatusCode(403, "You need to be at least an editor to update this poll."); // Update properties if they are provided in the request @@ -317,7 +318,7 @@ public class PollController( if (poll == null) return NotFound("Poll not found"); // Check if user is an editor of the publisher that owns the poll - if (!await pub.IsMemberWithRole(poll.PublisherId, accountId, Publisher.PublisherMemberRole.Editor)) + if (!await pub.IsMemberWithRole(poll.PublisherId, accountId, Shared.Models.PublisherMemberRole.Editor)) return StatusCode(403, "You need to be at least an editor to delete this poll."); // Delete all answers for this poll diff --git a/DysonNetwork.Sphere/Poll/PollEmbed.cs b/DysonNetwork.Sphere/Poll/PollEmbed.cs index f4e025c..8ceb838 100644 --- a/DysonNetwork.Sphere/Poll/PollEmbed.cs +++ b/DysonNetwork.Sphere/Poll/PollEmbed.cs @@ -1,13 +1,14 @@ +using DysonNetwork.Shared.Models; using DysonNetwork.Sphere.WebReader; namespace DysonNetwork.Sphere.Poll; public class PollWithStats : Poll { - public PollAnswer? UserAnswer { get; set; } + public SnPollAnswer? UserAnswer { get; set; } public Dictionary> Stats { get; set; } = new(); // question id -> (option id -> count) - public static PollWithStats FromPoll(Poll poll, PollAnswer? userAnswer = null) + public static PollWithStats FromPoll(Poll poll, SnPollAnswer? userAnswer = null) { return new PollWithStats { diff --git a/DysonNetwork.Sphere/Poll/PollService.cs b/DysonNetwork.Sphere/Poll/PollService.cs index 6437ab1..d852979 100644 --- a/DysonNetwork.Sphere/Poll/PollService.cs +++ b/DysonNetwork.Sphere/Poll/PollService.cs @@ -1,5 +1,6 @@ using System.Text.Json; using DysonNetwork.Shared.Cache; +using DysonNetwork.Shared.Models; using Microsoft.EntityFrameworkCore; using NodaTime; @@ -42,10 +43,10 @@ public class PollService(AppDatabase db, ICacheService cache) private const string PollAnswerCachePrefix = "poll:answer:"; - public async Task GetPollAnswer(Guid pollId, Guid accountId) + public async Task GetPollAnswer(Guid pollId, Guid accountId) { var cacheKey = $"{PollAnswerCachePrefix}{pollId}:{accountId}"; - var cachedAnswer = await cache.GetAsync(cacheKey); + var cachedAnswer = await cache.GetAsync(cacheKey); if (cachedAnswer is not null) return cachedAnswer; @@ -103,7 +104,7 @@ public class PollService(AppDatabase db, ICacheService cache) } } - public async Task AnswerPoll(Guid pollId, Guid accountId, Dictionary answer) + public async Task AnswerPoll(Guid pollId, Guid accountId, Dictionary answer) { // Validation var poll = await db.Polls @@ -124,7 +125,7 @@ public class PollService(AppDatabase db, ICacheService cache) await UnAnswerPoll(pollId, accountId); // Save the new answer - var answerRecord = new PollAnswer + var answerRecord = new SnPollAnswer { PollId = pollId, AccountId = accountId, diff --git a/DysonNetwork.Sphere/Post/PostCategoryController.cs b/DysonNetwork.Sphere/Post/PostCategoryController.cs index 42ef0a9..f254940 100644 --- a/DysonNetwork.Sphere/Post/PostCategoryController.cs +++ b/DysonNetwork.Sphere/Post/PostCategoryController.cs @@ -1,4 +1,5 @@ using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using DysonNetwork.Shared.Proto; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; @@ -11,7 +12,7 @@ namespace DysonNetwork.Sphere.Post; public class PostCategoryController(AppDatabase db) : ControllerBase { [HttpGet("categories")] - public async Task>> ListCategories( + public async Task>> ListCategories( [FromQuery] string? query = null, [FromQuery] int offset = 0, [FromQuery] int take = 20, @@ -59,7 +60,7 @@ public class PostCategoryController(AppDatabase db) : ControllerBase } [HttpGet("tags")] - public async Task>> ListTags( + public async Task>> ListTags( [FromQuery] string? query = null, [FromQuery] int offset = 0, [FromQuery] int take = 20, @@ -107,7 +108,7 @@ public class PostCategoryController(AppDatabase db) : ControllerBase } [HttpGet("categories/{slug}")] - public async Task> GetCategory(string slug) + public async Task> GetCategory(string slug) { var category = await db.PostCategories.FirstOrDefaultAsync(e => e.Slug == slug); if (category is null) @@ -116,7 +117,7 @@ public class PostCategoryController(AppDatabase db) : ControllerBase } [HttpGet("tags/{slug}")] - public async Task> GetTag(string slug) + public async Task> GetTag(string slug) { var tag = await db.PostTags.FirstOrDefaultAsync(e => e.Slug == slug); if (tag is null) @@ -126,7 +127,7 @@ public class PostCategoryController(AppDatabase db) : ControllerBase [HttpPost("categories/{slug}/subscribe")] [Authorize] - public async Task> SubscribeCategory(string slug) + public async Task> SubscribeCategory(string slug) { if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized(); var accountId = Guid.Parse(currentUser.Id); @@ -143,7 +144,7 @@ public class PostCategoryController(AppDatabase db) : ControllerBase if (existingSubscription != null) return Ok(existingSubscription); - var subscription = new PostCategorySubscription + var subscription = new SnPostCategorySubscription { AccountId = accountId, CategoryId = category.Id @@ -180,7 +181,7 @@ public class PostCategoryController(AppDatabase db) : ControllerBase [HttpGet("categories/{slug}/subscription")] [Authorize] - public async Task> GetCategorySubscription(string slug) + public async Task> GetCategorySubscription(string slug) { if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized(); var accountId = Guid.Parse(currentUser.Id); @@ -200,7 +201,7 @@ public class PostCategoryController(AppDatabase db) : ControllerBase [HttpPost("tags/{slug}/subscribe")] [Authorize] - public async Task> SubscribeTag(string slug) + public async Task> SubscribeTag(string slug) { if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized(); var accountId = Guid.Parse(currentUser.Id); @@ -219,7 +220,7 @@ public class PostCategoryController(AppDatabase db) : ControllerBase return Ok(existingSubscription); } - var subscription = new PostCategorySubscription + var subscription = new SnPostCategorySubscription { AccountId = accountId, TagId = tag.Id @@ -260,7 +261,7 @@ public class PostCategoryController(AppDatabase db) : ControllerBase [HttpGet("tags/{slug}/subscription")] [Authorize] - public async Task> GetTagSubscription(string slug) + public async Task> GetTagSubscription(string slug) { if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized(); var accountId = Guid.Parse(currentUser.Id); diff --git a/DysonNetwork.Sphere/Post/PostController.cs b/DysonNetwork.Sphere/Post/PostController.cs index 8ae575e..98ee583 100644 --- a/DysonNetwork.Sphere/Post/PostController.cs +++ b/DysonNetwork.Sphere/Post/PostController.cs @@ -3,6 +3,7 @@ using System.Globalization; using DysonNetwork.Shared.Auth; using DysonNetwork.Shared.Content; using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using DysonNetwork.Shared.Proto; using DysonNetwork.Sphere.Poll; using DysonNetwork.Sphere.Realm; @@ -12,7 +13,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using NodaTime; using Swashbuckle.AspNetCore.Annotations; -using PublisherMemberRole = DysonNetwork.Sphere.Publisher.PublisherMemberRole; +using PublisherMemberRole = DysonNetwork.Shared.Models.PublisherMemberRole; using PublisherService = DysonNetwork.Sphere.Publisher.PublisherService; namespace DysonNetwork.Sphere.Post; @@ -32,7 +33,7 @@ public class PostController( : ControllerBase { [HttpGet("featured")] - public async Task>> ListFeaturedPosts() + public async Task>> ListFeaturedPosts() { HttpContext.Items.TryGetValue("CurrentUser", out var currentUserValue); var currentUser = currentUserValue as Account; @@ -63,7 +64,7 @@ public class PostController( /// /// Returns the list of posts matching the criteria. [HttpGet] - [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(List))] + [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(List))] [ProducesResponseType(StatusCodes.Status400BadRequest)] [SwaggerOperation( Summary = "Retrieves a paginated list of posts", @@ -72,9 +73,9 @@ public class PostController( OperationId = "ListPosts", Tags = ["Posts"] )] - [SwaggerResponse(StatusCodes.Status200OK, "Successfully retrieved the list of posts", typeof(List))] + [SwaggerResponse(StatusCodes.Status200OK, "Successfully retrieved the list of posts", typeof(List))] [SwaggerResponse(StatusCodes.Status400BadRequest, "Invalid request parameters")] - public async Task>> ListPosts( + public async Task>> ListPosts( [FromQuery] int offset = 0, [FromQuery] int take = 20, [FromQuery(Name = "pub")] string? pubName = null, @@ -189,7 +190,7 @@ public class PostController( } [HttpGet("{publisherName}/{slug}")] - public async Task> GetPost(string publisherName, string slug) + public async Task> GetPost(string publisherName, string slug) { HttpContext.Items.TryGetValue("CurrentUser", out var currentUserValue); var currentUser = currentUserValue as Account; @@ -220,7 +221,7 @@ public class PostController( } [HttpGet("{id:guid}")] - public async Task> GetPost(Guid id) + public async Task> GetPost(Guid id) { HttpContext.Items.TryGetValue("CurrentUser", out var currentUserValue); var currentUser = currentUserValue as Account; @@ -251,7 +252,7 @@ public class PostController( } [HttpGet("{id:guid}/reactions")] - public async Task>> GetReactions( + public async Task>> GetReactions( Guid id, [FromQuery] string? symbol = null, [FromQuery] int offset = 0, @@ -275,7 +276,7 @@ public class PostController( } [HttpGet("{id:guid}/replies/featured")] - public async Task> GetFeaturedReply(Guid id) + public async Task> GetFeaturedReply(Guid id) { HttpContext.Items.TryGetValue("CurrentUser", out var currentUserValue); var currentUser = currentUserValue as Account; @@ -306,7 +307,7 @@ public class PostController( } [HttpGet("{id:guid}/replies/pinned")] - public async Task>> ListPinnedReplies(Guid id) + public async Task>> ListPinnedReplies(Guid id) { HttpContext.Items.TryGetValue("CurrentUser", out var currentUserValue); var currentUser = currentUserValue as Account; @@ -332,7 +333,7 @@ public class PostController( } [HttpGet("{id:guid}/replies")] - public async Task>> ListReplies(Guid id, [FromQuery] int offset = 0, + public async Task>> ListReplies(Guid id, [FromQuery] int offset = 0, [FromQuery] int take = 20) { HttpContext.Items.TryGetValue("CurrentUser", out var currentUserValue); @@ -403,7 +404,7 @@ public class PostController( [HttpPost] [RequiredPermission("global", "posts.create")] - public async Task> CreatePost( + public async Task> CreatePost( [FromBody] PostRequest request, [FromQuery(Name = "pub")] string? pubName ) @@ -415,12 +416,12 @@ public class PostController( var accountId = Guid.Parse(currentUser.Id); - Publisher.Publisher? publisher; + Shared.Models.SnPublisher? publisher; if (pubName is null) { // Use the first personal publisher publisher = await db.Publishers.FirstOrDefaultAsync(e => - e.AccountId == accountId && e.Type == Publisher.PublisherType.Individual); + e.AccountId == accountId && e.Type == Shared.Models.PublisherType.Individual); } else { @@ -432,7 +433,7 @@ public class PostController( if (publisher is null) return BadRequest("Publisher was not found."); - var post = new Post + var post = new SnPost { Title = request.Title, Description = request.Description, @@ -525,7 +526,7 @@ public class PostController( [HttpPost("{id:guid}/reactions")] [Authorize] [RequiredPermission("global", "posts.react")] - public async Task> ReactPost(Guid id, [FromBody] PostReactionRequest request) + public async Task> ReactPost(Guid id, [FromBody] PostReactionRequest request) { if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized(); @@ -549,7 +550,7 @@ public class PostController( .AnyAsync(r => r.PostId == post.Id && r.Symbol == request.Symbol && r.AccountId == accountId); - var reaction = new PostReaction + var reaction = new SnPostReaction { Symbol = request.Symbol, Attitude = request.Attitude, @@ -590,7 +591,7 @@ public class PostController( } [HttpGet("{id:guid}/awards")] - public async Task> GetPostAwards(Guid id, [FromQuery] int offset = 0, + public async Task> GetPostAwards(Guid id, [FromQuery] int offset = 0, [FromQuery] int take = 20) { var queryable = db.PostAwards @@ -666,7 +667,7 @@ public class PostController( [HttpPost("{id:guid}/pin")] [Authorize] - public async Task> PinPost(Guid id, [FromBody] PostPinRequest request) + public async Task> PinPost(Guid id, [FromBody] PostPinRequest request) { if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized(); @@ -714,7 +715,7 @@ public class PostController( [HttpDelete("{id:guid}/pin")] [Authorize] - public async Task> UnpinPost(Guid id) + public async Task> UnpinPost(Guid id) { if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized(); @@ -760,7 +761,7 @@ public class PostController( } [HttpPatch("{id:guid}")] - public async Task> UpdatePost( + public async Task> UpdatePost( Guid id, [FromBody] PostRequest request, [FromQuery(Name = "pub")] string? pubName @@ -780,14 +781,14 @@ public class PostController( if (post is null) return NotFound(); var accountId = Guid.Parse(currentUser.Id); - if (!await pub.IsMemberWithRole(post.Publisher.Id, accountId, Publisher.PublisherMemberRole.Editor)) + if (!await pub.IsMemberWithRole(post.Publisher.Id, accountId, PublisherMemberRole.Editor)) return StatusCode(403, "You need at least be an editor to edit this publisher's post."); if (pubName is not null) { var publisher = await pub.GetPublisherByName(pubName); if (publisher is null) return NotFound(); - if (!await pub.IsMemberWithRole(publisher.Id, accountId, Publisher.PublisherMemberRole.Editor)) + if (!await pub.IsMemberWithRole(publisher.Id, accountId, PublisherMemberRole.Editor)) return StatusCode(403, "You need at least be an editor to transfer this post to this publisher."); post.PublisherId = publisher.Id; post.Publisher = publisher; @@ -879,7 +880,7 @@ public class PostController( } [HttpDelete("{id:guid}")] - public async Task> DeletePost(Guid id) + public async Task> DeletePost(Guid id) { if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized(); diff --git a/DysonNetwork.Sphere/Post/PostService.cs b/DysonNetwork.Sphere/Post/PostService.cs index 5243df9..4f30e3b 100644 --- a/DysonNetwork.Sphere/Post/PostService.cs +++ b/DysonNetwork.Sphere/Post/PostService.cs @@ -3,7 +3,6 @@ using System.Text.RegularExpressions; using AngleSharp.Common; using DysonNetwork.Shared; using DysonNetwork.Shared.Cache; -using DysonNetwork.Shared.Data; using DysonNetwork.Shared.Proto; using DysonNetwork.Shared.Registry; using DysonNetwork.Sphere.WebReader; @@ -13,6 +12,7 @@ using DysonNetwork.Sphere.Publisher; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Localization; using NodaTime; +using DysonNetwork.Shared.Models; namespace DysonNetwork.Sphere.Post; @@ -32,7 +32,7 @@ public partial class PostService( { private const string PostFileUsageIdentifier = "post"; - private static List TruncatePostContent(List input) + private static List TruncatePostContent(List input) { const int maxLength = 256; const int embedMaxLength = 80; @@ -62,7 +62,7 @@ public partial class PostService( return input; } - public (string title, string content) ChopPostForNotification(Post post) + public (string title, string content) ChopPostForNotification(SnPost post) { var content = !string.IsNullOrEmpty(post.Description) ? post.Description?.Length >= 40 ? post.Description[..37] + "..." : post.Description @@ -75,8 +75,8 @@ public partial class PostService( return (title, content); } - public async Task PostAsync( - Post post, + public async Task PostAsync( + SnPost post, List? attachments = null, List? tags = null, List? categories = null @@ -101,7 +101,7 @@ public partial class PostService( queryRequest.Ids.AddRange(attachments); var queryResponse = await files.GetFileBatchAsync(queryRequest); - post.Attachments = queryResponse.Files.Select(CloudFileReferenceObject.FromProtoValue).ToList(); + post.Attachments = queryResponse.Files.Select(SnCloudFileReferenceObject.FromProtoValue).ToList(); // Re-order the list to match the id list places post.Attachments = attachments .Select(id => post.Attachments.First(a => a.Id == id)) @@ -116,7 +116,7 @@ public partial class PostService( var existingSlugs = existingTags.Select(t => t.Slug).ToHashSet(); var missingSlugs = tags.Where(slug => !existingSlugs.Contains(slug)).ToList(); - var newTags = missingSlugs.Select(slug => new PostTag { Slug = slug }).ToList(); + var newTags = missingSlugs.Select(slug => new SnPostTag { Slug = slug }).ToList(); if (newTags.Count > 0) { await db.PostTags.AddRangeAsync(newTags); @@ -208,8 +208,8 @@ public partial class PostService( return post; } - public async Task UpdatePostAsync( - Post post, + public async Task UpdatePostAsync( + SnPost post, List? attachments = null, List? tags = null, List? categories = null, @@ -248,7 +248,7 @@ public partial class PostService( queryRequest.Ids.AddRange(attachments); var queryResponse = await files.GetFileBatchAsync(queryRequest); - post.Attachments = queryResponse.Files.Select(CloudFileReferenceObject.FromProtoValue).ToList(); + post.Attachments = queryResponse.Files.Select(SnCloudFileReferenceObject.FromProtoValue).ToList(); } if (tags is not null) @@ -259,7 +259,7 @@ public partial class PostService( var existingSlugs = existingTags.Select(t => t.Slug).ToHashSet(); var missingSlugs = tags.Where(slug => !existingSlugs.Contains(slug)).ToList(); - var newTags = missingSlugs.Select(slug => new PostTag { Slug = slug }).ToList(); + var newTags = missingSlugs.Select(slug => new SnPostTag { Slug = slug }).ToList(); if (newTags.Count > 0) { await db.PostTags.AddRangeAsync(newTags); @@ -288,7 +288,7 @@ public partial class PostService( [GeneratedRegex(@"https?://(?!.*\.\w{1,6}(?:[#?]|$))[^\s]+", RegexOptions.IgnoreCase)] private static partial Regex GetLinkRegex(); - public async Task PreviewPostLinkAsync(Post item) + public async Task PreviewPostLinkAsync(SnPost item) { if (item.Type != PostType.Moment || string.IsNullOrEmpty(item.Content)) return item; @@ -348,7 +348,7 @@ public partial class PostService( /// This method is designed to be called from a background task /// /// The post to process link previews for - private async Task ProcessPostLinkPreviewAsync(Post post) + private async Task ProcessPostLinkPreviewAsync(SnPost post) { try { @@ -387,7 +387,7 @@ public partial class PostService( } } - public async Task DeletePostAsync(Post post) + public async Task DeletePostAsync(SnPost post) { // Delete all file references for this post await fileRefs.DeleteResourceReferencesAsync( @@ -420,7 +420,7 @@ public partial class PostService( } } - public async Task PinPostAsync(Post post, Account currentUser, PostPinMode pinMode) + public async Task PinPostAsync(SnPost post, Account currentUser, PostPinMode pinMode) { var accountId = Guid.Parse(currentUser.Id); if (post.RepliedPostId != null) @@ -430,14 +430,14 @@ public partial class PostService( if (post.RepliedPost == null) throw new ArgumentNullException(nameof(post.RepliedPost)); if (!await ps.IsMemberWithRole(post.RepliedPost.PublisherId, accountId, - Publisher.PublisherMemberRole.Editor)) + Shared.Models.PublisherMemberRole.Editor)) throw new InvalidOperationException("Only editors of original post can pin replies."); post.PinMode = pinMode; } else { - if (!await ps.IsMemberWithRole(post.PublisherId, accountId, Publisher.PublisherMemberRole.Editor)) + if (!await ps.IsMemberWithRole(post.PublisherId, accountId, Shared.Models.PublisherMemberRole.Editor)) throw new InvalidOperationException("Only editors can pin replies."); post.PinMode = pinMode; @@ -449,7 +449,7 @@ public partial class PostService( return post; } - public async Task UnpinPostAsync(Post post, Account currentUser) + public async Task UnpinPostAsync(SnPost post, Account currentUser) { var accountId = Guid.Parse(currentUser.Id); if (post.RepliedPostId != null) @@ -457,12 +457,12 @@ public partial class PostService( if (post.RepliedPost == null) throw new ArgumentNullException(nameof(post.RepliedPost)); if (!await ps.IsMemberWithRole(post.RepliedPost.PublisherId, accountId, - Publisher.PublisherMemberRole.Editor)) + Shared.Models.PublisherMemberRole.Editor)) throw new InvalidOperationException("Only editors of original post can unpin replies."); } else { - if (!await ps.IsMemberWithRole(post.PublisherId, accountId, Publisher.PublisherMemberRole.Editor)) + if (!await ps.IsMemberWithRole(post.PublisherId, accountId, Shared.Models.PublisherMemberRole.Editor)) throw new InvalidOperationException("Only editors can unpin posts."); } @@ -484,14 +484,14 @@ public partial class PostService( /// Indicate this reaction is by the original post himself /// The account that creates this reaction public async Task ModifyPostVotes( - Post post, - PostReaction reaction, + SnPost post, + SnPostReaction reaction, Account sender, bool isRemoving, bool isSelfReact ) { - var isExistingReaction = await db.Set() + var isExistingReaction = await db.Set() .AnyAsync(r => r.PostId == post.Id && r.AccountId == reaction.AccountId); if (isRemoving) @@ -576,7 +576,7 @@ public partial class PostService( public async Task> GetPostReactionMap(Guid postId) { - return await db.Set() + return await db.Set() .Where(r => r.PostId == postId) .GroupBy(r => r.Symbol) .ToDictionaryAsync( @@ -587,7 +587,7 @@ public partial class PostService( public async Task>> GetPostReactionMapBatch(List postIds) { - return await db.Set() + return await db.Set() .Where(r => postIds.Contains(r.PostId)) .GroupBy(r => r.PostId) .ToDictionaryAsync( @@ -603,7 +603,7 @@ public partial class PostService( public async Task>> GetPostReactionMadeMapBatch(List postIds, Guid accountId) { - var reactions = await db.Set() + var reactions = await db.Set() .Where(r => postIds.Contains(r.PostId) && r.AccountId == accountId) .Select(r => new { r.PostId, r.Symbol }) .ToListAsync(); @@ -653,10 +653,10 @@ public partial class PostService( }); } - public async Task> LoadPublishers(List posts) + public async Task> LoadPublishers(List posts) { var publisherIds = posts - .SelectMany(e => + .SelectMany(e => [ e.PublisherId, e.RepliedPost?.PublisherId, @@ -688,7 +688,7 @@ public partial class PostService( return posts; } - public async Task> LoadInteractive(List posts, Account? currentUser = null) + public async Task> LoadInteractive(List posts, Account? currentUser = null) { if (posts.Count == 0) return posts; @@ -738,7 +738,7 @@ public partial class PostService( ); } - private async Task LoadPostEmbed(Post post, Account? currentUser) + private async Task LoadPostEmbed(SnPost post, Account? currentUser) { if (!post.Meta!.TryGetValue("embeds", out var value)) return; @@ -778,8 +778,8 @@ public partial class PostService( } } - public async Task> LoadPostInfo( - List posts, + public async Task> LoadPostInfo( + List posts, Account? currentUser = null, bool truncate = false ) @@ -801,7 +801,7 @@ public partial class PostService( return posts; } - public async Task LoadPostInfo(Post post, Account? currentUser = null, bool truncate = false) + public async Task LoadPostInfo(SnPost post, Account? currentUser = null, bool truncate = false) { // Convert single post to list, process it, then return the single post var posts = await LoadPostInfo([post], currentUser, truncate); @@ -810,7 +810,7 @@ public partial class PostService( private const string FeaturedPostCacheKey = "posts:featured"; - public async Task> ListFeaturedPostsAsync(Account? currentUser = null) + public async Task> ListFeaturedPostsAsync(Account? currentUser = null) { // Check cache first for featured post IDs var featuredIds = await cache.GetAsync>(FeaturedPostCacheKey); @@ -877,7 +877,7 @@ public partial class PostService( var records = reactSocialPoints .Where(p => !existingFeaturedPostIds.Contains(p.Key)) - .Select(e => new PostFeaturedRecord + .Select(e => new SnPostFeaturedRecord { PostId = e.Key, SocialCredits = e.Value @@ -904,7 +904,7 @@ public partial class PostService( return posts; } - public async Task AwardPost( + public async Task AwardPost( Guid postId, Guid accountId, decimal amount, @@ -915,7 +915,7 @@ public partial class PostService( var post = await db.Posts.Where(p => p.Id == postId).FirstOrDefaultAsync(); if (post is null) throw new InvalidOperationException("Post not found"); - var award = new PostAward + var award = new SnPostAward { Amount = amount, Attitude = attitude, @@ -983,11 +983,11 @@ public partial class PostService( public static class PostQueryExtensions { - public static IQueryable FilterWithVisibility( - this IQueryable source, + public static IQueryable FilterWithVisibility( + this IQueryable source, Account? currentUser, List userFriends, - List publishers, + List publishers, bool isListing = false ) { diff --git a/DysonNetwork.Sphere/Publisher/PublisherController.cs b/DysonNetwork.Sphere/Publisher/PublisherController.cs index 70e8784..e3a43fb 100644 --- a/DysonNetwork.Sphere/Publisher/PublisherController.cs +++ b/DysonNetwork.Sphere/Publisher/PublisherController.cs @@ -1,8 +1,7 @@ using System.ComponentModel.DataAnnotations; using DysonNetwork.Shared.Auth; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using DysonNetwork.Shared.Proto; -using DysonNetwork.Sphere.Realm; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; @@ -23,7 +22,7 @@ public class PublisherController( : ControllerBase { [HttpGet("{name}")] - public async Task> GetPublisher(string name) + public async Task> GetPublisher(string name) { var publisher = await db.Publishers .Where(e => e.Name == name) @@ -34,7 +33,7 @@ public class PublisherController( var account = await accounts.GetAccountAsync( new GetAccountRequest { Id = publisher.AccountId.Value.ToString() } ); - publisher.Account = AccountReference.FromProtoValue(account); + publisher.Account = SnAccount.FromProtoValue(account); return Ok(publisher); } @@ -48,7 +47,7 @@ public class PublisherController( } [HttpGet("of/{accountId:guid}")] - public async Task>> GetAccountManagedPublishers(Guid accountId) + public async Task>> GetAccountManagedPublishers(Guid accountId) { var members = await db.PublisherMembers .Where(m => m.AccountId == accountId) @@ -61,7 +60,7 @@ public class PublisherController( [HttpGet] [Authorize] - public async Task>> ListManagedPublishers() + public async Task>> ListManagedPublishers() { if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized(); var accountId = Guid.Parse(currentUser.Id); @@ -77,7 +76,7 @@ public class PublisherController( [HttpGet("invites")] [Authorize] - public async Task>> ListInvites() + public async Task>> ListInvites() { if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized(); var accountId = Guid.Parse(currentUser.Id); @@ -99,7 +98,7 @@ public class PublisherController( [HttpPost("invites/{name}")] [Authorize] - public async Task> InviteMember(string name, + public async Task> InviteMember(string name, [FromBody] PublisherMemberRequest request) { if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized(); @@ -117,7 +116,7 @@ public class PublisherController( if (!await ps.IsMemberWithRole(publisher.Id, accountId, request.Role)) return StatusCode(403, "You cannot invite member has higher permission than yours."); - var newMember = new PublisherMember + var newMember = new SnPublisherMember { AccountId = Guid.Parse(relatedUser.Id), PublisherId = publisher.Id, @@ -145,7 +144,7 @@ public class PublisherController( [HttpPost("invites/{name}/accept")] [Authorize] - public async Task> AcceptMemberInvite(string name) + public async Task> AcceptMemberInvite(string name) { if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized(); var accountId = Guid.Parse(currentUser.Id); @@ -270,7 +269,7 @@ public class PublisherController( [HttpPost("individual")] [Authorize] [RequiredPermission("global", "publishers.create")] - public async Task> CreatePublisherIndividual([FromBody] PublisherRequest request) + public async Task> CreatePublisherIndividual([FromBody] PublisherRequest request) { if (string.IsNullOrEmpty(request.Name) || string.IsNullOrEmpty(request.Nick)) return BadRequest("Name and Nick are required."); @@ -288,7 +287,7 @@ public class PublisherController( "your name firstly to get your name back." ); - CloudFileReferenceObject? picture = null, background = null; + SnCloudFileReferenceObject? picture = null, background = null; if (request.PictureId is not null) { var queryResult = await files.GetFileAsync( @@ -296,7 +295,7 @@ public class PublisherController( ); if (queryResult is null) throw new InvalidOperationException("Invalid picture id, unable to find the file on cloud."); - picture = CloudFileReferenceObject.FromProtoValue(queryResult); + picture = SnCloudFileReferenceObject.FromProtoValue(queryResult); } if (request.BackgroundId is not null) @@ -306,7 +305,7 @@ public class PublisherController( ); if (queryResult is null) throw new InvalidOperationException("Invalid background id, unable to find the file on cloud."); - background = CloudFileReferenceObject.FromProtoValue(queryResult); + background = SnCloudFileReferenceObject.FromProtoValue(queryResult); } var publisher = await ps.CreateIndividualPublisher( @@ -338,7 +337,7 @@ public class PublisherController( [HttpPost("organization/{realmSlug}")] [Authorize] [RequiredPermission("global", "publishers.create")] - public async Task> CreatePublisherOrganization(string realmSlug, + public async Task> CreatePublisherOrganization(string realmSlug, [FromBody] PublisherRequest request) { if (string.IsNullOrEmpty(request.Name) || string.IsNullOrEmpty(request.Nick)) @@ -362,7 +361,7 @@ public class PublisherController( if (duplicateNameCount > 0) return BadRequest("The name you requested has already been taken"); - CloudFileReferenceObject? picture = null, background = null; + SnCloudFileReferenceObject? picture = null, background = null; if (request.PictureId is not null) { var queryResult = await files.GetFileAsync( @@ -370,7 +369,7 @@ public class PublisherController( ); if (queryResult is null) throw new InvalidOperationException("Invalid picture id, unable to find the file on cloud."); - picture = CloudFileReferenceObject.FromProtoValue(queryResult); + picture = SnCloudFileReferenceObject.FromProtoValue(queryResult); } if (request.BackgroundId is not null) @@ -380,7 +379,7 @@ public class PublisherController( ); if (queryResult is null) throw new InvalidOperationException("Invalid background id, unable to find the file on cloud."); - background = CloudFileReferenceObject.FromProtoValue(queryResult); + background = SnCloudFileReferenceObject.FromProtoValue(queryResult); } var publisher = await ps.CreateOrganizationPublisher( @@ -414,7 +413,7 @@ public class PublisherController( [HttpPatch("{name}")] [Authorize] - public async Task> UpdatePublisher(string name, PublisherRequest request) + public async Task> UpdatePublisher(string name, PublisherRequest request) { if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized(); var accountId = Guid.Parse(currentUser.Id); @@ -442,7 +441,7 @@ public class PublisherController( ); if (queryResult is null) throw new InvalidOperationException("Invalid picture id, unable to find the file on cloud."); - var picture = CloudFileReferenceObject.FromProtoValue(queryResult); + var picture = SnCloudFileReferenceObject.FromProtoValue(queryResult); // Remove old references for the publisher picture if (publisher.Picture is not null) @@ -470,7 +469,7 @@ public class PublisherController( ); if (queryResult is null) throw new InvalidOperationException("Invalid background id, unable to find the file on cloud."); - var background = CloudFileReferenceObject.FromProtoValue(queryResult); + var background = SnCloudFileReferenceObject.FromProtoValue(queryResult); // Remove old references for the publisher background if (publisher.Background is not null) @@ -518,7 +517,7 @@ public class PublisherController( [HttpDelete("{name}")] [Authorize] - public async Task> DeletePublisher(string name) + public async Task> DeletePublisher(string name) { if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized(); var accountId = Guid.Parse(currentUser.Id); @@ -564,7 +563,7 @@ public class PublisherController( } [HttpGet("{name}/members")] - public async Task>> ListMembers( + public async Task>> ListMembers( string name, [FromQuery] int offset = 0, [FromQuery] int take = 20 @@ -594,7 +593,7 @@ public class PublisherController( [HttpGet("{name}/members/me")] [Authorize] - public async Task> GetCurrentIdentity(string name) + public async Task> GetCurrentIdentity(string name) { if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized(); var accountId = Guid.Parse(currentUser.Id); diff --git a/DysonNetwork.Sphere/Publisher/PublisherService.cs b/DysonNetwork.Sphere/Publisher/PublisherService.cs index 27ba956..a3b0535 100644 --- a/DysonNetwork.Sphere/Publisher/PublisherService.cs +++ b/DysonNetwork.Sphere/Publisher/PublisherService.cs @@ -1,8 +1,7 @@ using DysonNetwork.Shared.Cache; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using DysonNetwork.Shared.Proto; using DysonNetwork.Shared.Registry; -using DysonNetwork.Sphere.Post; using Microsoft.EntityFrameworkCore; using NodaTime; @@ -15,7 +14,7 @@ public class PublisherService( AccountClientHelper accountsHelper ) { - public async Task GetPublisherByName(string name) + public async Task GetPublisherByName(string name) { return await db.Publishers .Where(e => e.Name == name) @@ -24,12 +23,12 @@ public class PublisherService( private const string UserPublishersCacheKey = "accounts:{0}:publishers"; - public async Task> GetUserPublishers(Guid userId) + public async Task> GetUserPublishers(Guid userId) { var cacheKey = string.Format(UserPublishersCacheKey, userId); // Try to get publishers from the cache first - var publishers = await cache.GetAsync>(cacheKey); + var publishers = await cache.GetAsync>(cacheKey); if (publishers is not null) return publishers; @@ -48,16 +47,16 @@ public class PublisherService( return publishers; } - public async Task>> GetUserPublishersBatch(List userIds) + public async Task>> GetUserPublishersBatch(List userIds) { - var result = new Dictionary>(); + var result = new Dictionary>(); var missingIds = new List(); // Try to get publishers from cache for each user foreach (var userId in userIds) { var cacheKey = string.Format(UserPublishersCacheKey, userId); - var publishers = await cache.GetAsync>(cacheKey); + var publishers = await cache.GetAsync>(cacheKey); if (publishers != null) result[userId] = publishers; else @@ -103,12 +102,12 @@ public class PublisherService( public const string SubscribedPublishersCacheKey = "accounts:{0}:subscribed-publishers"; - public async Task> GetSubscribedPublishers(Guid userId) + public async Task> GetSubscribedPublishers(Guid userId) { var cacheKey = string.Format(SubscribedPublishersCacheKey, userId); // Try to get publishers from the cache first - var publishers = await cache.GetAsync>(cacheKey); + var publishers = await cache.GetAsync>(cacheKey); if (publishers is not null) return publishers; @@ -130,12 +129,12 @@ public class PublisherService( private const string PublisherMembersCacheKey = "publishers:{0}:members"; - public async Task> GetPublisherMembers(Guid publisherId) + public async Task> GetPublisherMembers(Guid publisherId) { var cacheKey = string.Format(PublisherMembersCacheKey, publisherId); // Try to get members from the cache first - var members = await cache.GetAsync>(cacheKey); + var members = await cache.GetAsync>(cacheKey); if (members is not null) return members; @@ -150,16 +149,16 @@ public class PublisherService( return members; } - public async Task CreateIndividualPublisher( + public async Task CreateIndividualPublisher( Account account, string? name, string? nick, string? bio, - CloudFileReferenceObject? picture, - CloudFileReferenceObject? background + SnCloudFileReferenceObject? picture, + SnCloudFileReferenceObject? background ) { - var publisher = new Publisher + var publisher = new SnPublisher { Type = PublisherType.Individual, Name = name ?? account.Name, @@ -167,12 +166,12 @@ public class PublisherService( Bio = bio ?? account.Profile.Bio, Picture = picture ?? (account.Profile.Picture is null ? null - : CloudFileReferenceObject.FromProtoValue(account.Profile.Picture)), + : SnCloudFileReferenceObject.FromProtoValue(account.Profile.Picture)), Background = background ?? (account.Profile.Background is null ? null - : CloudFileReferenceObject.FromProtoValue(account.Profile.Background)), + : SnCloudFileReferenceObject.FromProtoValue(account.Profile.Background)), AccountId = Guid.Parse(account.Id), - Members = new List + Members = new List { new() { @@ -213,26 +212,26 @@ public class PublisherService( return publisher; } - public async Task CreateOrganizationPublisher( - Realm.Realm realm, + public async Task CreateOrganizationPublisher( + Shared.Models.SnRealm realm, Account account, string? name, string? nick, string? bio, - CloudFileReferenceObject? picture, - CloudFileReferenceObject? background + SnCloudFileReferenceObject? picture, + SnCloudFileReferenceObject? background ) { - var publisher = new Publisher + var publisher = new SnPublisher { Type = PublisherType.Organizational, Name = name ?? realm.Slug, Nick = nick ?? realm.Name, Bio = bio ?? realm.Description, - Picture = picture ?? CloudFileReferenceObject.FromProtoValue(account.Profile.Picture), - Background = background ?? CloudFileReferenceObject.FromProtoValue(account.Profile.Background), + Picture = picture ?? SnCloudFileReferenceObject.FromProtoValue(account.Profile.Picture), + Background = background ?? SnCloudFileReferenceObject.FromProtoValue(account.Profile.Background), RealmId = realm.Id, - Members = new List + Members = new List { new() { @@ -379,14 +378,14 @@ public class PublisherService( return member != null && member.Role >= requiredRole; } - public async Task LoadMemberAccount(PublisherMember member) + public async Task LoadMemberAccount(SnPublisherMember member) { var account = await accountsHelper.GetAccount(member.AccountId); - member.Account = AccountReference.FromProtoValue(account); + member.Account = SnAccount.FromProtoValue(account); return member; } - public async Task> LoadMemberAccounts(ICollection members) + public async Task> LoadMemberAccounts(ICollection members) { var accountIds = members.Select(m => m.AccountId).ToList(); var accounts = (await accountsHelper.GetAccountBatch(accountIds)).ToDictionary(a => Guid.Parse(a.Id), a => a); @@ -394,7 +393,7 @@ public class PublisherService( return members.Select(m => { if (accounts.TryGetValue(m.AccountId, out var account)) - m.Account = AccountReference.FromProtoValue(account); + m.Account = SnAccount.FromProtoValue(account); return m; }).ToList(); } diff --git a/DysonNetwork.Sphere/Publisher/PublisherServiceGrpc.cs b/DysonNetwork.Sphere/Publisher/PublisherServiceGrpc.cs index 8c748f3..01ae2bf 100644 --- a/DysonNetwork.Sphere/Publisher/PublisherServiceGrpc.cs +++ b/DysonNetwork.Sphere/Publisher/PublisherServiceGrpc.cs @@ -1,3 +1,4 @@ +using DysonNetwork.Shared.Models; using DysonNetwork.Shared.Proto; using Grpc.Core; using Microsoft.EntityFrameworkCore; @@ -12,7 +13,7 @@ public class PublisherServiceGrpc(PublisherService service, AppDatabase db) ServerCallContext context ) { - Publisher? p = null; + SnPublisher? p = null; switch (request.QueryCase) { case GetPublisherRequest.QueryOneofCase.Id: diff --git a/DysonNetwork.Sphere/Publisher/PublisherSubscriptionController.cs b/DysonNetwork.Sphere/Publisher/PublisherSubscriptionController.cs index 9220111..90aa1e7 100644 --- a/DysonNetwork.Sphere/Publisher/PublisherSubscriptionController.cs +++ b/DysonNetwork.Sphere/Publisher/PublisherSubscriptionController.cs @@ -1,3 +1,4 @@ +using DysonNetwork.Shared.Models; using DysonNetwork.Shared.Proto; using DysonNetwork.Sphere.Post; using Microsoft.AspNetCore.Authorization; diff --git a/DysonNetwork.Sphere/Publisher/PublisherSubscriptionService.cs b/DysonNetwork.Sphere/Publisher/PublisherSubscriptionService.cs index 013e273..418aa5c 100644 --- a/DysonNetwork.Sphere/Publisher/PublisherSubscriptionService.cs +++ b/DysonNetwork.Sphere/Publisher/PublisherSubscriptionService.cs @@ -1,5 +1,6 @@ using DysonNetwork.Shared; using DysonNetwork.Shared.Cache; +using DysonNetwork.Shared.Models; using DysonNetwork.Shared.Proto; using DysonNetwork.Sphere.Localization; using DysonNetwork.Sphere.Post; @@ -49,7 +50,7 @@ public class PublisherSubscriptionService( /// /// The new post /// The number of subscribers notified - public async Task NotifySubscriberPost(Post.Post post) + public async Task NotifySubscriberPost(SnPost post) { if (post.RepliedPostId is not null) return 0; @@ -74,7 +75,7 @@ public class PublisherSubscriptionService( if (subscribers.Count == 0) return 0; - List categorySubscribers = []; + List categorySubscribers = []; if (post.Categories.Count > 0) { var categoryIds = post.Categories.Select(x => x.Id).ToList(); diff --git a/DysonNetwork.Sphere/Realm/RealmChatController.cs b/DysonNetwork.Sphere/Realm/RealmChatController.cs index a820972..5f15ad1 100644 --- a/DysonNetwork.Sphere/Realm/RealmChatController.cs +++ b/DysonNetwork.Sphere/Realm/RealmChatController.cs @@ -1,5 +1,5 @@ +using DysonNetwork.Shared.Models; using DysonNetwork.Shared.Proto; -using DysonNetwork.Sphere.Chat; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; @@ -12,7 +12,7 @@ public class RealmChatController(AppDatabase db, RealmService rs) : ControllerBa { [HttpGet("chat")] [Authorize] - public async Task>> ListRealmChat(string slug) + public async Task>> ListRealmChat(string slug) { var currentUser = HttpContext.Items["CurrentUser"] as Account; var accountId = currentUser is null ? Guid.Empty : Guid.Parse(currentUser.Id); diff --git a/DysonNetwork.Sphere/Realm/RealmController.cs b/DysonNetwork.Sphere/Realm/RealmController.cs index 09efa48..ce0225a 100644 --- a/DysonNetwork.Sphere/Realm/RealmController.cs +++ b/DysonNetwork.Sphere/Realm/RealmController.cs @@ -1,5 +1,4 @@ using System.ComponentModel.DataAnnotations; -using DysonNetwork.Shared.Data; using DysonNetwork.Shared.Proto; using DysonNetwork.Shared.Registry; using Microsoft.AspNetCore.Authorization; @@ -7,6 +6,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using NodaTime; using Google.Protobuf.WellKnownTypes; +using DysonNetwork.Shared.Models; namespace DysonNetwork.Sphere.Realm; @@ -53,7 +53,7 @@ public class RealmController( [HttpGet("invites")] [Authorize] - public async Task>> ListInvites() + public async Task>> ListInvites() { if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized(); var accountId = Guid.Parse(currentUser.Id); @@ -75,7 +75,7 @@ public class RealmController( [HttpPost("invites/{slug}")] [Authorize] - public async Task> InviteMember(string slug, + public async Task> InviteMember(string slug, [FromBody] RealmMemberRequest request) { if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized(); @@ -110,7 +110,7 @@ public class RealmController( if (hasExistingMember) return BadRequest("This user has been joined the realm or leave cannot be invited again."); - var member = new RealmMember + var member = new SnRealmMember { AccountId = Guid.Parse(relatedUser.Id), RealmId = realm.Id, @@ -211,7 +211,7 @@ public class RealmController( [HttpGet("{slug}/members")] - public async Task>> ListMembers( + public async Task>> ListMembers( string slug, [FromQuery] int offset = 0, [FromQuery] int take = 20, @@ -281,7 +281,7 @@ public class RealmController( [HttpGet("{slug}/members/me")] [Authorize] - public async Task> GetCurrentIdentity(string slug) + public async Task> GetCurrentIdentity(string slug) { if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized(); var accountId = Guid.Parse(currentUser.Id); @@ -362,7 +362,7 @@ public class RealmController( AccountId = Guid.Parse(currentUser.Id), IsCommunity = request.IsCommunity ?? false, IsPublic = request.IsPublic ?? false, - Members = new List + Members = new List { new() { @@ -377,14 +377,14 @@ public class RealmController( { var pictureResult = await files.GetFileAsync(new GetFileRequest { Id = request.PictureId }); if (pictureResult is null) return BadRequest("Invalid picture id, unable to find the file on cloud."); - realm.Picture = CloudFileReferenceObject.FromProtoValue(pictureResult); + realm.Picture = SnCloudFileReferenceObject.FromProtoValue(pictureResult); } if (request.BackgroundId is not null) { var backgroundResult = await files.GetFileAsync(new GetFileRequest { Id = request.BackgroundId }); if (backgroundResult is null) return BadRequest("Invalid background id, unable to find the file on cloud."); - realm.Background = CloudFileReferenceObject.FromProtoValue(backgroundResult); + realm.Background = SnCloudFileReferenceObject.FromProtoValue(backgroundResult); } db.Realms.Add(realm); @@ -479,7 +479,7 @@ public class RealmController( }); } - realm.Picture = CloudFileReferenceObject.FromProtoValue(pictureResult); + realm.Picture = SnCloudFileReferenceObject.FromProtoValue(pictureResult); // Create a new reference await fileRefs.CreateReferenceAsync(new CreateReferenceRequest @@ -504,7 +504,7 @@ public class RealmController( }); } - realm.Background = CloudFileReferenceObject.FromProtoValue(backgroundResult); + realm.Background = SnCloudFileReferenceObject.FromProtoValue(backgroundResult); // Create a new reference await fileRefs.CreateReferenceAsync(new CreateReferenceRequest @@ -542,7 +542,7 @@ public class RealmController( [HttpPost("{slug}/members/me")] [Authorize] - public async Task> JoinRealm(string slug) + public async Task> JoinRealm(string slug) { if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized(); @@ -560,7 +560,7 @@ public class RealmController( if (existingMember is not null) return BadRequest("You are already a member of this realm."); - var member = new RealmMember + var member = new SnRealmMember { AccountId = Guid.Parse(currentUser.Id), RealmId = realm.Id, @@ -629,7 +629,7 @@ public class RealmController( [HttpPatch("{slug}/members/{memberId:guid}/role")] [Authorize] - public async Task> UpdateMemberRole(string slug, Guid memberId, [FromBody] int newRole) + public async Task> UpdateMemberRole(string slug, Guid memberId, [FromBody] int newRole) { if (newRole >= RealmMemberRole.Owner) return BadRequest("Unable to set realm member to owner or greater role."); if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized(); diff --git a/DysonNetwork.Sphere/Realm/RealmService.cs b/DysonNetwork.Sphere/Realm/RealmService.cs index 9ee2153..43c363c 100644 --- a/DysonNetwork.Sphere/Realm/RealmService.cs +++ b/DysonNetwork.Sphere/Realm/RealmService.cs @@ -1,6 +1,7 @@ using DysonNetwork.Shared; using DysonNetwork.Shared.Cache; using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using DysonNetwork.Shared.Proto; using DysonNetwork.Shared.Registry; using DysonNetwork.Sphere.Localization; @@ -39,7 +40,7 @@ public class RealmService( return realms; } - public async Task SendInviteNotify(RealmMember member) + public async Task SendInviteNotify(SnRealmMember member) { var account = await accounts.GetAccountAsync(new GetAccountRequest { Id = member.AccountId.ToString() }); CultureService.SetCultureInfo(account); @@ -71,14 +72,14 @@ public class RealmService( return member?.Role >= maxRequiredRole; } - public async Task LoadMemberAccount(RealmMember member) + public async Task LoadMemberAccount(SnRealmMember member) { var account = await accountsHelper.GetAccount(member.AccountId); - member.Account = AccountReference.FromProtoValue(account); + member.Account = SnAccount.FromProtoValue(account); return member; } - public async Task> LoadMemberAccounts(ICollection members) + public async Task> LoadMemberAccounts(ICollection members) { var accountIds = members.Select(m => m.AccountId).ToList(); var accounts = (await accountsHelper.GetAccountBatch(accountIds)).ToDictionary(a => Guid.Parse(a.Id), a => a); @@ -86,7 +87,7 @@ public class RealmService( return members.Select(m => { if (accounts.TryGetValue(m.AccountId, out var account)) - m.Account = AccountReference.FromProtoValue(account); + m.Account = SnAccount.FromProtoValue(account); return m; }).ToList(); } diff --git a/DysonNetwork.Sphere/Startup/BroadcastEventHandler.cs b/DysonNetwork.Sphere/Startup/BroadcastEventHandler.cs index d99609a..f3301a5 100644 --- a/DysonNetwork.Sphere/Startup/BroadcastEventHandler.cs +++ b/DysonNetwork.Sphere/Startup/BroadcastEventHandler.cs @@ -1,5 +1,6 @@ using System.Text.Json; using System.Text.Json.Serialization; +using DysonNetwork.Shared.Models; using DysonNetwork.Shared.Proto; using DysonNetwork.Shared.Stream; using DysonNetwork.Sphere.Chat; @@ -9,7 +10,7 @@ using Microsoft.EntityFrameworkCore; using NATS.Client.Core; using NATS.Client.JetStream.Models; using NATS.Net; -using WebSocketPacket = DysonNetwork.Shared.Data.WebSocketPacket; +using WebSocketPacket = DysonNetwork.Shared.Models.WebSocketPacket; namespace DysonNetwork.Sphere.Startup; diff --git a/DysonNetwork.Sphere/Sticker/StickerController.cs b/DysonNetwork.Sphere/Sticker/StickerController.cs index 0ba15da..24c6a11 100644 --- a/DysonNetwork.Sphere/Sticker/StickerController.cs +++ b/DysonNetwork.Sphere/Sticker/StickerController.cs @@ -1,6 +1,6 @@ using System.ComponentModel.DataAnnotations; using DysonNetwork.Shared.Auth; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using DysonNetwork.Shared.Proto; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; @@ -20,7 +20,7 @@ public class StickerController( private async Task _CheckStickerPackPermissions( Guid packId, Account currentUser, - Publisher.PublisherMemberRole requiredRole + Shared.Models.PublisherMemberRole requiredRole ) { var pack = await db.StickerPacks @@ -46,7 +46,7 @@ public class StickerController( [FromQuery(Name = "query")] string? query = null ) { - Publisher.Publisher? publisher = null; + Shared.Models.SnPublisher? publisher = null; if (pubName is not null) publisher = await db.Publishers.FirstOrDefaultAsync(p => p.Name == pubName); @@ -168,7 +168,7 @@ public class StickerController( .FirstOrDefaultAsync(m => m.AccountId == accountId && m.PublisherId == pack.PublisherId); if (member is null) return StatusCode(403, "You are not a member of this publisher"); - if (member.Role < Publisher.PublisherMemberRole.Editor) + if (member.Role < Shared.Models.PublisherMemberRole.Editor) return StatusCode(403, "You need to be at least an editor to update sticker packs"); if (request.Name is not null) @@ -200,7 +200,7 @@ public class StickerController( .FirstOrDefaultAsync(m => m.AccountId == accountId && m.PublisherId == pack.PublisherId); if (member is null) return StatusCode(403, "You are not a member of this publisher"); - if (member.Role < Publisher.PublisherMemberRole.Editor) + if (member.Role < Shared.Models.PublisherMemberRole.Editor) return StatusCode(403, "You need to be an editor to delete sticker packs"); await st.DeleteStickerPackAsync(pack); @@ -262,7 +262,7 @@ public class StickerController( return Unauthorized(); var permissionCheck = - await _CheckStickerPackPermissions(packId, currentUser, Publisher.PublisherMemberRole.Editor); + await _CheckStickerPackPermissions(packId, currentUser, Shared.Models.PublisherMemberRole.Editor); if (permissionCheck is not OkResult) return permissionCheck; @@ -277,14 +277,14 @@ public class StickerController( if (request.Slug is not null) sticker.Slug = request.Slug; - CloudFileReferenceObject? image = null; + SnCloudFileReferenceObject? image = null; if (request.ImageId is not null) { var file = await files.GetFileAsync(new GetFileRequest { Id = request.ImageId }); if (file is null) return BadRequest("Image not found"); sticker.ImageId = request.ImageId; - sticker.Image = CloudFileReferenceObject.FromProtoValue(file); + sticker.Image = SnCloudFileReferenceObject.FromProtoValue(file); } sticker = await st.UpdateStickerAsync(sticker, image); @@ -298,7 +298,7 @@ public class StickerController( return Unauthorized(); var permissionCheck = - await _CheckStickerPackPermissions(packId, currentUser, Publisher.PublisherMemberRole.Editor); + await _CheckStickerPackPermissions(packId, currentUser, Shared.Models.PublisherMemberRole.Editor); if (permissionCheck is not OkResult) return permissionCheck; @@ -329,7 +329,7 @@ public class StickerController( return BadRequest("Image is required."); var permissionCheck = - await _CheckStickerPackPermissions(packId, currentUser, Publisher.PublisherMemberRole.Editor); + await _CheckStickerPackPermissions(packId, currentUser, Shared.Models.PublisherMemberRole.Editor); if (permissionCheck is not OkResult) return permissionCheck; @@ -351,7 +351,7 @@ public class StickerController( { Slug = request.Slug, ImageId = file.Id, - Image = CloudFileReferenceObject.FromProtoValue(file), + Image = SnCloudFileReferenceObject.FromProtoValue(file), Pack = pack }; diff --git a/DysonNetwork.Sphere/Sticker/StickerService.cs b/DysonNetwork.Sphere/Sticker/StickerService.cs index d912a10..9f515b8 100644 --- a/DysonNetwork.Sphere/Sticker/StickerService.cs +++ b/DysonNetwork.Sphere/Sticker/StickerService.cs @@ -1,5 +1,5 @@ using DysonNetwork.Shared.Cache; -using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; using DysonNetwork.Shared.Proto; using Microsoft.EntityFrameworkCore; @@ -33,7 +33,7 @@ public class StickerService( return sticker; } - public async Task UpdateStickerAsync(Sticker sticker, CloudFileReferenceObject? newImage) + public async Task UpdateStickerAsync(Sticker sticker, SnCloudFileReferenceObject? newImage) { if (newImage is not null) { diff --git a/DysonNetwork.Sphere/WebReader/WebArticle.cs b/DysonNetwork.Sphere/WebReader/WebArticle.cs index 1945804..d00f510 100644 --- a/DysonNetwork.Sphere/WebReader/WebArticle.cs +++ b/DysonNetwork.Sphere/WebReader/WebArticle.cs @@ -2,6 +2,7 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Text.Json.Serialization; using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Models; namespace DysonNetwork.Sphere.WebReader; @@ -41,7 +42,7 @@ public class WebFeed : ModelBase [Column(TypeName = "jsonb")] public WebFeedConfig Config { get; set; } = new(); public Guid PublisherId { get; set; } - public Publisher.Publisher Publisher { get; set; } = null!; + public Shared.Models.SnPublisher Publisher { get; set; } = null!; [JsonIgnore] public ICollection Articles { get; set; } = new List(); } @@ -53,5 +54,5 @@ public class WebFeedSubscription : ModelBase public Guid FeedId { get; set; } public WebFeed Feed { get; set; } = null!; public Guid AccountId { get; set; } - [NotMapped] public AccountReference Account { get; set; } = null!; + [NotMapped] public SnAccount Account { get; set; } = null!; } \ No newline at end of file diff --git a/DysonNetwork.Sphere/WebReader/WebFeedController.cs b/DysonNetwork.Sphere/WebReader/WebFeedController.cs index 881f419..91c080a 100644 --- a/DysonNetwork.Sphere/WebReader/WebFeedController.cs +++ b/DysonNetwork.Sphere/WebReader/WebFeedController.cs @@ -52,7 +52,7 @@ public class WebFeedController(WebFeedService webFeed, Publisher.PublisherServic if (publisher is null) return NotFound(); var accountId = Guid.Parse(currentUser.Id); - if (!await ps.IsMemberWithRole(publisher.Id, accountId, Publisher.PublisherMemberRole.Editor)) + if (!await ps.IsMemberWithRole(publisher.Id, accountId, Shared.Models.PublisherMemberRole.Editor)) return StatusCode(403, "You must be an editor of the publisher to create a web feed"); var feed = await webFeed.CreateWebFeedAsync(publisher, request); @@ -69,7 +69,7 @@ public class WebFeedController(WebFeedService webFeed, Publisher.PublisherServic if (publisher is null) return NotFound(); var accountId = Guid.Parse(currentUser.Id); - if (!await ps.IsMemberWithRole(publisher.Id, accountId, Publisher.PublisherMemberRole.Editor)) + if (!await ps.IsMemberWithRole(publisher.Id, accountId, Shared.Models.PublisherMemberRole.Editor)) return StatusCode(403, "You must be an editor of the publisher to update a web feed"); var feed = await webFeed.GetFeedAsync(id, publisherId: publisher.Id); @@ -90,7 +90,7 @@ public class WebFeedController(WebFeedService webFeed, Publisher.PublisherServic if (publisher is null) return NotFound(); var accountId = Guid.Parse(currentUser.Id); - if (!await ps.IsMemberWithRole(publisher.Id, accountId, Publisher.PublisherMemberRole.Editor)) + if (!await ps.IsMemberWithRole(publisher.Id, accountId, Shared.Models.PublisherMemberRole.Editor)) return StatusCode(403, "You must be an editor of the publisher to delete a web feed"); var feed = await webFeed.GetFeedAsync(id, publisherId: publisher.Id); @@ -113,7 +113,7 @@ public class WebFeedController(WebFeedService webFeed, Publisher.PublisherServic if (publisher is null) return NotFound(); var accountId = Guid.Parse(currentUser.Id); - if (!await ps.IsMemberWithRole(publisher.Id, accountId, Publisher.PublisherMemberRole.Editor)) + if (!await ps.IsMemberWithRole(publisher.Id, accountId, Shared.Models.PublisherMemberRole.Editor)) return StatusCode(403, "You must be an editor of the publisher to scrape a web feed"); var feed = await webFeed.GetFeedAsync(id, publisherId: publisher.Id); diff --git a/DysonNetwork.Sphere/WebReader/WebFeedService.cs b/DysonNetwork.Sphere/WebReader/WebFeedService.cs index 4100304..a1558ad 100644 --- a/DysonNetwork.Sphere/WebReader/WebFeedService.cs +++ b/DysonNetwork.Sphere/WebReader/WebFeedService.cs @@ -11,7 +11,7 @@ public class WebFeedService( WebReaderService webReaderService ) { - public async Task CreateWebFeedAsync(Publisher.Publisher publisher, + public async Task CreateWebFeedAsync(Shared.Models.SnPublisher publisher, WebFeedController.WebFeedRequest request) { var feed = new WebFeed