From 266312e97e915313f0dfff2f74409cc764c3bbf7 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Wed, 24 Sep 2025 13:45:05 +0800 Subject: [PATCH] :sparkles: Automated status meta --- DysonNetwork.Control/DysonNetwork.Control.csproj | 4 +--- DysonNetwork.Pass/Account/AccountController.cs | 1 + DysonNetwork.Pass/Account/AccountCurrentController.cs | 5 ++++- DysonNetwork.Pass/Account/Event.cs | 11 ++++++++--- DysonNetwork.Shared/Data/AccountStatus.cs | 7 +++++-- DysonNetwork.Shared/Proto/account.proto | 1 + 6 files changed, 20 insertions(+), 9 deletions(-) diff --git a/DysonNetwork.Control/DysonNetwork.Control.csproj b/DysonNetwork.Control/DysonNetwork.Control.csproj index f8a51c4..85e6917 100644 --- a/DysonNetwork.Control/DysonNetwork.Control.csproj +++ b/DysonNetwork.Control/DysonNetwork.Control.csproj @@ -1,6 +1,4 @@ - - - + Exe diff --git a/DysonNetwork.Pass/Account/AccountController.cs b/DysonNetwork.Pass/Account/AccountController.cs index 29835fe..b413794 100644 --- a/DysonNetwork.Pass/Account/AccountController.cs +++ b/DysonNetwork.Pass/Account/AccountController.cs @@ -194,6 +194,7 @@ public class AccountController( public bool IsAutomated { get; set; } = false; [MaxLength(1024)] public string? Label { get; set; } [MaxLength(4096)] public string? AppIdentifier { get; set; } + public Dictionary? Meta { get; set; } public Instant? ClearedAt { get; set; } } diff --git a/DysonNetwork.Pass/Account/AccountCurrentController.cs b/DysonNetwork.Pass/Account/AccountCurrentController.cs index 63a80e2..0ad6b63 100644 --- a/DysonNetwork.Pass/Account/AccountCurrentController.cs +++ b/DysonNetwork.Pass/Account/AccountCurrentController.cs @@ -216,6 +216,7 @@ public class AccountCurrentController( status.IsAutomated = request.IsAutomated; status.Label = request.Label; status.AppIdentifier = request.AppIdentifier; + status.Meta = request.Meta; status.ClearedAt = request.ClearedAt; db.Update(status); @@ -245,6 +246,7 @@ public class AccountCurrentController( existingStatus.Attitude = request.Attitude; existingStatus.IsInvisible = request.IsInvisible; existingStatus.IsNotDisturb = request.IsNotDisturb; + existingStatus.Meta = request.Meta; existingStatus.Label = request.Label; db.Update(existingStatus); await db.SaveChangesAsync(); @@ -268,6 +270,7 @@ public class AccountCurrentController( IsNotDisturb = request.IsNotDisturb, IsAutomated = request.IsAutomated, Label = request.Label, + Meta = request.Meta, AppIdentifier = request.AppIdentifier, ClearedAt = request.ClearedAt }; @@ -287,7 +290,7 @@ public class AccountCurrentController( .OrderByDescending(s => s.CreatedAt) .AsQueryable(); - if (string.IsNullOrWhiteSpace(app)) + if (!string.IsNullOrWhiteSpace(app)) queryable = queryable.Where(s => s.IsAutomated && s.AppIdentifier == app); var status = await queryable diff --git a/DysonNetwork.Pass/Account/Event.cs b/DysonNetwork.Pass/Account/Event.cs index fc57194..8877851 100644 --- a/DysonNetwork.Pass/Account/Event.cs +++ b/DysonNetwork.Pass/Account/Event.cs @@ -1,6 +1,7 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using DysonNetwork.Shared.Data; +using DysonNetwork.Shared.Proto; using NodaTime; using NodaTime.Serialization.Protobuf; @@ -22,9 +23,10 @@ public class Status : ModelBase public bool IsInvisible { get; set; } public bool IsNotDisturb { get; set; } [MaxLength(1024)] public string? Label { get; set; } + [Column(TypeName = "jsonb")] public Dictionary? Meta { get; set; } public Instant? ClearedAt { get; set; } [MaxLength(4096)] public string? AppIdentifier { get; set; } - + /// /// Indicates this status is created based on running process or rich presence /// @@ -32,7 +34,7 @@ public class Status : ModelBase public Guid AccountId { get; set; } public Account Account { get; set; } = null!; - + public Shared.Proto.AccountStatus ToProtoValue() { var proto = new Shared.Proto.AccountStatus @@ -50,6 +52,7 @@ public class Status : ModelBase IsInvisible = IsInvisible, IsNotDisturb = IsNotDisturb, Label = Label ?? string.Empty, + Meta = GrpcTypeHelper.ConvertObjectToByteString(Meta), ClearedAt = ClearedAt?.ToTimestamp(), AccountId = AccountId.ToString() }; @@ -74,6 +77,7 @@ public class Status : ModelBase IsInvisible = proto.IsInvisible, IsNotDisturb = proto.IsNotDisturb, Label = proto.Label, + Meta = GrpcTypeHelper.ConvertByteStringToObject>(proto.Meta), ClearedAt = proto.ClearedAt?.ToInstant(), AccountId = Guid.Parse(proto.AccountId) }; @@ -88,7 +92,8 @@ public enum CheckInResultLevel Worse, Normal, Better, - Best + Best, + Special } public class CheckInResult : ModelBase diff --git a/DysonNetwork.Shared/Data/AccountStatus.cs b/DysonNetwork.Shared/Data/AccountStatus.cs index 2f2f23d..630d514 100644 --- a/DysonNetwork.Shared/Data/AccountStatus.cs +++ b/DysonNetwork.Shared/Data/AccountStatus.cs @@ -13,10 +13,11 @@ public class AccountStatusReference : ModelBase 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 @@ -28,6 +29,7 @@ public class AccountStatusReference : ModelBase IsInvisible = IsInvisible, IsNotDisturb = IsNotDisturb, Label = Label ?? string.Empty, + Meta = GrpcTypeHelper.ConvertObjectToByteString(Meta), ClearedAt = ClearedAt?.ToTimestamp(), AccountId = AccountId.ToString() }; @@ -46,10 +48,11 @@ public class AccountStatusReference : ModelBase 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; } -} \ No newline at end of file +} diff --git a/DysonNetwork.Shared/Proto/account.proto b/DysonNetwork.Shared/Proto/account.proto index 44c683e..0306067 100644 --- a/DysonNetwork.Shared/Proto/account.proto +++ b/DysonNetwork.Shared/Proto/account.proto @@ -56,6 +56,7 @@ message AccountStatus { google.protobuf.StringValue label = 7; google.protobuf.Timestamp cleared_at = 8; string account_id = 9; + bytes meta = 10; } // Profile contains detailed information about a user