Automated status meta

This commit is contained in:
2025-09-24 13:45:05 +08:00
parent 7087736e31
commit 266312e97e
6 changed files with 20 additions and 9 deletions

View File

@@ -1,6 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk/9.4.2;Aspire.AppHost.Sdk/9.4.2">
<Sdk Name="Aspire.AppHost.Sdk" Version="9.4.2"/>
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>

View File

@@ -194,6 +194,7 @@ public class AccountController(
public bool IsAutomated { get; set; } = false; public bool IsAutomated { get; set; } = false;
[MaxLength(1024)] public string? Label { get; set; } [MaxLength(1024)] public string? Label { get; set; }
[MaxLength(4096)] public string? AppIdentifier { get; set; } [MaxLength(4096)] public string? AppIdentifier { get; set; }
public Dictionary<string, object>? Meta { get; set; }
public Instant? ClearedAt { get; set; } public Instant? ClearedAt { get; set; }
} }

View File

@@ -216,6 +216,7 @@ public class AccountCurrentController(
status.IsAutomated = request.IsAutomated; status.IsAutomated = request.IsAutomated;
status.Label = request.Label; status.Label = request.Label;
status.AppIdentifier = request.AppIdentifier; status.AppIdentifier = request.AppIdentifier;
status.Meta = request.Meta;
status.ClearedAt = request.ClearedAt; status.ClearedAt = request.ClearedAt;
db.Update(status); db.Update(status);
@@ -245,6 +246,7 @@ public class AccountCurrentController(
existingStatus.Attitude = request.Attitude; existingStatus.Attitude = request.Attitude;
existingStatus.IsInvisible = request.IsInvisible; existingStatus.IsInvisible = request.IsInvisible;
existingStatus.IsNotDisturb = request.IsNotDisturb; existingStatus.IsNotDisturb = request.IsNotDisturb;
existingStatus.Meta = request.Meta;
existingStatus.Label = request.Label; existingStatus.Label = request.Label;
db.Update(existingStatus); db.Update(existingStatus);
await db.SaveChangesAsync(); await db.SaveChangesAsync();
@@ -268,6 +270,7 @@ public class AccountCurrentController(
IsNotDisturb = request.IsNotDisturb, IsNotDisturb = request.IsNotDisturb,
IsAutomated = request.IsAutomated, IsAutomated = request.IsAutomated,
Label = request.Label, Label = request.Label,
Meta = request.Meta,
AppIdentifier = request.AppIdentifier, AppIdentifier = request.AppIdentifier,
ClearedAt = request.ClearedAt ClearedAt = request.ClearedAt
}; };
@@ -287,7 +290,7 @@ public class AccountCurrentController(
.OrderByDescending(s => s.CreatedAt) .OrderByDescending(s => s.CreatedAt)
.AsQueryable(); .AsQueryable();
if (string.IsNullOrWhiteSpace(app)) if (!string.IsNullOrWhiteSpace(app))
queryable = queryable.Where(s => s.IsAutomated && s.AppIdentifier == app); queryable = queryable.Where(s => s.IsAutomated && s.AppIdentifier == app);
var status = await queryable var status = await queryable

View File

@@ -1,6 +1,7 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using DysonNetwork.Shared.Data; using DysonNetwork.Shared.Data;
using DysonNetwork.Shared.Proto;
using NodaTime; using NodaTime;
using NodaTime.Serialization.Protobuf; using NodaTime.Serialization.Protobuf;
@@ -22,6 +23,7 @@ public class Status : ModelBase
public bool IsInvisible { get; set; } public bool IsInvisible { get; set; }
public bool IsNotDisturb { get; set; } public bool IsNotDisturb { get; set; }
[MaxLength(1024)] public string? Label { get; set; } [MaxLength(1024)] public string? Label { get; set; }
[Column(TypeName = "jsonb")] public Dictionary<string, object>? Meta { get; set; }
public Instant? ClearedAt { get; set; } public Instant? ClearedAt { get; set; }
[MaxLength(4096)] public string? AppIdentifier { get; set; } [MaxLength(4096)] public string? AppIdentifier { get; set; }
@@ -50,6 +52,7 @@ public class Status : ModelBase
IsInvisible = IsInvisible, IsInvisible = IsInvisible,
IsNotDisturb = IsNotDisturb, IsNotDisturb = IsNotDisturb,
Label = Label ?? string.Empty, Label = Label ?? string.Empty,
Meta = GrpcTypeHelper.ConvertObjectToByteString(Meta),
ClearedAt = ClearedAt?.ToTimestamp(), ClearedAt = ClearedAt?.ToTimestamp(),
AccountId = AccountId.ToString() AccountId = AccountId.ToString()
}; };
@@ -74,6 +77,7 @@ public class Status : ModelBase
IsInvisible = proto.IsInvisible, IsInvisible = proto.IsInvisible,
IsNotDisturb = proto.IsNotDisturb, IsNotDisturb = proto.IsNotDisturb,
Label = proto.Label, Label = proto.Label,
Meta = GrpcTypeHelper.ConvertByteStringToObject<Dictionary<string, object>>(proto.Meta),
ClearedAt = proto.ClearedAt?.ToInstant(), ClearedAt = proto.ClearedAt?.ToInstant(),
AccountId = Guid.Parse(proto.AccountId) AccountId = Guid.Parse(proto.AccountId)
}; };
@@ -88,7 +92,8 @@ public enum CheckInResultLevel
Worse, Worse,
Normal, Normal,
Better, Better,
Best Best,
Special
} }
public class CheckInResult : ModelBase public class CheckInResult : ModelBase

View File

@@ -13,6 +13,7 @@ public class AccountStatusReference : ModelBase
public bool IsInvisible { get; set; } public bool IsInvisible { get; set; }
public bool IsNotDisturb { get; set; } public bool IsNotDisturb { get; set; }
public string? Label { get; set; } public string? Label { get; set; }
public Dictionary<string, object>? Meta { get; set; }
public Instant? ClearedAt { get; set; } public Instant? ClearedAt { get; set; }
public Guid AccountId { get; set; } public Guid AccountId { get; set; }
@@ -28,6 +29,7 @@ public class AccountStatusReference : ModelBase
IsInvisible = IsInvisible, IsInvisible = IsInvisible,
IsNotDisturb = IsNotDisturb, IsNotDisturb = IsNotDisturb,
Label = Label ?? string.Empty, Label = Label ?? string.Empty,
Meta = GrpcTypeHelper.ConvertObjectToByteString(Meta),
ClearedAt = ClearedAt?.ToTimestamp(), ClearedAt = ClearedAt?.ToTimestamp(),
AccountId = AccountId.ToString() AccountId = AccountId.ToString()
}; };
@@ -46,6 +48,7 @@ public class AccountStatusReference : ModelBase
IsInvisible = proto.IsInvisible, IsInvisible = proto.IsInvisible,
IsNotDisturb = proto.IsNotDisturb, IsNotDisturb = proto.IsNotDisturb,
Label = proto.Label, Label = proto.Label,
Meta = GrpcTypeHelper.ConvertByteStringToObject<Dictionary<string, object>>(proto.Meta),
ClearedAt = proto.ClearedAt?.ToInstant(), ClearedAt = proto.ClearedAt?.ToInstant(),
AccountId = Guid.Parse(proto.AccountId) AccountId = Guid.Parse(proto.AccountId)
}; };

View File

@@ -56,6 +56,7 @@ message AccountStatus {
google.protobuf.StringValue label = 7; google.protobuf.StringValue label = 7;
google.protobuf.Timestamp cleared_at = 8; google.protobuf.Timestamp cleared_at = 8;
string account_id = 9; string account_id = 9;
bytes meta = 10;
} }
// Profile contains detailed information about a user // Profile contains detailed information about a user