diff --git a/LightlessAPI b/LightlessAPI index 852e2a0..c3caa7e 160000 --- a/LightlessAPI +++ b/LightlessAPI @@ -1 +1 @@ -Subproject commit 852e2a005f5bfdf3844e057c6ba71de6f5f84ed8 +Subproject commit c3caa7e25cf17fd52c4765bf051ec37c8fd92082 diff --git a/LightlessSyncServer/LightlessSyncServer/Hubs/LightlessHub.User.cs b/LightlessSyncServer/LightlessSyncServer/Hubs/LightlessHub.User.cs index bda6d24..1614af9 100644 --- a/LightlessSyncServer/LightlessSyncServer/Hubs/LightlessHub.User.cs +++ b/LightlessSyncServer/LightlessSyncServer/Hubs/LightlessHub.User.cs @@ -1322,16 +1322,27 @@ public partial class LightlessHub [Authorize(Policy = "Identified")] - public async Task ToggleLocationSharing(LocationSharingToggleDto dto) + public async Task ToggleLocationSharing(LocationSharingToggleDto dto) { _logger.LogCallInfo(LightlessHubLogger.Args(UserUID,dto)); - await DbContext.Permissions.Where(x => x.UserUID == UserUID && dto.users.Contains(x.OtherUserUID)) - .ExecuteUpdateAsync(setter => - setter.SetProperty(x => x.ShareLocationUntil, dto.duration.ToUniversalTime()), cancellationToken: RequestAbortedToken).ConfigureAwait(false); - - //update user's location for target users - var currentLocation = await _redis.GetAsync($"Location:{UserUID}").ConfigureAwait(false); - await Clients.Users(dto.users).Client_SendLocationToClient(currentLocation, dto.duration.ToUniversalTime()).ConfigureAwait(false); + try + { + await DbContext.Permissions.Where(x => x.UserUID == UserUID && dto.users.Contains(x.OtherUserUID)) + .ExecuteUpdateAsync(setter => + setter.SetProperty(x => x.ShareLocationUntil, dto.duration.ToUniversalTime()), + cancellationToken: RequestAbortedToken).ConfigureAwait(false); + + //update user's location for target users + var currentLocation = await _redis.GetAsync($"Location:{UserUID}").ConfigureAwait(false); + await Clients.Users(dto.users).Client_SendLocationToClient(currentLocation, dto.duration.ToUniversalTime()) + .ConfigureAwait(false); + } + catch (Exception ex) + { + _logger.LogError(ex, "ToggleLocationSharing error:"); + return false; + } + return true; } [GeneratedRegex(@"^([a-z0-9_ '+&,\.\-\{\}]+\/)+([a-z0-9_ '+&,\.\-\{\}]+\.[a-z]{3,4})$", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.ECMAScript)]