From 272f1afd9e3a113783b956d0db2e629023ea64ef Mon Sep 17 00:00:00 2001 From: rootdarkarchon Date: Wed, 18 Oct 2023 16:44:18 +0200 Subject: [PATCH] potentially fix group join --- .../Hubs/MareHub.Groups.cs | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/MareSynchronosServer/MareSynchronosServer/Hubs/MareHub.Groups.cs b/MareSynchronosServer/MareSynchronosServer/Hubs/MareHub.Groups.cs index 5a9897f..84def2b 100644 --- a/MareSynchronosServer/MareSynchronosServer/Hubs/MareHub.Groups.cs +++ b/MareSynchronosServer/MareSynchronosServer/Hubs/MareHub.Groups.cs @@ -542,19 +542,26 @@ public partial class MareHub var otherPermissionToSelf = userinfo?.OtherPermissions ?? null; if (otherPermissionToSelf == null) { - var otherPreferred = await _dbContext.GroupPairPreferredPermissions.SingleAsync(u => u.GroupGID == group.GID && u.UserUID == pair.GroupUserUID).ConfigureAwait(false); - otherPermissionToSelf = new() - { - UserUID = pair.GroupUserUID, - OtherUserUID = UserUID, - DisableAnimations = otherPreferred.DisableAnimations, - DisableSounds = otherPreferred.DisableSounds, - DisableVFX = otherPreferred.DisableVFX, - IsPaused = otherPreferred.IsPaused, - Sticky = false - }; + var existingPermissionsOnDb = await _dbContext.Permissions.SingleOrDefaultAsync(p => p.UserUID == pair.GroupUserUID && p.OtherUserUID == UserUID).ConfigureAwait(false); - await _dbContext.AddAsync(otherPermissionToSelf).ConfigureAwait(false); + if (existingPermissionsOnDb == null) + { + var otherPreferred = await _dbContext.GroupPairPreferredPermissions.SingleAsync(u => u.GroupGID == group.GID && u.UserUID == pair.GroupUserUID).ConfigureAwait(false); + otherPermissionToSelf = new() + { + UserUID = pair.GroupUserUID, + OtherUserUID = UserUID, + DisableAnimations = otherPreferred.DisableAnimations, + DisableSounds = otherPreferred.DisableSounds, + DisableVFX = otherPreferred.DisableVFX, + IsPaused = otherPreferred.IsPaused, + Sticky = false + }; + + await _dbContext.AddAsync(otherPermissionToSelf).ConfigureAwait(false); + } + + otherPermissionToSelf = existingPermissionsOnDb; } await Clients.User(UserUID).Client_GroupPairJoined(new GroupPairFullInfoDto(group.ToGroupData(),