Major API rework for paradigm change (#10)
* start with group permissions implementation * refactor group dto stuff * adjustments to api as necessary from client * more api refactor for UserData * use implicit usings and file scoped namespaces * fix userpermissionsextensions * fix extenions * add more comparers * adjust comparers * remove admin stuff (tbd migration to discord bot) * adjust extensions * code style for api --------- Co-authored-by: rootdarkarchon <root.darkarchon@outlook.com>
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MareSynchronos.API
|
||||
{
|
||||
public record BannedGroupUserDto
|
||||
{
|
||||
public string UID { get; set; }
|
||||
public string Reason { get; set; }
|
||||
public DateTime BannedOn { get; set; }
|
||||
public string BannedBy { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
namespace MareSynchronos.API
|
||||
{
|
||||
public record BannedUserDto
|
||||
{
|
||||
public string CharacterHash { get; set; }
|
||||
public string Reason { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace MareSynchronos.API
|
||||
{
|
||||
public class CharacterCacheDto
|
||||
{
|
||||
public Dictionary<ObjectKind, List<FileReplacementDto>> FileReplacements { get; set; } = new();
|
||||
public Dictionary<ObjectKind, string> GlamourerData { get; set; } = new();
|
||||
public string ManipulationData { get; set; } = string.Empty;
|
||||
public string CustomizePlusData { get; set; } = string.Empty;
|
||||
public override string ToString()
|
||||
{
|
||||
return GetHashCode() + Environment.NewLine + "Manip:" + ManipulationData + Environment.NewLine
|
||||
+ string.Join(Environment.NewLine, GlamourerData.Select(g => g.Key + ":" + g.Value)) + Environment.NewLine
|
||||
+ string.Join(Environment.NewLine, FileReplacements.Select(g => g.Key + Environment.NewLine + string.Join(Environment.NewLine, g.Value)))
|
||||
+ Environment.NewLine + "CustomizePlus:" + CustomizePlusData;
|
||||
}
|
||||
|
||||
public float HeelsOffset { get; set; } = 0.0f;
|
||||
|
||||
public static int GetOrderIndependentHashCode<T>(IEnumerable<T> source)
|
||||
{
|
||||
int hash = 0;
|
||||
foreach (T element in source)
|
||||
{
|
||||
hash = unchecked(hash +
|
||||
EqualityComparer<T>.Default.GetHashCode(element));
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
int fileReplacementsHash = 0;
|
||||
foreach (var item in FileReplacements)
|
||||
{
|
||||
foreach (var values in item.Value)
|
||||
{
|
||||
fileReplacementsHash = unchecked(fileReplacementsHash + values.GetHashCode());
|
||||
}
|
||||
}
|
||||
|
||||
int glamourerHash = 0;
|
||||
foreach (var item in GlamourerData)
|
||||
{
|
||||
glamourerHash = unchecked(glamourerHash + item.Value.GetHashCode());
|
||||
}
|
||||
|
||||
return HashCode.Combine(fileReplacementsHash, glamourerHash, ManipulationData, HeelsOffset, CustomizePlusData);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace MareSynchronos.API
|
||||
{
|
||||
public record ClientPairDto
|
||||
{
|
||||
public string OtherUID { get; set; }
|
||||
public string VanityUID { get; set; }
|
||||
public bool IsPaused { get; set; }
|
||||
public bool IsSynced { get; set; }
|
||||
public bool IsPausedFromOthers { get; set; }
|
||||
public bool IsRemoved { get; set; }
|
||||
public bool AllowReceiveMessages { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
namespace MareSynchronos.API
|
||||
{
|
||||
public record ConnectionDto
|
||||
{
|
||||
public int ServerVersion { get; set; }
|
||||
public bool IsAdmin { get; set; }
|
||||
public bool IsModerator { get; set; }
|
||||
public string UID { get; set; }
|
||||
public ServerInfoDto ServerInfo { get; set; }
|
||||
}
|
||||
|
||||
public record ServerInfoDto
|
||||
{
|
||||
public string ShardName { get; set; }
|
||||
public int MaxGroupUserCount { get; set; }
|
||||
public int MaxGroupsCreatedByUser { get; set; }
|
||||
public int MaxGroupsJoinedByUser { get; set; }
|
||||
}
|
||||
}
|
||||
12
MareSynchronosAPI/Data/CharacterData.cs
Normal file
12
MareSynchronosAPI/Data/CharacterData.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using MareSynchronos.API.Data.Enum;
|
||||
|
||||
namespace MareSynchronos.API.Data;
|
||||
|
||||
public class CharacterData : HashableDataBase
|
||||
{
|
||||
public Dictionary<ObjectKind, List<FileReplacementData>> FileReplacements { get; set; } = new();
|
||||
public Dictionary<ObjectKind, string> GlamourerData { get; set; } = new();
|
||||
public string ManipulationData { get; set; } = string.Empty;
|
||||
public string CustomizePlusData { get; set; } = string.Empty;
|
||||
public float HeelsOffset { get; set; } = 0.0f;
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
10
MareSynchronosAPI/Data/Enum/GroupPermissions.cs
Normal file
10
MareSynchronosAPI/Data/Enum/GroupPermissions.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace MareSynchronos.API.Data.Enum;
|
||||
|
||||
[Flags]
|
||||
public enum GroupPermissions
|
||||
{
|
||||
NoneSet = 0x0,
|
||||
DisableAnimations = 0x1,
|
||||
DisableSounds = 0x2,
|
||||
DisableInvites = 0x4
|
||||
}
|
||||
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
|
||||
}
|
||||
10
MareSynchronosAPI/Data/Enum/GroupUserPermissions.cs
Normal file
10
MareSynchronosAPI/Data/Enum/GroupUserPermissions.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace MareSynchronos.API.Data.Enum;
|
||||
|
||||
[Flags]
|
||||
public enum GroupUserPermissions
|
||||
{
|
||||
NoneSet = 0x0,
|
||||
Paused = 0x1,
|
||||
DisableAnimations = 0x2,
|
||||
DisableSounds = 0x4,
|
||||
}
|
||||
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,
|
||||
}
|
||||
9
MareSynchronosAPI/Data/Enum/UserPermissions.cs
Normal file
9
MareSynchronosAPI/Data/Enum/UserPermissions.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace MareSynchronos.API.Data.Enum;
|
||||
|
||||
[Flags]
|
||||
public enum UserPermissions
|
||||
{
|
||||
NoneSet,
|
||||
Paired,
|
||||
Paused
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
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 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;
|
||||
}
|
||||
}
|
||||
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,39 @@
|
||||
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 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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
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 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;
|
||||
}
|
||||
}
|
||||
8
MareSynchronosAPI/Data/FileReplacementData.cs
Normal file
8
MareSynchronosAPI/Data/FileReplacementData.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace MareSynchronos.API.Data;
|
||||
|
||||
public class FileReplacementData : HashableDataBase
|
||||
{
|
||||
public string[] GamePaths { get; set; } = Array.Empty<string>();
|
||||
public string Hash { get; set; } = string.Empty;
|
||||
public string FileSwapPath { get; set; } = string.Empty;
|
||||
}
|
||||
6
MareSynchronosAPI/Data/GroupData.cs
Normal file
6
MareSynchronosAPI/Data/GroupData.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace MareSynchronos.API.Data;
|
||||
|
||||
public record GroupData(string GID, string? Alias = null)
|
||||
{
|
||||
public string AliasOrGID => Alias ?? GID;
|
||||
}
|
||||
20
MareSynchronosAPI/Data/HashableDataBase.cs
Normal file
20
MareSynchronosAPI/Data/HashableDataBase.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.Security.Cryptography;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace MareSynchronos.API.Data;
|
||||
|
||||
public abstract class HashableDataBase
|
||||
{
|
||||
protected HashableDataBase()
|
||||
{
|
||||
DataHash = new(() =>
|
||||
{
|
||||
var json = JsonConvert.SerializeObject(this, Formatting.None);
|
||||
var hash = SHA256.HashData(System.Text.Encoding.UTF8.GetBytes(json));
|
||||
return BitConverter.ToString(hash).ToUpperInvariant().Replace("-", "", StringComparison.OrdinalIgnoreCase);
|
||||
});
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public Lazy<string> DataHash { get; }
|
||||
}
|
||||
6
MareSynchronosAPI/Data/UserData.cs
Normal file
6
MareSynchronosAPI/Data/UserData.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace MareSynchronos.API.Data;
|
||||
|
||||
public record UserData(string UID, string? Alias = null)
|
||||
{
|
||||
public string AliasOrUID => Alias ?? UID;
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
namespace MareSynchronos.API
|
||||
{
|
||||
public record DownloadFileDto : ITransferFileDto
|
||||
{
|
||||
public bool FileExists { get; set; } = true;
|
||||
public string Hash { get; set; } = string.Empty;
|
||||
public string Url { get; set; }
|
||||
public long Size { get; set; } = 0;
|
||||
public bool IsForbidden { get; set; } = false;
|
||||
public string ForbiddenBy { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
19
MareSynchronosAPI/Dto/ConnectionDto.cs
Normal file
19
MareSynchronosAPI/Dto/ConnectionDto.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using MareSynchronos.API.Data;
|
||||
|
||||
namespace MareSynchronos.API.Dto;
|
||||
|
||||
public record ConnectionDto(UserData User)
|
||||
{
|
||||
public int ServerVersion { get; set; }
|
||||
public bool IsAdmin { get; set; }
|
||||
public bool IsModerator { get; set; }
|
||||
public ServerInfo ServerInfo { get; set; } = new();
|
||||
}
|
||||
|
||||
public record ServerInfo
|
||||
{
|
||||
public string ShardName { get; set; } = string.Empty;
|
||||
public int MaxGroupUserCount { get; set; }
|
||||
public int MaxGroupsCreatedByUser { get; set; }
|
||||
public int MaxGroupsJoinedByUser { get; set; }
|
||||
}
|
||||
11
MareSynchronosAPI/Dto/Files/DownloadFileDto.cs
Normal file
11
MareSynchronosAPI/Dto/Files/DownloadFileDto.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace MareSynchronos.API.Dto.Files;
|
||||
|
||||
public record DownloadFileDto : ITransferFileDto
|
||||
{
|
||||
public bool FileExists { get; set; } = true;
|
||||
public string Hash { get; set; } = string.Empty;
|
||||
public string Url { get; set; } = string.Empty;
|
||||
public long Size { get; set; } = 0;
|
||||
public bool IsForbidden { get; set; } = false;
|
||||
public string ForbiddenBy { get; set; } = string.Empty;
|
||||
}
|
||||
7
MareSynchronosAPI/Dto/Files/ForbiddenUploadsDto.cs
Normal file
7
MareSynchronosAPI/Dto/Files/ForbiddenUploadsDto.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace MareSynchronos.API.Dto.Files;
|
||||
|
||||
public record ForbiddenFileDto
|
||||
{
|
||||
public string Hash { get; set; } = string.Empty;
|
||||
public string ForbiddenBy { get; set; } = string.Empty;
|
||||
}
|
||||
8
MareSynchronosAPI/Dto/Files/ITransferFileDto.cs
Normal file
8
MareSynchronosAPI/Dto/Files/ITransferFileDto.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace MareSynchronos.API.Dto.Files;
|
||||
|
||||
public interface ITransferFileDto
|
||||
{
|
||||
string Hash { get; set; }
|
||||
bool IsForbidden { get; set; }
|
||||
string ForbiddenBy { get; set; }
|
||||
}
|
||||
8
MareSynchronosAPI/Dto/Files/UploadFileDto.cs
Normal file
8
MareSynchronosAPI/Dto/Files/UploadFileDto.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace MareSynchronos.API.Dto.Files;
|
||||
|
||||
public record UploadFileDto : ITransferFileDto
|
||||
{
|
||||
public string Hash { get; set; } = string.Empty;
|
||||
public bool IsForbidden { get; set; } = false;
|
||||
public string ForbiddenBy { get; set; } = string.Empty;
|
||||
}
|
||||
17
MareSynchronosAPI/Dto/Group/BannedGroupUserDto.cs
Normal file
17
MareSynchronosAPI/Dto/Group/BannedGroupUserDto.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using MareSynchronos.API.Data;
|
||||
|
||||
namespace MareSynchronos.API.Dto.Group;
|
||||
|
||||
public record BannedGroupUserDto : GroupPairDto
|
||||
{
|
||||
public BannedGroupUserDto(GroupData group, UserData user, string reason, DateTime bannedOn, string bannedBy) : base(group, user)
|
||||
{
|
||||
Reason = reason;
|
||||
BannedOn = bannedOn;
|
||||
BannedBy = bannedBy;
|
||||
}
|
||||
|
||||
public string Reason { get; set; }
|
||||
public DateTime BannedOn { get; set; }
|
||||
public string BannedBy { get; set; }
|
||||
}
|
||||
11
MareSynchronosAPI/Dto/Group/GroupDto.cs
Normal file
11
MareSynchronosAPI/Dto/Group/GroupDto.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using MareSynchronos.API.Data;
|
||||
|
||||
namespace MareSynchronos.API.Dto.Group;
|
||||
|
||||
public record GroupDto(GroupData Group)
|
||||
{
|
||||
public GroupData Group { get; set; } = Group;
|
||||
public string GID => Group.GID;
|
||||
public string? GroupAlias => Group.Alias;
|
||||
public string GroupAliasOrGID => Group.AliasOrGID;
|
||||
}
|
||||
10
MareSynchronosAPI/Dto/Group/GroupFullInfoDto.cs
Normal file
10
MareSynchronosAPI/Dto/Group/GroupFullInfoDto.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using MareSynchronos.API.Data;
|
||||
using MareSynchronos.API.Data.Enum;
|
||||
|
||||
namespace MareSynchronos.API.Dto.Group;
|
||||
|
||||
public record GroupFullInfoDto(GroupData Group, UserData Owner, GroupPermissions GroupPermissions, GroupUserPermissions GroupUserPermissions, GroupUserInfo GroupUserInfo) : GroupInfoDto(Group, Owner, GroupPermissions)
|
||||
{
|
||||
public GroupUserPermissions GroupUserPermissions { get; set; } = GroupUserPermissions;
|
||||
public GroupUserInfo GroupUserInfo { get; set; } = GroupUserInfo;
|
||||
}
|
||||
14
MareSynchronosAPI/Dto/Group/GroupInfoDto.cs
Normal file
14
MareSynchronosAPI/Dto/Group/GroupInfoDto.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using MareSynchronos.API.Data;
|
||||
using MareSynchronos.API.Data.Enum;
|
||||
|
||||
namespace MareSynchronos.API.Dto.Group;
|
||||
|
||||
public record GroupInfoDto(GroupData Group, UserData Owner, GroupPermissions GroupPermissions) : GroupDto(Group)
|
||||
{
|
||||
public GroupPermissions GroupPermissions { get; set; } = GroupPermissions;
|
||||
public UserData Owner { get; set; } = Owner;
|
||||
|
||||
public string OwnerUID => Owner.UID;
|
||||
public string? OwnerAlias => Owner.Alias;
|
||||
public string OwnerAliasOrUID => Owner.AliasOrUID;
|
||||
}
|
||||
10
MareSynchronosAPI/Dto/Group/GroupPairDto.cs
Normal file
10
MareSynchronosAPI/Dto/Group/GroupPairDto.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using MareSynchronos.API.Data;
|
||||
|
||||
namespace MareSynchronos.API.Dto.Group;
|
||||
|
||||
public record GroupPairDto(GroupData Group, UserData User) : GroupDto(Group)
|
||||
{
|
||||
public string UID => User.UID;
|
||||
public string? UserAlias => User.Alias;
|
||||
public string UserAliasOrUID => User.AliasOrUID;
|
||||
}
|
||||
10
MareSynchronosAPI/Dto/Group/GroupPairFullInfoDto.cs
Normal file
10
MareSynchronosAPI/Dto/Group/GroupPairFullInfoDto.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using MareSynchronos.API.Data;
|
||||
using MareSynchronos.API.Data.Enum;
|
||||
|
||||
namespace MareSynchronos.API.Dto.Group;
|
||||
|
||||
public record GroupPairFullInfoDto(GroupData Group, UserData User, GroupUserInfo GroupPairStatusInfo, GroupUserPermissions GroupUserPermissions) : GroupPairDto(Group, User)
|
||||
{
|
||||
public GroupUserInfo GroupPairStatusInfo { get; set; } = GroupPairStatusInfo;
|
||||
public GroupUserPermissions GroupUserPermissions { get; set; } = GroupUserPermissions;
|
||||
}
|
||||
6
MareSynchronosAPI/Dto/Group/GroupPairUserInfoDto.cs
Normal file
6
MareSynchronosAPI/Dto/Group/GroupPairUserInfoDto.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
using MareSynchronos.API.Data;
|
||||
using MareSynchronos.API.Data.Enum;
|
||||
|
||||
namespace MareSynchronos.API.Dto.Group;
|
||||
|
||||
public record GroupPairUserInfoDto(GroupData Group, UserData User, GroupUserInfo GroupUserInfo) : GroupPairDto(Group, User);
|
||||
@@ -0,0 +1,6 @@
|
||||
using MareSynchronos.API.Data;
|
||||
using MareSynchronos.API.Data.Enum;
|
||||
|
||||
namespace MareSynchronos.API.Dto.Group;
|
||||
|
||||
public record GroupPairUserPermissionDto(GroupData Group, UserData User, GroupUserPermissions GroupPairPermissions) : GroupPairDto(Group, User);
|
||||
5
MareSynchronosAPI/Dto/Group/GroupPasswordDto.cs
Normal file
5
MareSynchronosAPI/Dto/Group/GroupPasswordDto.cs
Normal file
@@ -0,0 +1,5 @@
|
||||
using MareSynchronos.API.Data;
|
||||
|
||||
namespace MareSynchronos.API.Dto.Group;
|
||||
|
||||
public record GroupPasswordDto(GroupData Group, string Password) : GroupDto(Group);
|
||||
6
MareSynchronosAPI/Dto/Group/GroupPermissionDto.cs
Normal file
6
MareSynchronosAPI/Dto/Group/GroupPermissionDto.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
using MareSynchronos.API.Data;
|
||||
using MareSynchronos.API.Data.Enum;
|
||||
|
||||
namespace MareSynchronos.API.Dto.Group;
|
||||
|
||||
public record GroupPermissionDto(GroupData Group, GroupPermissions Permissions) : GroupDto(Group);
|
||||
6
MareSynchronosAPI/Dto/SystemInfoDto.cs
Normal file
6
MareSynchronosAPI/Dto/SystemInfoDto.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace MareSynchronos.API.Dto;
|
||||
|
||||
public record SystemInfoDto
|
||||
{
|
||||
public int OnlineUsers { get; set; }
|
||||
}
|
||||
5
MareSynchronosAPI/Dto/User/OnlineUserCharaDataDto.cs
Normal file
5
MareSynchronosAPI/Dto/User/OnlineUserCharaDataDto.cs
Normal file
@@ -0,0 +1,5 @@
|
||||
using MareSynchronos.API.Data;
|
||||
|
||||
namespace MareSynchronos.API.Dto.User;
|
||||
|
||||
public record OnlineUserCharaDataDto(UserData User, CharacterData CharaData) : UserDto(User);
|
||||
5
MareSynchronosAPI/Dto/User/OnlineUserIdentDto.cs
Normal file
5
MareSynchronosAPI/Dto/User/OnlineUserIdentDto.cs
Normal file
@@ -0,0 +1,5 @@
|
||||
using MareSynchronos.API.Data;
|
||||
|
||||
namespace MareSynchronos.API.Dto.User;
|
||||
|
||||
public record OnlineUserIdentDto(UserData User, string Ident) : UserDto(User);
|
||||
5
MareSynchronosAPI/Dto/User/UserCharaDataMessageDto.cs
Normal file
5
MareSynchronosAPI/Dto/User/UserCharaDataMessageDto.cs
Normal file
@@ -0,0 +1,5 @@
|
||||
using MareSynchronos.API.Data;
|
||||
|
||||
namespace MareSynchronos.API.Dto.User;
|
||||
|
||||
public record UserCharaDataMessageDto(List<UserData> Recipients, CharacterData CharaData);
|
||||
5
MareSynchronosAPI/Dto/User/UserDto.cs
Normal file
5
MareSynchronosAPI/Dto/User/UserDto.cs
Normal file
@@ -0,0 +1,5 @@
|
||||
using MareSynchronos.API.Data;
|
||||
|
||||
namespace MareSynchronos.API.Dto.User;
|
||||
|
||||
public record UserDto(UserData User);
|
||||
10
MareSynchronosAPI/Dto/User/UserPairDto.cs
Normal file
10
MareSynchronosAPI/Dto/User/UserPairDto.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using MareSynchronos.API.Data;
|
||||
using MareSynchronos.API.Data.Enum;
|
||||
|
||||
namespace MareSynchronos.API.Dto.User;
|
||||
|
||||
public record UserPairDto(UserData User, UserPermissions OwnPermissions, UserPermissions OtherPermissions) : UserDto(User)
|
||||
{
|
||||
public UserPermissions OwnPermissions { get; set; } = OwnPermissions;
|
||||
public UserPermissions OtherPermissions { get; set; } = OtherPermissions;
|
||||
}
|
||||
6
MareSynchronosAPI/Dto/User/UserPermissionsDto.cs
Normal file
6
MareSynchronosAPI/Dto/User/UserPermissionsDto.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
using MareSynchronos.API.Data;
|
||||
using MareSynchronos.API.Data.Enum;
|
||||
|
||||
namespace MareSynchronos.API.Dto.User;
|
||||
|
||||
public record UserPermissionsDto(UserData User, UserPermissions Permissions) : UserDto(User);
|
||||
@@ -1,41 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace MareSynchronos.API
|
||||
{
|
||||
public class FileReplacementDto
|
||||
{
|
||||
public string[] GamePaths { get; set; } = Array.Empty<string>();
|
||||
public string Hash { get; set; }
|
||||
|
||||
public string FileSwapPath { get; set; } = string.Empty;
|
||||
|
||||
public override bool Equals(object? otherObj)
|
||||
{
|
||||
if (otherObj == null || otherObj is not FileReplacementDto other) return false;
|
||||
return Hash == other.Hash && Enumerable.SequenceEqual(GamePaths, other.GamePaths) && FileSwapPath == other.FileSwapPath;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(GetOrderIndependentHashCode(GamePaths), Hash, FileSwapPath);
|
||||
}
|
||||
|
||||
public static int GetOrderIndependentHashCode<T>(IEnumerable<T> source)
|
||||
{
|
||||
int hash = 0;
|
||||
foreach (T element in source)
|
||||
{
|
||||
hash = unchecked(hash +
|
||||
EqualityComparer<T>.Default.GetHashCode(element));
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Hash + ":" + string.Join(",", GamePaths) + "(" + FileSwapPath + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
namespace MareSynchronos.API
|
||||
{
|
||||
public record ForbiddenFileDto
|
||||
{
|
||||
public string Hash { get; set; }
|
||||
public string ForbiddenBy { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
namespace MareSynchronos.API
|
||||
{
|
||||
public record GroupCreatedDto
|
||||
{
|
||||
public string GID { get; set; }
|
||||
public string Password { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace MareSynchronos.API
|
||||
{
|
||||
public record GroupDto
|
||||
{
|
||||
public string GID { get; set; }
|
||||
public string? OwnedBy { get; set; }
|
||||
public bool? InvitesEnabled { get; set; }
|
||||
public bool? IsPaused { get; set; }
|
||||
public bool? IsDeleted { get; set; }
|
||||
public string? Alias { get; set; }
|
||||
public bool? IsModerator { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace MareSynchronos.API
|
||||
{
|
||||
public record GroupPairDto
|
||||
{
|
||||
public string GroupGID { get; set; }
|
||||
public string UserUID { get; set; }
|
||||
public string? UserAlias { get; set; }
|
||||
public bool? IsPaused { get; set; }
|
||||
public bool? IsRemoved { get; set; }
|
||||
public bool? IsPinned { get; set; }
|
||||
public bool? IsModerator { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MareSynchronos.API
|
||||
{
|
||||
public enum MessageSeverity
|
||||
{
|
||||
Information,
|
||||
Warning,
|
||||
Error
|
||||
}
|
||||
public interface IMareHub
|
||||
{
|
||||
const int ApiVersion = 20;
|
||||
const string Path = "/mare";
|
||||
|
||||
Task FilesAbortUpload();
|
||||
Task<List<OnlineUserDto>> AdminGetOnlineUsers();
|
||||
Task<bool> GroupChangePassword(string gid, string password);
|
||||
Task AdminChangeModeratorStatus(string uid, bool isModerator);
|
||||
Task GroupChangeOwnership(string gid, string uid);
|
||||
Task GroupChangePinned(string gid, string uid, bool isPinned);
|
||||
Task<bool> CheckClientHealth();
|
||||
Task GroupClear(string gid);
|
||||
Task<GroupCreatedDto> GroupCreate();
|
||||
Task UserDelete();
|
||||
Task FilesDeleteAll();
|
||||
Task AdminDeleteBannedUser(BannedUserDto dto);
|
||||
Task AdminDeleteForbiddenFile(ForbiddenFileDto dto);
|
||||
Task<List<BannedUserDto>> AdminGetBannedUsers();
|
||||
Task<List<DownloadFileDto>> FilesGetSizes(List<string> hashes);
|
||||
Task<List<ForbiddenFileDto>> AdminGetForbiddenFiles();
|
||||
Task<List<BannedGroupUserDto>> GroupGetBannedUsers(string gid);
|
||||
Task<List<GroupDto>> GroupsGetAll();
|
||||
Task<List<string>> UserGetOnlineCharacters();
|
||||
Task<List<ClientPairDto>> UserGetPairedClients();
|
||||
Task<List<GroupPairDto>> GroupsGetUsersInGroup(string gid);
|
||||
Task GroupBanUser(string gid, string uid, string reason);
|
||||
Task GroupChangeInviteState(string gid, bool enabled);
|
||||
Task GroupChangePauseState(string gid, bool isPaused);
|
||||
Task GroupDelete(string gid);
|
||||
Task<bool> GroupJoin(string gid, string password);
|
||||
Task GroupLeave(string gid);
|
||||
Task GroupRemoveUser(string gid, string uid);
|
||||
Task GroupUnbanUser(string gid, string uid);
|
||||
Task<List<string>> GroupCreateTempInvite(string gid, int amount);
|
||||
Task<ConnectionDto> GetConnectionDto();
|
||||
Task<bool> FilesIsUploadFinished();
|
||||
Task UserPushData(CharacterCacheDto characterCache, List<string> visibleCharacterIds);
|
||||
Task<List<UploadFileDto>> FilesSend(List<string> fileListHashes);
|
||||
Task UserAddPair(string uid);
|
||||
Task UserChangePairPauseStatus(string otherUserUid, bool isPaused);
|
||||
Task UserRemovePair(string otherUserUid);
|
||||
Task GroupSetModerator(string gid, string uid, bool isModerator);
|
||||
Task AdminUpdateOrAddBannedUser(BannedUserDto dto);
|
||||
Task AdminUpdateOrAddForbiddenFile(ForbiddenFileDto dto);
|
||||
Task FilesUploadStreamAsync(string hash, IAsyncEnumerable<byte[]> fileContent);
|
||||
Task Client_UserUpdateClientPairs(ClientPairDto clientPairDto);
|
||||
Task Client_UpdateSystemInfo(SystemInfoDto systemInfo);
|
||||
Task Client_UserReceiveCharacterData(CharacterCacheDto clientPairDto, string characterIdent);
|
||||
Task Client_UserChangePairedPlayer(string characterIdent, bool isOnline);
|
||||
Task Client_GroupChange(GroupDto groupDto);
|
||||
Task Client_GroupUserChange(GroupPairDto groupPairDto);
|
||||
Task Client_AdminForcedReconnect();
|
||||
Task Client_AdminDeleteBannedUser(BannedUserDto dto);
|
||||
Task Client_AdminDeleteForbiddenFile(ForbiddenFileDto dto);
|
||||
Task Client_AdminUpdateOrAddBannedUser(BannedUserDto dto);
|
||||
Task Client_AdminUpdateOrAddForbiddenFile(ForbiddenFileDto dto);
|
||||
Task Client_ReceiveServerMessage(MessageSeverity messageSeverity, string message);
|
||||
Task Client_DownloadReady(Guid requestId);
|
||||
}
|
||||
|
||||
public interface IMareHubClient : IMareHub
|
||||
{
|
||||
void OnUserUpdateClientPairs(Action<ClientPairDto> act);
|
||||
void OnUpdateSystemInfo(Action<SystemInfoDto> act);
|
||||
void OnUserReceiveCharacterData(Action<CharacterCacheDto, string> act);
|
||||
void OnUserChangePairedPlayer(Action<string, bool> act);
|
||||
void OnGroupChange(Action<GroupDto> act);
|
||||
void OnGroupUserChange(Action<GroupPairDto> act);
|
||||
void OnAdminForcedReconnect(Action act);
|
||||
void OnAdminDeleteBannedUser(Action<BannedUserDto> dto);
|
||||
void OnAdminDeleteForbiddenFile(Action<ForbiddenFileDto> act);
|
||||
void OnAdminUpdateOrAddBannedUser(Action<BannedUserDto> dto);
|
||||
void OnAdminUpdateOrAddForbiddenFile(Action<ForbiddenFileDto> dto);
|
||||
void OnReceiveServerMessage(Action<MessageSeverity, string> act);
|
||||
void OnDownloadReady(Action<Guid> act);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
namespace MareSynchronos.API
|
||||
{
|
||||
public interface ITransferFileDto
|
||||
{
|
||||
string Hash { get; set; }
|
||||
bool IsForbidden { get; set; }
|
||||
string ForbiddenBy { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace MareSynchronos.API
|
||||
{
|
||||
public class MareAuth
|
||||
{
|
||||
|
||||
public const string Auth = "/auth";
|
||||
public const string Auth_CreateIdent = "createWithIdent";
|
||||
public static Uri AuthFullPath(Uri baseUri) => new Uri(baseUri, Auth + "/" + Auth_CreateIdent);
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace MareSynchronos.API
|
||||
{
|
||||
public class MareFiles
|
||||
{
|
||||
public const string Cache = "/cache";
|
||||
public const string Cache_Get = "get";
|
||||
public static Uri CacheGetFullPath(Uri baseUri, Guid requestId) => new(baseUri, Cache + "/" + Cache_Get + "?requestId=" + requestId.ToString());
|
||||
|
||||
public const string ServerFiles = "/files";
|
||||
public const string ServerFiles_Get = "get";
|
||||
public static Uri ServerFilesGetFullPath(Uri baseUri, string hash) => new(baseUri, ServerFiles + "/" + ServerFiles_Get + "/" + hash);
|
||||
|
||||
public const string Request = "/request";
|
||||
public const string Request_Enqueue = "enqueue";
|
||||
public const string Request_RequestFile = "file";
|
||||
public const string Request_Cancel = "cancel";
|
||||
public const string Request_Check = "check";
|
||||
|
||||
public static Uri RequestEnqueueFullPath(Uri baseUri) => new(baseUri, Request + "/" + Request_Enqueue);
|
||||
public static Uri RequestRequestFileFullPath(Uri baseUri, string hash) => new(baseUri, Request + "/" + Request_RequestFile + "?file=" + hash);
|
||||
public static Uri RequestCancelFullPath(Uri baseUri, Guid guid) => new Uri(baseUri, Request + "/" + Request_Cancel + "?requestId=" + guid.ToString());
|
||||
public static Uri RequestCheckQueueFullPath(Uri baseUri, Guid guid, string hash) => new Uri(baseUri, Request + "/" + Request_Check + "?requestId=" + guid.ToString() + "&file=" + hash);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
namespace MareSynchronos.API
|
||||
{
|
||||
public enum ObjectKind
|
||||
{
|
||||
Player = 0,
|
||||
MinionOrMount = 1,
|
||||
Companion = 2,
|
||||
Pet = 3,
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
namespace MareSynchronos.API
|
||||
{
|
||||
public record OnlineUserDto
|
||||
{
|
||||
public string UID { get; set; }
|
||||
public string CharacterNameHash { get; set; }
|
||||
public bool IsModerator { get; set; }
|
||||
public bool IsAdmin { get; set; }
|
||||
}
|
||||
}
|
||||
9
MareSynchronosAPI/Routes/MareAuth.cs
Normal file
9
MareSynchronosAPI/Routes/MareAuth.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace MareSynchronos.API.Routes;
|
||||
|
||||
public class MareAuth
|
||||
{
|
||||
|
||||
public const string Auth = "/auth";
|
||||
public const string Auth_CreateIdent = "createWithIdent";
|
||||
public static Uri AuthFullPath(Uri baseUri) => new Uri(baseUri, Auth + "/" + Auth_CreateIdent);
|
||||
}
|
||||
23
MareSynchronosAPI/Routes/MareFiles.cs
Normal file
23
MareSynchronosAPI/Routes/MareFiles.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
namespace MareSynchronos.API.Routes;
|
||||
|
||||
public class MareFiles
|
||||
{
|
||||
public const string Cache = "/cache";
|
||||
public const string Cache_Get = "get";
|
||||
public static Uri CacheGetFullPath(Uri baseUri, Guid requestId) => new(baseUri, Cache + "/" + Cache_Get + "?requestId=" + requestId.ToString());
|
||||
|
||||
public const string ServerFiles = "/files";
|
||||
public const string ServerFiles_Get = "get";
|
||||
public static Uri ServerFilesGetFullPath(Uri baseUri, string hash) => new(baseUri, ServerFiles + "/" + ServerFiles_Get + "/" + hash);
|
||||
|
||||
public const string Request = "/request";
|
||||
public const string Request_Enqueue = "enqueue";
|
||||
public const string Request_RequestFile = "file";
|
||||
public const string Request_Cancel = "cancel";
|
||||
public const string Request_Check = "check";
|
||||
|
||||
public static Uri RequestEnqueueFullPath(Uri baseUri) => new(baseUri, Request + "/" + Request_Enqueue);
|
||||
public static Uri RequestRequestFileFullPath(Uri baseUri, string hash) => new(baseUri, Request + "/" + Request_RequestFile + "?file=" + hash);
|
||||
public static Uri RequestCancelFullPath(Uri baseUri, Guid guid) => new Uri(baseUri, Request + "/" + Request_Cancel + "?requestId=" + guid.ToString());
|
||||
public static Uri RequestCheckQueueFullPath(Uri baseUri, Guid guid, string hash) => new Uri(baseUri, Request + "/" + Request_Check + "?requestId=" + guid.ToString() + "&file=" + hash);
|
||||
}
|
||||
71
MareSynchronosAPI/SignalR/IMareHub.cs
Normal file
71
MareSynchronosAPI/SignalR/IMareHub.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using MareSynchronos.API.Data.Enum;
|
||||
using MareSynchronos.API.Dto;
|
||||
using MareSynchronos.API.Dto.Group;
|
||||
using MareSynchronos.API.Dto.User;
|
||||
using MareSynchronos.API.Dto.Files;
|
||||
|
||||
namespace MareSynchronos.API.SignalR;
|
||||
|
||||
public interface IMareHub
|
||||
{
|
||||
const int ApiVersion = 21;
|
||||
const string Path = "/mare";
|
||||
|
||||
Task<ConnectionDto> GetConnectionDto();
|
||||
Task<bool> CheckClientHealth();
|
||||
|
||||
Task<List<DownloadFileDto>> FilesGetSizes(List<string> hashes);
|
||||
Task FilesAbortUpload();
|
||||
Task FilesDeleteAll();
|
||||
Task<bool> FilesIsUploadFinished();
|
||||
Task<List<UploadFileDto>> FilesSend(List<string> fileListHashes);
|
||||
Task FilesUploadStreamAsync(string hash, IAsyncEnumerable<byte[]> fileContent);
|
||||
|
||||
Task<List<UserPairDto>> UserGetPairedClients();
|
||||
Task UserAddPair(UserDto user);
|
||||
Task UserRemovePair(UserDto userDto);
|
||||
Task UserSetPairPermissions(UserPermissionsDto userPermissions);
|
||||
Task<List<OnlineUserIdentDto>> UserGetOnlinePairs();
|
||||
Task UserPushData(UserCharaDataMessageDto dto);
|
||||
|
||||
Task UserDelete();
|
||||
|
||||
Task<List<BannedGroupUserDto>> GroupGetBannedUsers(GroupDto group);
|
||||
Task GroupClear(GroupDto group);
|
||||
Task GroupChangeOwnership(GroupPairDto groupPair);
|
||||
Task<bool> GroupChangePassword(GroupPasswordDto groupPassword);
|
||||
Task<GroupPasswordDto> GroupCreate();
|
||||
Task<List<GroupFullInfoDto>> GroupsGetAll();
|
||||
Task<List<GroupPairFullInfoDto>> GroupsGetUsersInGroup(GroupDto group);
|
||||
Task GroupBanUser(GroupPairDto dto, string reason);
|
||||
Task GroupChangeGroupPermissionState(GroupPermissionDto dto);
|
||||
Task GroupChangeIndividualPermissionState(GroupPairUserPermissionDto dto);
|
||||
Task GroupDelete(GroupDto group);
|
||||
Task<bool> GroupJoin(GroupPasswordDto passwordedGroup);
|
||||
Task GroupLeave(GroupDto group);
|
||||
Task GroupRemoveUser(GroupPairDto groupPair);
|
||||
Task GroupUnbanUser(GroupPairDto groupPair);
|
||||
Task GroupSetUserInfo(GroupPairUserInfoDto groupPair);
|
||||
Task<List<string>> GroupCreateTempInvite(GroupDto group, int amount);
|
||||
|
||||
Task Client_UpdateSystemInfo(SystemInfoDto systemInfo);
|
||||
Task Client_ReceiveServerMessage(MessageSeverity messageSeverity, string message);
|
||||
Task Client_DownloadReady(Guid requestId);
|
||||
|
||||
Task Client_UserSendOnline(OnlineUserIdentDto dto);
|
||||
Task Client_UserSendOffline(UserDto dto);
|
||||
Task Client_UserAddClientPair(UserPairDto dto);
|
||||
Task Client_UserRemoveClientPair(UserDto dto);
|
||||
Task Client_UserUpdateSelfPairPermissions(UserPermissionsDto dto);
|
||||
Task Client_UserUpdateOtherPairPermissions(UserPermissionsDto dto);
|
||||
Task Client_UserReceiveCharacterData(OnlineUserCharaDataDto dataDto);
|
||||
|
||||
Task Client_GroupSendFullInfo(GroupFullInfoDto groupInfo);
|
||||
Task Client_GroupSendInfo(GroupInfoDto groupInfo);
|
||||
Task Client_GroupDelete(GroupDto groupDto);
|
||||
Task Client_GroupPairJoined(GroupPairFullInfoDto groupPairInfoDto);
|
||||
Task Client_GroupPairLeft(GroupPairDto groupPairDto);
|
||||
Task Client_GroupChangePermissions(GroupPermissionDto groupPermission);
|
||||
Task Client_GroupPairChangePermissions(GroupPairUserPermissionDto permissionDto);
|
||||
Task Client_GroupPairChangeUserInfo(GroupPairUserInfoDto userInfo);
|
||||
}
|
||||
31
MareSynchronosAPI/SignalR/IMareHubClient.cs
Normal file
31
MareSynchronosAPI/SignalR/IMareHubClient.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using MareSynchronos.API.Data.Enum;
|
||||
using MareSynchronos.API.Dto;
|
||||
using MareSynchronos.API.Dto.Files;
|
||||
using MareSynchronos.API.Dto.Group;
|
||||
using MareSynchronos.API.Dto.User;
|
||||
|
||||
namespace MareSynchronos.API.SignalR;
|
||||
|
||||
public interface IMareHubClient : IMareHub
|
||||
{
|
||||
void OnUpdateSystemInfo(Action<SystemInfoDto> act);
|
||||
void OnReceiveServerMessage(Action<MessageSeverity, string> act);
|
||||
void OnDownloadReady(Action<Guid> act);
|
||||
|
||||
void OnUserSendOnline(Action<OnlineUserIdentDto> act);
|
||||
void OnUserSendOffline(Action<UserDto> act);
|
||||
void OnUserAddClientPair(Action<UserPairDto> act);
|
||||
void OnUserRemoveClientPair(Action<UserDto> act);
|
||||
void OnUserUpdateSelfPairPermissions(Action<UserPermissionsDto> act);
|
||||
void OnUserUpdateOtherPairPermissions(Action<UserPermissionsDto> act);
|
||||
void OnUserReceiveCharacterData(Action<OnlineUserCharaDataDto> act);
|
||||
|
||||
void OnGroupSendFullInfo(Action<GroupFullInfoDto> act);
|
||||
void OnGroupSendInfo(Action<GroupInfoDto> act);
|
||||
void OnGroupDelete(Action<GroupDto> act);
|
||||
void OnGroupPairJoined(Action<GroupPairFullInfoDto> act);
|
||||
void OnGroupPairLeft(Action<GroupPairDto> act);
|
||||
void OnGroupChangePermissions(Action<GroupPermissionDto> act);
|
||||
void OnGroupPairChangePermissions(Action<GroupPairUserPermissionDto> act);
|
||||
void OnGroupPairChangeUserInfo(Action<GroupPairUserInfoDto> act);
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
namespace MareSynchronos.API
|
||||
{
|
||||
public record SystemInfoDto
|
||||
{
|
||||
public int OnlineUsers { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
namespace MareSynchronos.API
|
||||
{
|
||||
public record UploadFileDto : ITransferFileDto
|
||||
{
|
||||
public string Hash { get; set; } = string.Empty;
|
||||
public bool IsForbidden { get; set; } = false;
|
||||
public string ForbiddenBy { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user