Mare 0.8 (#13)

* get rid of file handling through grpc and signalr

* make non empty uri for serialization

* adjust api DataHash calc into their respective classes

* Revert "adapt api extensions"

This reverts commit 5fb78ba367.

* Revert "adapt userpermissions"

This reverts commit 28dd123ca6.

* Revert "Revert "adapt api extensions""

This reverts commit 12c9bc3c53566532e2984ace0b3d2e0a8b7facc0.

* Revert "Revert "adapt userpermissions""

This reverts commit 4193ac008cccf2f5b42e9cdf50b2a084877cbf9a.

* update flags

* add upload status to server

---------

Co-authored-by: rootdarkarchon <root.darkarchon@outlook.com>
This commit is contained in:
rootdarkarchon
2023-03-14 19:49:44 +01:00
committed by GitHub
parent 85bedb49e3
commit ecaadc8ead
11 changed files with 181 additions and 104 deletions

View File

@@ -1,11 +1,30 @@
using MareSynchronos.API.Data.Enum;
using MessagePack;
using System.Text.Json.Serialization;
using System.Text.Json;
using System.Text;
using System.Security.Cryptography;
namespace MareSynchronos.API.Data;
[MessagePackObject(keyAsPropertyName: true)]
public class CharacterData : HashableDataBase
public class CharacterData
{
public CharacterData()
{
DataHash = new(() =>
{
var json = JsonSerializer.Serialize(this);
#pragma warning disable SYSLIB0021 // Type or member is obsolete
using SHA256CryptoServiceProvider cryptoProvider = new();
#pragma warning restore SYSLIB0021 // Type or member is obsolete
return BitConverter.ToString(cryptoProvider.ComputeHash(Encoding.UTF8.GetBytes(json))).Replace("-", "", StringComparison.Ordinal);
});
}
[JsonIgnore]
public Lazy<string> DataHash { get; }
public Dictionary<ObjectKind, List<FileReplacementData>> FileReplacements { get; set; } = new();
public Dictionary<ObjectKind, string> GlamourerData { get; set; } = new();
public string ManipulationData { get; set; } = string.Empty;

View File

@@ -3,7 +3,9 @@
[Flags]
public enum UserPermissions
{
NoneSet,
Paired,
Paused
NoneSet = 0,
Paired = 1,
Paused = 2,
DisableAnimations = 4,
DisableSounds = 8
}

View File

@@ -1,10 +1,29 @@
using MessagePack;
using System.Text.Json.Serialization;
using System.Text.Json;
using System.Text;
using System.Security.Cryptography;
namespace MareSynchronos.API.Data;
[MessagePackObject(keyAsPropertyName: true)]
public class FileReplacementData : HashableDataBase
public class FileReplacementData
{
public FileReplacementData()
{
DataHash = new(() =>
{
var json = JsonSerializer.Serialize(this);
#pragma warning disable SYSLIB0021 // Type or member is obsolete
using SHA256CryptoServiceProvider cryptoProvider = new();
#pragma warning restore SYSLIB0021 // Type or member is obsolete
return BitConverter.ToString(cryptoProvider.ComputeHash(Encoding.UTF8.GetBytes(json))).Replace("-", "", StringComparison.Ordinal);
});
}
[JsonIgnore]
public Lazy<string> DataHash { get; }
public string[] GamePaths { get; set; } = Array.Empty<string>();
public string Hash { get; set; } = string.Empty;
public string FileSwapPath { get; set; } = string.Empty;

View File

@@ -1,22 +0,0 @@
using System.Security.Cryptography;
using System.Text;
using MessagePack;
using Newtonsoft.Json;
namespace MareSynchronos.API.Data;
public abstract class HashableDataBase
{
protected HashableDataBase()
{
DataHash = new(() =>
{
var json = JsonConvert.SerializeObject(this, Formatting.None);
using SHA256CryptoServiceProvider cryptoProvider = new();
return BitConverter.ToString(cryptoProvider.ComputeHash(Encoding.UTF8.GetBytes(json))).Replace("-", "", StringComparison.Ordinal);
});
}
[JsonIgnore]
public Lazy<string> DataHash { get; }
}