adjusting notifications
This commit is contained in:
Submodule LightlessAPI updated: 69f0e310bd...6c542c0ccc
@@ -59,7 +59,7 @@ public class BroadcastConfiguration : IBroadcastConfiguration
|
|||||||
return string.Concat(RedisKeyPrefix, hashedCid);
|
return string.Concat(RedisKeyPrefix, hashedCid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string BuildPairRequestNotification(string displayName)
|
public string BuildPairRequestNotification()
|
||||||
{
|
{
|
||||||
var template = Options.PairRequestNotificationTemplate;
|
var template = Options.PairRequestNotificationTemplate;
|
||||||
if (string.IsNullOrWhiteSpace(template))
|
if (string.IsNullOrWhiteSpace(template))
|
||||||
@@ -67,8 +67,6 @@ public class BroadcastConfiguration : IBroadcastConfiguration
|
|||||||
template = DefaultNotificationTemplate;
|
template = DefaultNotificationTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
displayName = string.IsNullOrWhiteSpace(displayName) ? "Someone" : displayName;
|
return template;
|
||||||
|
|
||||||
return template.Replace("{DisplayName}", displayName, StringComparison.Ordinal);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,5 +12,5 @@ public interface IBroadcastConfiguration
|
|||||||
bool EnableSyncshellBroadcastPayloads { get; }
|
bool EnableSyncshellBroadcastPayloads { get; }
|
||||||
|
|
||||||
string BuildRedisKey(string hashedCid);
|
string BuildRedisKey(string hashedCid);
|
||||||
string BuildPairRequestNotification(string displayName);
|
string BuildPairRequestNotification();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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_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_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_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_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_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");
|
public Task Client_UserReceiveCharacterData(OnlineUserCharaDataDto dataDto) => throw new PlatformNotSupportedException("Calling clientside method on server not supported");
|
||||||
|
|||||||
@@ -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);
|
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));
|
_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;
|
return;
|
||||||
|
|
||||||
if (!_broadcastConfiguration.EnableBroadcasting || !_broadcastConfiguration.NotifyOwnerOnPairRequest)
|
if (!_broadcastConfiguration.EnableBroadcasting || !_broadcastConfiguration.NotifyOwnerOnPairRequest)
|
||||||
@@ -313,10 +313,12 @@ public partial class LightlessHub
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var senderAlias = Context.User?.Claims?.SingleOrDefault(c => string.Equals(c.Type, LightlessClaimTypes.Alias, StringComparison.Ordinal))?.Value;
|
var senderAlias = Context.User?.Claims?.SingleOrDefault(c => string.Equals(c.Type, LightlessClaimTypes.Alias, StringComparison.Ordinal))?.Value;
|
||||||
var displayName = string.IsNullOrWhiteSpace(senderAlias) ? UserUID : senderAlias;
|
//var displayName = string.IsNullOrWhiteSpace(senderAlias) ? UserUID : senderAlias;
|
||||||
var message = _broadcastConfiguration.BuildPairRequestNotification(displayName);
|
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
|
private class PairingPayload
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user