using System.Text.Json;
using DysonNetwork.Shared.Proto;
using Google.Protobuf;
namespace DysonNetwork.Shared.Data;
public enum ContentSensitiveMark
{
Language,
SexualContent,
Violence,
Profanity,
HateSpeech,
Racism,
AdultContent,
DrugAbuse,
AlcoholAbuse,
Gambling,
SelfHarm,
ChildAbuse,
Other
}
///
/// 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 string Id { get; set; } = null!;
public string Name { get; set; } = string.Empty;
public Dictionary FileMeta { get; set; } = null!;
public Dictionary UserMeta { get; set; } = null!;
public string? MimeType { get; set; }
public string? Hash { get; set; }
public long Size { get; set; }
public bool HasCompression { get; set; } = false;
public static CloudFileReferenceObject FromProtoValue(Proto.CloudFile proto)
{
return new CloudFileReferenceObject
{
Id = proto.Id,
Name = proto.Name,
FileMeta = JsonSerializer.Deserialize>(
proto.FileMeta.ToStringUtf8(),
GrpcTypeHelper.SerializerOptions
)?.ToDictionary(
kvp => kvp.Key,
kvp => kvp.Value.ValueKind == JsonValueKind.Undefined ? null : kvp.Value.Deserialize