Préparation serveur pour TypingState

This commit is contained in:
2025-09-28 22:32:05 +02:00
parent f696c1d400
commit 331cb612ad
3 changed files with 43 additions and 1 deletions

Submodule MareAPI updated: fa9b7bce43...3b175900c1

View File

@@ -54,6 +54,8 @@ namespace MareSynchronosServer.Hubs
public Task Client_UserUpdateSelfPairPermissions(UserPermissionsDto dto) => throw new PlatformNotSupportedException("Calling clientside method on server not supported"); public Task Client_UserUpdateSelfPairPermissions(UserPermissionsDto dto) => throw new PlatformNotSupportedException("Calling clientside method on server not supported");
public Task Client_UserTypingState(TypingStateDto dto) => throw new PlatformNotSupportedException("Calling clientside method on server not supported");
public Task Client_GposeLobbyJoin(UserData userData) => throw new PlatformNotSupportedException("Calling clientside method on server not supported"); public Task Client_GposeLobbyJoin(UserData userData) => throw new PlatformNotSupportedException("Calling clientside method on server not supported");
public Task Client_GposeLobbyLeave(UserData userData) => throw new PlatformNotSupportedException("Calling clientside method on server not supported"); public Task Client_GposeLobbyLeave(UserData userData) => throw new PlatformNotSupportedException("Calling clientside method on server not supported");
public Task Client_GposeLobbyPushCharacterData(CharaDataDownloadDto charaDownloadDto) => throw new PlatformNotSupportedException("Calling clientside method on server not supported"); public Task Client_GposeLobbyPushCharacterData(CharaDataDownloadDto charaDownloadDto) => throw new PlatformNotSupportedException("Calling clientside method on server not supported");

View File

@@ -0,0 +1,40 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using MareSynchronos.API.Data.Extensions;
using MareSynchronos.API.Dto.User;
using MareSynchronosServer.Utils;
using Microsoft.AspNetCore.Authorization;
using Microsoft.EntityFrameworkCore;
namespace MareSynchronosServer.Hubs;
public partial class MareHub
{
[Authorize(Policy = "Identified")]
public async Task UserSetTypingState(bool isTyping)
{
_logger.LogCallInfo(MareHubLogger.Args(isTyping));
var pairedEntries = await GetAllPairedClientsWithPauseState().ConfigureAwait(false);
if (pairedEntries.Count == 0)
return;
var recipients = pairedEntries
.Where(p => !p.IsPaused)
.Select(p => p.UID)
.Distinct(StringComparer.Ordinal)
.ToList();
if (recipients.Count == 0)
return;
var sender = await DbContext.Users.AsNoTracking()
.SingleAsync(u => u.UID == UserUID)
.ConfigureAwait(false);
var typingDto = new TypingStateDto(sender.ToUserData(), isTyping);
await Clients.Users(recipients).Client_UserTypingState(typingDto).ConfigureAwait(false);
}
}