Initial mirror.
This commit is contained in:
36
MareSynchronosAPI/Data/CharacterData.cs
Normal file
36
MareSynchronosAPI/Data/CharacterData.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
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
|
||||
{
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
||||
public Dictionary<ObjectKind, string> CustomizePlusData { get; set; } = new();
|
||||
[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 HeelsData { get; set; } = string.Empty;
|
||||
public string HonorificData { get; set; } = string.Empty;
|
||||
public string ManipulationData { get; set; } = string.Empty;
|
||||
public string MoodlesData { get; set; } = string.Empty;
|
||||
public string PetNamesData { get; set; } = string.Empty;
|
||||
}
|
11
MareSynchronosAPI/Data/ChatMessage.cs
Normal file
11
MareSynchronosAPI/Data/ChatMessage.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using MessagePack;
|
||||
|
||||
namespace MareSynchronos.API.Data;
|
||||
|
||||
[MessagePackObject(keyAsPropertyName: true)]
|
||||
public record ChatMessage
|
||||
{
|
||||
public string SenderName { get; set; } = string.Empty;
|
||||
public uint SenderHomeWorldId { get; set; } = 0;
|
||||
public byte[] PayloadContent { get; set; } = [];
|
||||
}
|
19
MareSynchronosAPI/Data/Comparer/GroupDataComparer.cs
Normal file
19
MareSynchronosAPI/Data/Comparer/GroupDataComparer.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
namespace MareSynchronos.API.Data.Comparer;
|
||||
|
||||
public class GroupDataComparer : IEqualityComparer<GroupData>
|
||||
{
|
||||
public static GroupDataComparer Instance => _instance;
|
||||
private static GroupDataComparer _instance = new GroupDataComparer();
|
||||
|
||||
private GroupDataComparer() { }
|
||||
public bool Equals(GroupData? x, GroupData? y)
|
||||
{
|
||||
if (x == null || y == null) return false;
|
||||
return x.GID.Equals(y.GID, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
public int GetHashCode(GroupData obj)
|
||||
{
|
||||
return obj.GID.GetHashCode();
|
||||
}
|
||||
}
|
23
MareSynchronosAPI/Data/Comparer/GroupDtoComparer.cs
Normal file
23
MareSynchronosAPI/Data/Comparer/GroupDtoComparer.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using MareSynchronos.API.Dto.Group;
|
||||
|
||||
namespace MareSynchronos.API.Data.Comparer;
|
||||
|
||||
|
||||
public class GroupDtoComparer : IEqualityComparer<GroupDto>
|
||||
{
|
||||
public static GroupDtoComparer Instance => _instance;
|
||||
private static GroupDtoComparer _instance = new GroupDtoComparer();
|
||||
|
||||
private GroupDtoComparer() { }
|
||||
|
||||
public bool Equals(GroupDto? x, GroupDto? y)
|
||||
{
|
||||
if (x == null || y == null) return false;
|
||||
return x.GID.Equals(y.GID, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
public int GetHashCode(GroupDto obj)
|
||||
{
|
||||
return obj.Group.GID.GetHashCode();
|
||||
}
|
||||
}
|
20
MareSynchronosAPI/Data/Comparer/GroupPairDtoComparer.cs
Normal file
20
MareSynchronosAPI/Data/Comparer/GroupPairDtoComparer.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using MareSynchronos.API.Dto.Group;
|
||||
|
||||
namespace MareSynchronos.API.Data.Comparer;
|
||||
|
||||
public class GroupPairDtoComparer : IEqualityComparer<GroupPairDto>
|
||||
{
|
||||
public static GroupPairDtoComparer Instance => _instance;
|
||||
private static GroupPairDtoComparer _instance = new();
|
||||
private GroupPairDtoComparer() { }
|
||||
public bool Equals(GroupPairDto? x, GroupPairDto? y)
|
||||
{
|
||||
if (x == null || y == null) return false;
|
||||
return x.GID.Equals(y.GID, StringComparison.Ordinal) && x.UID.Equals(y.UID, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
public int GetHashCode(GroupPairDto obj)
|
||||
{
|
||||
return HashCode.Combine(obj.Group.GID.GetHashCode(), obj.User.UID.GetHashCode());
|
||||
}
|
||||
}
|
20
MareSynchronosAPI/Data/Comparer/UserDataComparer.cs
Normal file
20
MareSynchronosAPI/Data/Comparer/UserDataComparer.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
namespace MareSynchronos.API.Data.Comparer;
|
||||
|
||||
public class UserDataComparer : IEqualityComparer<UserData>
|
||||
{
|
||||
public static UserDataComparer Instance => _instance;
|
||||
private static UserDataComparer _instance = new();
|
||||
|
||||
private UserDataComparer() { }
|
||||
|
||||
public bool Equals(UserData? x, UserData? y)
|
||||
{
|
||||
if (x == null || y == null) return false;
|
||||
return x.UID.Equals(y.UID, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
public int GetHashCode(UserData obj)
|
||||
{
|
||||
return obj.UID.GetHashCode();
|
||||
}
|
||||
}
|
20
MareSynchronosAPI/Data/Comparer/UserDtoComparer.cs
Normal file
20
MareSynchronosAPI/Data/Comparer/UserDtoComparer.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using MareSynchronos.API.Dto.User;
|
||||
|
||||
namespace MareSynchronos.API.Data.Comparer;
|
||||
|
||||
public class UserDtoComparer : IEqualityComparer<UserDto>
|
||||
{
|
||||
public static UserDtoComparer Instance => _instance;
|
||||
private static UserDtoComparer _instance = new();
|
||||
private UserDtoComparer() { }
|
||||
public bool Equals(UserDto? x, UserDto? y)
|
||||
{
|
||||
if (x == null || y == null) return false;
|
||||
return x.User.UID.Equals(y.User.UID, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
public int GetHashCode(UserDto obj)
|
||||
{
|
||||
return obj.User.UID.GetHashCode();
|
||||
}
|
||||
}
|
11
MareSynchronosAPI/Data/Enum/GroupPermissions.cs
Normal file
11
MareSynchronosAPI/Data/Enum/GroupPermissions.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace MareSynchronos.API.Data.Enum;
|
||||
|
||||
[Flags]
|
||||
public enum GroupPermissions
|
||||
{
|
||||
NoneSet = 0x0,
|
||||
DisableAnimations = 0x1,
|
||||
DisableSounds = 0x2,
|
||||
DisableInvites = 0x4,
|
||||
DisableVFX = 0x8,
|
||||
}
|
9
MareSynchronosAPI/Data/Enum/GroupUserInfo.cs
Normal file
9
MareSynchronosAPI/Data/Enum/GroupUserInfo.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace MareSynchronos.API.Data.Enum;
|
||||
|
||||
[Flags]
|
||||
public enum GroupUserInfo
|
||||
{
|
||||
None = 0x0,
|
||||
IsModerator = 0x2,
|
||||
IsPinned = 0x4
|
||||
}
|
11
MareSynchronosAPI/Data/Enum/GroupUserPermissions.cs
Normal file
11
MareSynchronosAPI/Data/Enum/GroupUserPermissions.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace MareSynchronos.API.Data.Enum;
|
||||
|
||||
[Flags]
|
||||
public enum GroupUserPermissions
|
||||
{
|
||||
NoneSet = 0x0,
|
||||
Paused = 0x1,
|
||||
DisableAnimations = 0x2,
|
||||
DisableSounds = 0x4,
|
||||
DisableVFX = 0x8,
|
||||
}
|
8
MareSynchronosAPI/Data/Enum/MessageSeverity.cs
Normal file
8
MareSynchronosAPI/Data/Enum/MessageSeverity.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace MareSynchronos.API.Data.Enum;
|
||||
|
||||
public enum MessageSeverity
|
||||
{
|
||||
Information,
|
||||
Warning,
|
||||
Error
|
||||
}
|
9
MareSynchronosAPI/Data/Enum/ObjectKind.cs
Normal file
9
MareSynchronosAPI/Data/Enum/ObjectKind.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace MareSynchronos.API.Data.Enum;
|
||||
|
||||
public enum ObjectKind
|
||||
{
|
||||
Player = 0,
|
||||
MinionOrMount = 1,
|
||||
Companion = 2,
|
||||
Pet = 3,
|
||||
}
|
12
MareSynchronosAPI/Data/Enum/UserPermissions.cs
Normal file
12
MareSynchronosAPI/Data/Enum/UserPermissions.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace MareSynchronos.API.Data.Enum;
|
||||
|
||||
[Flags]
|
||||
public enum UserPermissions
|
||||
{
|
||||
NoneSet = 0,
|
||||
Paired = 1,
|
||||
Paused = 2,
|
||||
DisableAnimations = 4,
|
||||
DisableSounds = 8,
|
||||
DisableVFX = 16,
|
||||
}
|
@@ -0,0 +1,50 @@
|
||||
using MareSynchronos.API.Data.Enum;
|
||||
|
||||
namespace MareSynchronos.API.Data.Extensions;
|
||||
|
||||
public static class GroupPermissionsExtensions
|
||||
{
|
||||
public static bool IsDisableAnimations(this GroupPermissions perm)
|
||||
{
|
||||
return perm.HasFlag(GroupPermissions.DisableAnimations);
|
||||
}
|
||||
|
||||
public static bool IsDisableSounds(this GroupPermissions perm)
|
||||
{
|
||||
return perm.HasFlag(GroupPermissions.DisableSounds);
|
||||
}
|
||||
|
||||
public static bool IsDisableInvites(this GroupPermissions perm)
|
||||
{
|
||||
return perm.HasFlag(GroupPermissions.DisableInvites);
|
||||
}
|
||||
|
||||
public static bool IsDisableVFX(this GroupPermissions perm)
|
||||
{
|
||||
return perm.HasFlag(GroupPermissions.DisableVFX);
|
||||
}
|
||||
|
||||
public static void SetDisableAnimations(this ref GroupPermissions perm, bool set)
|
||||
{
|
||||
if (set) perm |= GroupPermissions.DisableAnimations;
|
||||
else perm &= ~GroupPermissions.DisableAnimations;
|
||||
}
|
||||
|
||||
public static void SetDisableSounds(this ref GroupPermissions perm, bool set)
|
||||
{
|
||||
if (set) perm |= GroupPermissions.DisableSounds;
|
||||
else perm &= ~GroupPermissions.DisableSounds;
|
||||
}
|
||||
|
||||
public static void SetDisableInvites(this ref GroupPermissions perm, bool set)
|
||||
{
|
||||
if (set) perm |= GroupPermissions.DisableInvites;
|
||||
else perm &= ~GroupPermissions.DisableInvites;
|
||||
}
|
||||
|
||||
public static void SetDisableVFX(this ref GroupPermissions perm, bool set)
|
||||
{
|
||||
if (set) perm |= GroupPermissions.DisableVFX;
|
||||
else perm &= ~GroupPermissions.DisableVFX;
|
||||
}
|
||||
}
|
28
MareSynchronosAPI/Data/Extensions/GroupUserInfoExtensions.cs
Normal file
28
MareSynchronosAPI/Data/Extensions/GroupUserInfoExtensions.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using MareSynchronos.API.Data.Enum;
|
||||
|
||||
namespace MareSynchronos.API.Data.Extensions;
|
||||
|
||||
public static class GroupUserInfoExtensions
|
||||
{
|
||||
public static bool IsModerator(this GroupUserInfo info)
|
||||
{
|
||||
return info.HasFlag(GroupUserInfo.IsModerator);
|
||||
}
|
||||
|
||||
public static bool IsPinned(this GroupUserInfo info)
|
||||
{
|
||||
return info.HasFlag(GroupUserInfo.IsPinned);
|
||||
}
|
||||
|
||||
public static void SetModerator(this ref GroupUserInfo info, bool isModerator)
|
||||
{
|
||||
if (isModerator) info |= GroupUserInfo.IsModerator;
|
||||
else info &= ~GroupUserInfo.IsModerator;
|
||||
}
|
||||
|
||||
public static void SetPinned(this ref GroupUserInfo info, bool isPinned)
|
||||
{
|
||||
if (isPinned) info |= GroupUserInfo.IsPinned;
|
||||
else info &= ~GroupUserInfo.IsPinned;
|
||||
}
|
||||
}
|
@@ -0,0 +1,50 @@
|
||||
using MareSynchronos.API.Data.Enum;
|
||||
|
||||
namespace MareSynchronos.API.Data.Extensions;
|
||||
|
||||
public static class GroupUserPermissionsExtensions
|
||||
{
|
||||
public static bool IsDisableAnimations(this GroupUserPermissions perm)
|
||||
{
|
||||
return perm.HasFlag(GroupUserPermissions.DisableAnimations);
|
||||
}
|
||||
|
||||
public static bool IsDisableSounds(this GroupUserPermissions perm)
|
||||
{
|
||||
return perm.HasFlag(GroupUserPermissions.DisableSounds);
|
||||
}
|
||||
|
||||
public static bool IsPaused(this GroupUserPermissions perm)
|
||||
{
|
||||
return perm.HasFlag(GroupUserPermissions.Paused);
|
||||
}
|
||||
|
||||
public static bool IsDisableVFX(this GroupUserPermissions perm)
|
||||
{
|
||||
return perm.HasFlag(GroupUserPermissions.DisableVFX);
|
||||
}
|
||||
|
||||
public static void SetDisableAnimations(this ref GroupUserPermissions perm, bool set)
|
||||
{
|
||||
if (set) perm |= GroupUserPermissions.DisableAnimations;
|
||||
else perm &= ~GroupUserPermissions.DisableAnimations;
|
||||
}
|
||||
|
||||
public static void SetDisableSounds(this ref GroupUserPermissions perm, bool set)
|
||||
{
|
||||
if (set) perm |= GroupUserPermissions.DisableSounds;
|
||||
else perm &= ~GroupUserPermissions.DisableSounds;
|
||||
}
|
||||
|
||||
public static void SetPaused(this ref GroupUserPermissions perm, bool set)
|
||||
{
|
||||
if (set) perm |= GroupUserPermissions.Paused;
|
||||
else perm &= ~GroupUserPermissions.Paused;
|
||||
}
|
||||
|
||||
public static void SetDisableVFX(this ref GroupUserPermissions perm, bool set)
|
||||
{
|
||||
if (set) perm |= GroupUserPermissions.DisableVFX;
|
||||
else perm &= ~GroupUserPermissions.DisableVFX;
|
||||
}
|
||||
}
|
@@ -0,0 +1,61 @@
|
||||
using MareSynchronos.API.Data.Enum;
|
||||
|
||||
namespace MareSynchronos.API.Data.Extensions;
|
||||
|
||||
public static class UserPermissionsExtensions
|
||||
{
|
||||
public static bool IsPaired(this UserPermissions perm)
|
||||
{
|
||||
return perm.HasFlag(UserPermissions.Paired);
|
||||
}
|
||||
|
||||
public static bool IsPaused(this UserPermissions perm)
|
||||
{
|
||||
return perm.HasFlag(UserPermissions.Paused);
|
||||
}
|
||||
|
||||
public static bool IsDisableAnimations(this UserPermissions perm)
|
||||
{
|
||||
return perm.HasFlag(UserPermissions.DisableAnimations);
|
||||
}
|
||||
|
||||
public static bool IsDisableSounds(this UserPermissions perm)
|
||||
{
|
||||
return perm.HasFlag(UserPermissions.DisableSounds);
|
||||
}
|
||||
|
||||
public static bool IsDisableVFX(this UserPermissions perm)
|
||||
{
|
||||
return perm.HasFlag(UserPermissions.DisableVFX);
|
||||
}
|
||||
|
||||
public static void SetPaired(this ref UserPermissions perm, bool paired)
|
||||
{
|
||||
if (paired) perm |= UserPermissions.Paired;
|
||||
else perm &= ~UserPermissions.Paired;
|
||||
}
|
||||
|
||||
public static void SetPaused(this ref UserPermissions perm, bool paused)
|
||||
{
|
||||
if (paused) perm |= UserPermissions.Paused;
|
||||
else perm &= ~UserPermissions.Paused;
|
||||
}
|
||||
|
||||
public static void SetDisableAnimations(this ref UserPermissions perm, bool set)
|
||||
{
|
||||
if (set) perm |= UserPermissions.DisableAnimations;
|
||||
else perm &= ~UserPermissions.DisableAnimations;
|
||||
}
|
||||
|
||||
public static void SetDisableSounds(this ref UserPermissions perm, bool set)
|
||||
{
|
||||
if (set) perm |= UserPermissions.DisableSounds;
|
||||
else perm &= ~UserPermissions.DisableSounds;
|
||||
}
|
||||
|
||||
public static void SetDisableVFX(this ref UserPermissions perm, bool set)
|
||||
{
|
||||
if (set) perm |= UserPermissions.DisableVFX;
|
||||
else perm &= ~UserPermissions.DisableVFX;
|
||||
}
|
||||
}
|
30
MareSynchronosAPI/Data/FileReplacementData.cs
Normal file
30
MareSynchronosAPI/Data/FileReplacementData.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
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
|
||||
{
|
||||
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;
|
||||
}
|
10
MareSynchronosAPI/Data/GroupData.cs
Normal file
10
MareSynchronosAPI/Data/GroupData.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using MessagePack;
|
||||
|
||||
namespace MareSynchronos.API.Data;
|
||||
|
||||
[MessagePackObject(keyAsPropertyName: true)]
|
||||
public record GroupData(string GID, string? Alias = null)
|
||||
{
|
||||
[IgnoreMember]
|
||||
public string AliasOrGID => string.IsNullOrWhiteSpace(Alias) ? GID : Alias;
|
||||
}
|
14
MareSynchronosAPI/Data/SignedChatMessage.cs
Normal file
14
MareSynchronosAPI/Data/SignedChatMessage.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using MessagePack;
|
||||
|
||||
namespace MareSynchronos.API.Data;
|
||||
|
||||
[MessagePackObject(keyAsPropertyName: true)]
|
||||
public record SignedChatMessage(ChatMessage Message, UserData Sender) : ChatMessage(Message)
|
||||
{
|
||||
// Sender and timestamp are set by the server
|
||||
public UserData Sender { get; set; } = Sender;
|
||||
public long Timestamp { get; set; } = 0;
|
||||
// Signature is generated by the server as SHA256(Sender.UID | Timestamp | Destination | Message)
|
||||
// Where Destination is either the receiver's UID, or the group GID
|
||||
public string Signature { get; set; } = string.Empty;
|
||||
}
|
10
MareSynchronosAPI/Data/UserData.cs
Normal file
10
MareSynchronosAPI/Data/UserData.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using MessagePack;
|
||||
|
||||
namespace MareSynchronos.API.Data;
|
||||
|
||||
[MessagePackObject(keyAsPropertyName: true)]
|
||||
public record UserData(string UID, string? Alias = null)
|
||||
{
|
||||
[IgnoreMember]
|
||||
public string AliasOrUID => string.IsNullOrWhiteSpace(Alias) ? UID : Alias;
|
||||
}
|
Reference in New Issue
Block a user