partial revert + change
This commit is contained in:
@@ -109,20 +109,11 @@ namespace MareSynchronosServer.Hubs
|
||||
other = otherToUser.UserUID
|
||||
} into leftJoin
|
||||
from otherEntry in leftJoin.DefaultIfEmpty()
|
||||
join alias in _dbContext.Aliases
|
||||
on new
|
||||
{
|
||||
uid = userToOther.UserUID
|
||||
} equals new
|
||||
{
|
||||
uid = alias.UserUID
|
||||
} into aliasLeftJoin
|
||||
from aliasEntry in aliasLeftJoin.DefaultIfEmpty()
|
||||
where
|
||||
userToOther.UserUID == userid
|
||||
select new
|
||||
{
|
||||
Alias = aliasEntry == null ? string.Empty : aliasEntry.AliasUID,
|
||||
otherEntry.OtherUser.Alias,
|
||||
userToOther.IsPaused,
|
||||
OtherIsPaused = otherEntry != null && otherEntry.IsPaused,
|
||||
userToOther.OtherUserUID,
|
||||
@@ -181,25 +172,18 @@ namespace MareSynchronosServer.Hubs
|
||||
[HubMethodName(Api.SendUserPairedClientAddition)]
|
||||
public async Task SendPairedClientAddition(string uid)
|
||||
{
|
||||
string otherUserUid = uid;
|
||||
if (uid == AuthenticatedUserId) return;
|
||||
uid = uid.Trim();
|
||||
var user = await _dbContext.Users.SingleAsync(u => u.UID == AuthenticatedUserId).ConfigureAwait(false);
|
||||
|
||||
var potentialAlias = _dbContext.Aliases.SingleOrDefault(u => u.AliasUID == uid);
|
||||
if (potentialAlias != null)
|
||||
{
|
||||
otherUserUid = potentialAlias.UserUID;
|
||||
}
|
||||
|
||||
var otherUser = await _dbContext.Users
|
||||
.SingleOrDefaultAsync(u => u.UID == otherUserUid).ConfigureAwait(false);
|
||||
.SingleOrDefaultAsync(u => u.UID == uid).ConfigureAwait(false);
|
||||
var existingEntry =
|
||||
await _dbContext.ClientPairs.AsNoTracking()
|
||||
.FirstOrDefaultAsync(p =>
|
||||
p.User.UID == AuthenticatedUserId && p.OtherUser.UID == otherUserUid).ConfigureAwait(false);
|
||||
p.User.UID == AuthenticatedUserId && p.OtherUser.UID == uid).ConfigureAwait(false);
|
||||
if (otherUser == null || existingEntry != null) return;
|
||||
_logger.LogInformation("User {AuthenticatedUserId} adding {uid} to whitelist", AuthenticatedUserId, otherUserUid);
|
||||
_logger.LogInformation("User {AuthenticatedUserId} adding {uid} to whitelist", AuthenticatedUserId, uid);
|
||||
ClientPair wl = new ClientPair()
|
||||
{
|
||||
IsPaused = false,
|
||||
@@ -208,7 +192,7 @@ namespace MareSynchronosServer.Hubs
|
||||
};
|
||||
await _dbContext.ClientPairs.AddAsync(wl).ConfigureAwait(false);
|
||||
await _dbContext.SaveChangesAsync().ConfigureAwait(false);
|
||||
var otherEntry = OppositeEntry(otherUserUid);
|
||||
var otherEntry = OppositeEntry(uid);
|
||||
await Clients.User(user.UID)
|
||||
.SendAsync(Api.OnUserUpdateClientPairs, new ClientPairDto()
|
||||
{
|
||||
@@ -219,7 +203,7 @@ namespace MareSynchronosServer.Hubs
|
||||
}, string.Empty).ConfigureAwait(false);
|
||||
if (otherEntry != null)
|
||||
{
|
||||
await Clients.User(otherUserUid).SendAsync(Api.OnUserUpdateClientPairs,
|
||||
await Clients.User(uid).SendAsync(Api.OnUserUpdateClientPairs,
|
||||
new ClientPairDto()
|
||||
{
|
||||
OtherUID = user.UID,
|
||||
@@ -237,7 +221,7 @@ namespace MareSynchronosServer.Hubs
|
||||
}
|
||||
}
|
||||
|
||||
await _metricsClient.IncGaugeAsync(new GaugeRequest() { GaugeName = MetricsAPI.GaugePairs, Value = 1 }).ConfigureAwait(false);
|
||||
await _metricsClient.IncGaugeAsync(new GaugeRequest() {GaugeName = MetricsAPI.GaugePairs, Value = 1}).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[Authorize(AuthenticationSchemes = SecretKeyGrpcAuthenticationHandler.AuthScheme)]
|
||||
|
||||
@@ -73,11 +73,11 @@ namespace MareSynchronosServer.Hubs
|
||||
user.CharacterIdentification = characterIdentification;
|
||||
await _dbContext.SaveChangesAsync().ConfigureAwait(false);
|
||||
|
||||
var alias = await _dbContext.Aliases.SingleOrDefaultAsync(u => u.UserUID == userId).ConfigureAwait(false);
|
||||
var alias = (await _dbContext.Users.SingleOrDefaultAsync(u => u.UID == userId).ConfigureAwait(false))?.Alias ?? string.Empty;
|
||||
return new ConnectionDto
|
||||
{
|
||||
ServerVersion = Api.Version,
|
||||
UID = alias == null ? userId : alias.AliasUID,
|
||||
UID = string.IsNullOrEmpty(alias) ? userId : alias,
|
||||
IsModerator = user.IsModerator,
|
||||
IsAdmin = user.IsAdmin
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user