From 610461fa995acb3afacbfa3ce7ae01d4626c4600 Mon Sep 17 00:00:00 2001 From: azyges <229218900+azyges@users.noreply.github.com> Date: Thu, 2 Oct 2025 09:21:21 +0900 Subject: [PATCH] adjusting notifications --- LightlessAPI | 2 +- .../Configuration/BroadcastConfiguration.cs | 6 ++---- .../Configuration/IBroadcastConfiguration.cs | 2 +- .../Hubs/LightlessHub.ClientStubs.cs | 1 + .../LightlessSyncServer/Hubs/LightlessHub.User.cs | 14 ++++++++------ 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/LightlessAPI b/LightlessAPI index 69f0e31..6c542c0 160000 --- a/LightlessAPI +++ b/LightlessAPI @@ -1 +1 @@ -Subproject commit 69f0e310bd78e0c56eab298199e6e2ca15bf56bd +Subproject commit 6c542c0ccca0327896ef895f9de02a76869ea311 diff --git a/LightlessSyncServer/LightlessSyncServer/Configuration/BroadcastConfiguration.cs b/LightlessSyncServer/LightlessSyncServer/Configuration/BroadcastConfiguration.cs index 560ea00..893ec65 100644 --- a/LightlessSyncServer/LightlessSyncServer/Configuration/BroadcastConfiguration.cs +++ b/LightlessSyncServer/LightlessSyncServer/Configuration/BroadcastConfiguration.cs @@ -59,7 +59,7 @@ public class BroadcastConfiguration : IBroadcastConfiguration return string.Concat(RedisKeyPrefix, hashedCid); } - public string BuildPairRequestNotification(string displayName) + public string BuildPairRequestNotification() { var template = Options.PairRequestNotificationTemplate; if (string.IsNullOrWhiteSpace(template)) @@ -67,8 +67,6 @@ public class BroadcastConfiguration : IBroadcastConfiguration template = DefaultNotificationTemplate; } - displayName = string.IsNullOrWhiteSpace(displayName) ? "Someone" : displayName; - - return template.Replace("{DisplayName}", displayName, StringComparison.Ordinal); + return template; } } diff --git a/LightlessSyncServer/LightlessSyncServer/Configuration/IBroadcastConfiguration.cs b/LightlessSyncServer/LightlessSyncServer/Configuration/IBroadcastConfiguration.cs index 7320720..0f741f7 100644 --- a/LightlessSyncServer/LightlessSyncServer/Configuration/IBroadcastConfiguration.cs +++ b/LightlessSyncServer/LightlessSyncServer/Configuration/IBroadcastConfiguration.cs @@ -12,5 +12,5 @@ public interface IBroadcastConfiguration bool EnableSyncshellBroadcastPayloads { get; } string BuildRedisKey(string hashedCid); - string BuildPairRequestNotification(string displayName); + string BuildPairRequestNotification(); } diff --git a/LightlessSyncServer/LightlessSyncServer/Hubs/LightlessHub.ClientStubs.cs b/LightlessSyncServer/LightlessSyncServer/Hubs/LightlessHub.ClientStubs.cs index c4fbe0c..7fbb954 100644 --- a/LightlessSyncServer/LightlessSyncServer/Hubs/LightlessHub.ClientStubs.cs +++ b/LightlessSyncServer/LightlessSyncServer/Hubs/LightlessHub.ClientStubs.cs @@ -19,6 +19,7 @@ namespace LightlessSyncServer.Hubs public Task Client_GroupSendProfile(GroupProfileDto groupProfile) => throw new PlatformNotSupportedException("Calling clientside method on server not supported"); public Task Client_GroupSendInfo(GroupInfoDto dto) => throw new PlatformNotSupportedException("Calling clientside method on server not supported"); public Task Client_ReceiveServerMessage(MessageSeverity messageSeverity, string message) => throw new PlatformNotSupportedException("Calling clientside method on server not supported"); + public Task Client_ReceiveBroadcastPairRequest(UserPairNotificationDto dto) => throw new PlatformNotSupportedException("Calling clientside method on server not supported"); public Task Client_UpdateSystemInfo(SystemInfoDto systemInfo) => throw new PlatformNotSupportedException("Calling clientside method on server not supported"); public Task Client_UserAddClientPair(UserPairDto dto) => throw new PlatformNotSupportedException("Calling clientside method on server not supported"); public Task Client_UserReceiveCharacterData(OnlineUserCharaDataDto dataDto) => throw new PlatformNotSupportedException("Calling clientside method on server not supported"); diff --git a/LightlessSyncServer/LightlessSyncServer/Hubs/LightlessHub.User.cs b/LightlessSyncServer/LightlessSyncServer/Hubs/LightlessHub.User.cs index 914e181..5a8c164 100644 --- a/LightlessSyncServer/LightlessSyncServer/Hubs/LightlessHub.User.cs +++ b/LightlessSyncServer/LightlessSyncServer/Hubs/LightlessHub.User.cs @@ -262,14 +262,14 @@ public partial class LightlessHub await Clients.Caller.Client_ReceiveServerMessage(MessageSeverity.Information, $"Pair request sent. Waiting for the other player to confirm.").ConfigureAwait(false); _logger.LogCallInfo(LightlessHubLogger.Args("stored pairing request", myCid, otherCid)); - await NotifyBroadcastOwnerOfPairRequest(otherCid).ConfigureAwait(false); + await NotifyBroadcastOwnerOfPairRequest(myCid, otherCid).ConfigureAwait(false); } } - private async Task NotifyBroadcastOwnerOfPairRequest(string targetHashedCid) + private async Task NotifyBroadcastOwnerOfPairRequest(string myHashedCid, string targetHashedCid) { - if (string.IsNullOrWhiteSpace(targetHashedCid)) + if (string.IsNullOrWhiteSpace(targetHashedCid) || string.IsNullOrWhiteSpace(myHashedCid)) return; if (!_broadcastConfiguration.EnableBroadcasting || !_broadcastConfiguration.NotifyOwnerOnPairRequest) @@ -313,10 +313,12 @@ public partial class LightlessHub return; var senderAlias = Context.User?.Claims?.SingleOrDefault(c => string.Equals(c.Type, LightlessClaimTypes.Alias, StringComparison.Ordinal))?.Value; - var displayName = string.IsNullOrWhiteSpace(senderAlias) ? UserUID : senderAlias; - var message = _broadcastConfiguration.BuildPairRequestNotification(displayName); + //var displayName = string.IsNullOrWhiteSpace(senderAlias) ? UserUID : senderAlias; + var message = _broadcastConfiguration.BuildPairRequestNotification(); - await Clients.User(entry.OwnerUID).Client_ReceiveServerMessage(MessageSeverity.Information, message).ConfigureAwait(false); + var dto = new UserPairNotificationDto{myHashedCid = myHashedCid, message = message}; + + await Clients.User(entry.OwnerUID).Client_ReceiveBroadcastPairRequest(dto).ConfigureAwait(false); } private class PairingPayload {