* tag '0.9.17': add census popup on connection api update census update heave fewer redraws as main method for data application, minor fixes remove unnecessary exists check add visibility for loaded mods size for pair, use menu bar for settings, remove settings button fix staging issues add download throttling, change header of mare, fix reverting players when going offline/paused when not visible use name for glamourer revert fix startup breaking add inner exception stacktraces calc correct button size wording add permission popup ui fix getting identifier during zoning indent nonscaled remove unnecessary usings ui icon boogaloo fix cache dict wtf add normalized icons add owner/moderator/pinned user icons check tokentime more precisely in both directions more cleanup fix sorting and cleanup make local groups more usable for pause/resume fix outlined font rework creation of popout windows into factory and some refactoring in general make syncshell admin ui to standalone window remove close button on intro ui do not allow to open main ui without finishing setup readonly bla wait for plugin disposal fix palette wording fix palette application and add experimental less redraws option some minor fixes check for timezone idk adjust token handling fix total user count in syncshell (distinct by UIDs) fix text alignment fix some shit maybe idk some fixes I guess fix offset for transfer bar at the bottom, use async collections, clear filter on tab change + add button to clear, require ctrl for align syncshells blah Some display options for DTR tooltip (#66) add ordering adjust api to latest rework main ui add total count on mouseover, make syncshell windows non-blocking fix token for character change, add online count to syncshells and groups argh fix broken font in header add more options for the compactui fix icons and text of buttons being static in place remove logspam
109 lines
3.7 KiB
C#
109 lines
3.7 KiB
C#
using MareSynchronos.API.Data;
|
|
using MareSynchronos.API.Dto.User;
|
|
using Microsoft.AspNetCore.SignalR.Client;
|
|
using Microsoft.Extensions.Logging;
|
|
using System.Text;
|
|
|
|
namespace MareSynchronos.WebAPI;
|
|
|
|
public partial class ApiController
|
|
{
|
|
public async Task PushCharacterData(CharacterData data, List<UserData> visibleCharacters)
|
|
{
|
|
if (!IsConnected) return;
|
|
|
|
try
|
|
{
|
|
await PushCharacterDataInternal(data, visibleCharacters.ToList()).ConfigureAwait(false);
|
|
}
|
|
catch (OperationCanceledException)
|
|
{
|
|
Logger.LogDebug("Upload operation was cancelled");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Logger.LogWarning(ex, "Error during upload of files");
|
|
}
|
|
}
|
|
|
|
public async Task UserAddPair(UserDto user)
|
|
{
|
|
if (!IsConnected) return;
|
|
await _mareHub!.SendAsync(nameof(UserAddPair), user).ConfigureAwait(false);
|
|
}
|
|
|
|
public async Task UserDelete()
|
|
{
|
|
CheckConnection();
|
|
await _mareHub!.SendAsync(nameof(UserDelete)).ConfigureAwait(false);
|
|
await CreateConnections().ConfigureAwait(false);
|
|
}
|
|
|
|
public async Task<List<OnlineUserIdentDto>> UserGetOnlinePairs()
|
|
{
|
|
return await _mareHub!.InvokeAsync<List<OnlineUserIdentDto>>(nameof(UserGetOnlinePairs)).ConfigureAwait(false);
|
|
}
|
|
|
|
public async Task<List<UserPairDto>> UserGetPairedClients()
|
|
{
|
|
return await _mareHub!.InvokeAsync<List<UserPairDto>>(nameof(UserGetPairedClients)).ConfigureAwait(false);
|
|
}
|
|
|
|
public async Task<UserProfileDto> UserGetProfile(UserDto dto)
|
|
{
|
|
if (!IsConnected) return new UserProfileDto(dto.User, false, null, null, null);
|
|
return await _mareHub!.InvokeAsync<UserProfileDto>(nameof(UserGetProfile), dto).ConfigureAwait(false);
|
|
}
|
|
|
|
public async Task UserPushData(UserCharaDataMessageDto dto)
|
|
{
|
|
try
|
|
{
|
|
await _mareHub!.InvokeAsync(nameof(UserPushData), dto).ConfigureAwait(false);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Logger.LogWarning(ex, "Failed to Push character data");
|
|
}
|
|
}
|
|
|
|
public async Task UserRemovePair(UserDto userDto)
|
|
{
|
|
if (!IsConnected) return;
|
|
await _mareHub!.SendAsync(nameof(UserRemovePair), userDto).ConfigureAwait(false);
|
|
}
|
|
|
|
public async Task UserReportProfile(UserProfileReportDto userDto)
|
|
{
|
|
if (!IsConnected) return;
|
|
await _mareHub!.SendAsync(nameof(UserReportProfile), userDto).ConfigureAwait(false);
|
|
}
|
|
|
|
public async Task UserSetPairPermissions(UserPermissionsDto userPermissions)
|
|
{
|
|
await _mareHub!.SendAsync(nameof(UserSetPairPermissions), userPermissions).ConfigureAwait(false);
|
|
}
|
|
|
|
public async Task UserSetProfile(UserProfileDto userDescription)
|
|
{
|
|
if (!IsConnected) return;
|
|
await _mareHub!.InvokeAsync(nameof(UserSetProfile), userDescription).ConfigureAwait(false);
|
|
}
|
|
|
|
private async Task PushCharacterDataInternal(CharacterData character, List<UserData> visibleCharacters)
|
|
{
|
|
Logger.LogInformation("Pushing character data for {hash} to {charas}", character.DataHash.Value, string.Join(", ", visibleCharacters.Select(c => c.AliasOrUID)));
|
|
StringBuilder sb = new();
|
|
foreach (var kvp in character.FileReplacements.ToList())
|
|
{
|
|
sb.AppendLine($"FileReplacements for {kvp.Key}: {kvp.Value.Count}");
|
|
}
|
|
foreach (var item in character.GlamourerData)
|
|
{
|
|
sb.AppendLine($"GlamourerData for {item.Key}: {!string.IsNullOrEmpty(item.Value)}");
|
|
}
|
|
Logger.LogDebug("Chara data contained: {nl} {data}", Environment.NewLine, sb.ToString());
|
|
|
|
await UserPushData(new(visibleCharacters, character)).ConfigureAwait(false);
|
|
}
|
|
} |